Skip to content

UglifyJS breaking ng build --prod #7756

@hugodes

Description

@hugodes

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Versions.

@angular/cli: 1.4.2
node: 8.5.0
os: darwin x64
@angular/animations: 4.4.3
@angular/common: 4.4.3
@angular/compiler: 4.4.3
@angular/core: 4.4.3
@angular/forms: 4.4.3
@angular/http: 4.4.3
@angular/platform-browser: 4.4.3
@angular/platform-browser-dynamic: 4.4.3
@angular/router: 4.4.3
@angular/cli: 1.4.2
@angular/compiler-cli: 4.4.3
@angular/language-service: 4.4.3
typescript: 2.3.4

Repro steps.

One part of the problem is I can't find the root of it, building with ng build --prod --sourcemaps, still doesn't reference the area in the code which doesn't work

The log given by the failure.

ng build --prod

Date: 2017-09-20T13:43:50.815Z
Hash: 50c525c6fe0425118ede
Time: 93360ms
chunk {0} polyfills.02292696f70cecd900dd.bundle.js (polyfills) 190 kB {4} [initial] [rendered]
chunk {1} main.fc82f1345284e30cbd13.bundle.js (main) 5.98 MB {3} [initial] [rendered]
chunk {2} styles.122ee5153af13aed7be2.bundle.css (styles) 122 kB {4} [initial] [rendered]
chunk {3} vendor.1f1e29f52bc669b282ae.bundle.js (vendor) 2.63 MB [initial] [rendered]
chunk {4} inline.a2a6d04122157473c4e7.bundle.js (inline) 1.45 kB [entry] [rendered]

ERROR in main.fc82f1345284e30cbd13.bundle.js from UglifyJs
TypeError: Cannot set property 'fixed' of undefined
at TreeWalker.eval [as visit] (eval at (/Users/hugodes/src/core-front/node_modules/uglifyjs-webpack-plugin/node_modules/uglify-js/tools/node.js:27:1), :5584:25)
at TreeWalker._visit (eval at (/Users/hugodes/src/core-front/node_modules/uglifyjs-webpack-plugin/node_modules/uglify-js/tools/node.js:27:1), :1339:24)
at AST_This._walk (eval at (/Users/hugodes/src/core-front/node_modules/uglifyjs-webpack-plugin/node_modules/uglify-js/tools/node.js:27:1), :480:24)
at AST_Dot.eval (eval at (/Users/hugodes/src/core-front/node_modules/uglifyjs-webpack-plugin/node_modules/uglify-js/tools/node.js:27:1), :1061:29)
at TreeWalker._visit (eval at (/Users/hugodes/src/core-front/node_modules/uglifyjs-webpack-plugin/node_modules/uglify-js/tools/node.js:27:1), :1343:21)
at AST_Dot._walk (eval at (/Users/hugodes/src/core-front/node_modules/uglifyjs-webpack-plugin/node_modules/uglify-js/tools/node.js:27:1), :1060:24)
at AST_Dot.walk (eval at (/Users/hugodes/src/core-front/node_modules/uglifyjs-webpack-plugin/node_modules/uglify-js/tools/node.js:27:1), :483:21)
at TreeWalker.eval [as visit] (eval at (/Users/hugodes/src/core-front/node_modules/uglifyjs-webpack-plugin/node_modules/uglify-js/tools/node.js:27:1), :5722:31)
at TreeWalker._visit (eval at (/Users/hugodes/src/core-front/node_modules/uglifyjs-webpack-plugin/node_modules/uglify-js/tools/node.js:27:1), :1339:24)
at AST_ForIn._walk (eval at (/Users/hugodes/src/core-front/node_modules/uglifyjs-webpack-plugin/node_modules/uglify-js/tools/node.js:27:1), :653:24)
at walk_body (eval at (/Users/hugodes/src/core-front/node_modules/uglifyjs-webpack-plugin/node_modules/uglify-js/tools/node.js:27:1), :530:17)
at AST_BlockStatement.eval (eval at (/Users/hugodes/src/core-front/node_modules/uglifyjs-webpack-plugin/node_modules/uglify-js/tools/node.js:27:1), :541:13)
at TreeWalker._visit (eval at (/Users/hugodes/src/core-front/node_modules/uglifyjs-webpack-plugin/node_modules/uglify-js/tools/node.js:27:1), :1343:21)
at AST_BlockStatement._walk (eval at (/Users/hugodes/src/core-front/node_modules/uglifyjs-webpack-plugin/node_modules/uglify-js/tools/node.js:27:1), :540:24)
at AST_BlockStatement.walk (eval at (/Users/hugodes/src/core-front/node_modules/uglifyjs-webpack-plugin/node_modules/uglify-js/tools/node.js:27:1), :483:21)
at TreeWalker.eval [as visit] (eval at (/Users/hugodes/src/core-front/node_modules/uglifyjs-webpack-plugin/node_modules/uglify-js/tools/node.js:27:1), :5697:31)
at TreeWalker._visit (eval at (/Users/hugodes/src/core-front/node_modules/uglifyjs-webpack-plugin/node_modules/uglify-js/tools/node.js:27:1), :1339:24)
at AST_If._walk (eval at (/Users/hugodes/src/core-front/node_modules/uglifyjs-webpack-plugin/node_modules/uglify-js/tools/node.js:27:1), :843:24)
at walk_body (eval at (/Users/hugodes/src/core-front/node_modules/uglifyjs-webpack-plugin/node_modules/uglify-js/tools/node.js:27:1), :530:17)
at AST_Function.eval (eval at (/Users/hugodes/src/core-front/node_modules/uglifyjs-webpack-plugin/node_modules/uglify-js/tools/node.js:27:1), :771:13)
at eval (eval at (/Users/hugodes/src/core-front/node_modules/uglifyjs-webpack-plugin/node_modules/uglify-js/tools/node.js:27:1), :1340:21)
at TreeWalker.eval [as visit] (eval at (/Users/hugodes/src/core-front/node_modules/uglifyjs-webpack-plugin/node_modules/uglify-js/tools/node.js:27:1), :5665:21)

