angular-cli: ERROR in vendor... from UglifyJs Unexpected character '`'

When I build or serve without AOT it works but when using --prod I get:

ERROR in vendor.8ebdc3713b6c81a2665a.bundle.js from UglifyJs Unexpected character ‘`’ [vendor.8ebdc3713b6c81a2665a.bundle.js:70273,25]

My tsconfig.json:

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

My tsconfig.app.json:

{"compilerOptions": {
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": ["es2016","dom"],
    "outDir": "../out-tsc/app",
    "target": "es5",
    "module": "es2015",
    "baseUrl": "",
    "types": []},
  "exclude": ["test.ts","**/*.spec.ts"]}

Config:

@angular/cli: 1.0.0-rc.1
node: 6.9.2
os: win32 x64
@angular/common: 4.0.0-rc.2
@angular/compiler: 4.0.0-rc.2
@angular/core: 4.0.0-rc.2
@angular/forms: 4.0.0-rc.2
@angular/http: 4.0.0-rc.2
@angular/platform-browser: 4.0.0-rc.2
@angular/platform-browser-dynamic: 4.0.0-rc.2
@angular/router: 4.0.0-rc.2
@angular/cli: 1.0.0-rc.1
@angular/compiler-cli: 4.0.0-rc.2

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 6
  • Comments: 23 (5 by maintainers)

Most upvoted comments

It’s because you install dependencies which use ES2016 features like template strings, fat arrow functions, etc. UglifyJS can’t handle them and crashes.

More information can be found in this thread https://github.com/sindresorhus/ama/issues/446 as it discusses possible workarounds.

I was tired of the entire discussion and created babel-engine-plugin which is a webpack plugin that only transpiles dependencies targetting Node.js >= 0.12. The only downside is that you’d have to eject your webpack config. Or Angular-CLI should embed it.

I have the same question,+1

I don’t either but I think it is related to how some TPL are compiled. I just wish to see where it breaks in a file or in console, somewhere but can’t find a flag for the cli to output intermediate files.