Angular-cli: Math minified on --prod build

Created on 1 Nov 2018  路  9Comments  路  Source: angular/angular-cli

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

blocked devkibuild-angular low regression bufix

All 9 comments

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

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.

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 actually, the package bump will be picked automatically as Terser is not a direct dependency of Angular CLI, but rather a transitive one.

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

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

Closing a terser released a fix for this.

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._

Was this page helpful?
0 / 5 - 0 ratings