Also worth noting, that when I do a ng build --dev, and open the main.bundle.js, there is no reference to the term "fixed" anywhere. So I really cant trace the problem.

Desired functionality.

That the ng build --prod works without problem.
Failing that, I'd like to get some more info from --sourcemaps, because right now, the stacktrace references a file that does not exist

Mention any other details that might be useful.

I can't link the project as it's private, but I wouldn't mind sending a copy of the source code to someone on the angular-cli team privately.

Things I tried:

  • Updating @angular/cli doens't solve the issue.
  • rm -rf /node_modules && rm package-lock.json && npm cache clear --force && npm install doesn't work
  • adding uglify-js@2 to package.json doesn't work
  • I've been at it for a long time, so I've gone through most of the google search results, trying everything without success.

Package.json

{
  "name": "front",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "gulp sass && ng serve -e=local",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^4.2.4",
    "@angular/common": "^4.2.4",
    "@angular/compiler": "^4.2.4",
    "@angular/core": "^4.2.4",
    "@angular/forms": "^4.2.4",
    "@angular/http": "^4.2.4",
    "@angular/platform-browser": "^4.2.4",
    "@angular/platform-browser-dynamic": "^4.2.4",
    "@angular/router": "^4.2.4",
    "angular2-jwt": "^0.2.3",
    "aws-sdk": "^2.119.0",
    "classlist.js": "^1.1.20150312",
    "core-js": "^2.4.1",
    "file-saver": "^1.3.3",
   "intl": "^1.2.5",
    "mydatepicker": "^2.0.31",
    "ng2-charts": "^1.6.0",
    "rxjs": "^5.4.2",
    "web-animations-js": "^2.3.1",
    "zone.js": "^0.8.14"
  },
  "devDependencies": {
    "@angular/cli": "1.4.2",
    "@angular/compiler-cli": "^4.2.4",
    "@angular/language-service": "^4.2.4",
    "@types/jasmine": "~2.5.53",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "codelyzer": "~3.1.1",
    "jasmine-core": "~2.6.2",
    "jasmine-spec-reporter": "~4.1.0",
    "karma": "~1.7.0",
    "karma-chrome-launcher": "~2.1.1",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.1.2",
    "ts-node": "~3.2.0",
    "tslint": "~5.3.2",
    "typescript": "~2.3.3"
  }
}

tsconfig.json:

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2017",
      "dom"
    ]
  }
}

tsconfig.app.json

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/app",
    "baseUrl": "./",
    "module": "es2015",
    "types": [
      "node",
      "file-saver"
    ]
  },
  "exclude": [
    "test.ts",
    "**/*.spec.ts"
  ]
}

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgenttype: bug/fix

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions