angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Math minified on --prod build

Open Gamblt opened this issue 8 years ago • 9 comments

Bug Report or Feature Request (mark with an x)

- [x ] bug report

Command (mark with an x)

- [ ] new
- [ x] build
- [ ] serve

Versions

Angular CLI: 7.0.3 Node: 8.12.0 Npm 6.4.1 OS: linux x64 Angular: 7.0.1

After update angular from v6.1 to v7 with all dependencies serve and build with flag --prod make an issue in crypto-js library with native Math function. ERROR TypeError: Cannot read property 'ceil' of undefined

Library code: words.length = Math.ceil(sigBytes / 4); Minified code: t.length=r.ceil(e/4) r - undefined as expected.

Desired functionality

Save native window.[Objects] without minification

Repro steps

ng new testapp
cd ./testapp
npm install crypto-js --save

Update app.component

import { Component } from '@angular/core';
import * as CryptoJS from 'crypto-js';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent {
  title = 'Title:' + CryptoJS.SHA256('helloworld');;
}

ng serve --prod

Gamblt avatar Nov 01 '18 16:11 Gamblt

@Gamblt I'm experiencing this issue as well. Have you discovered a workaround?

KClough avatar Nov 01 '18 20:11 KClough

This is an upstream bug https://github.com/terser-js/terser/issues/156, which should been solved by https://github.com/terser-js/terser/pull/154

However, it has not been released yet.

alan-agius4 avatar Nov 02 '18 09:11 alan-agius4

Ugh. Happens for me as well. Just my luck that I updated right before adding PWA to our app, which kinda needs production builds to make sense.

Oh well, at least it seems like a fixed release of Terser is imminent (I guess it's possible to manually bump Terser as soon as they release, instead of waiting for an angular-cli release to pick it up).

LosD avatar Nov 02 '18 13:11 LosD

@LosD actually, the package bump will be picked automatically as Terser is not a direct dependency of Angular CLI, but rather a transitive one.

alan-agius4 avatar Nov 02 '18 15:11 alan-agius4

Our team resolved this issue by manually installing the fixed release of Terser.

KClough avatar Nov 02 '18 15:11 KClough

This might be helpful, https://github.com/angular/angular-cli/issues/12414

Temkit avatar Nov 03 '18 07:11 Temkit

Please try [email protected] and report your findings in this thread.

You'd have to adapt the instructions in this post to install this new terser version: https://github.com/angular/angular-cli/issues/12414#issuecomment-434615979

kzc avatar Nov 03 '18 19:11 kzc

Closing a terser released a fix for this.

alan-agius4 avatar Nov 05 '18 21:11 alan-agius4

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.