Angular-cli: ng build --prod generates error if target is es6

Created on 18 Nov 2016  路  9Comments  路  Source: angular/angular-cli

Please provide us with the following information:

OS?

Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)
Windows 7

Versions.

Please run ng --version. If there's nothing outputted, please run in a Terminal: node --version and paste the result here:
D:\intelliJ\testcli\cli>ng --version
angular-cli: 1.0.0-beta.20-4
node: 6.2.0
os: win32 x64

Repro steps.

Was this an app that wasn't created using the CLI? What change did you do on your code? etc.
Fresh installed angular cli. Only change the target option to es6 will cause the error.
{
"compilerOptions": {
"baseUrl": "",
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": ["es6", "dom"],
"mapRoot": "./",
"module": "es6",
"moduleResolution": "node",
"outDir": "../dist/out-tsc",
"sourceMap": true,
"target": "es6", <<<<<<<<<<<<<<<<<<<<<<<<<<<
"typeRoots": [
"../node_modules/@types"
]
}
}

The log given by the failure.

Normally this include a stack trace and some more information.

ERROR in main.9e857c22c48e133aa50b.bundle.js from UglifyJs
SyntaxError: Unexpected token: name (AppComponent) [D:/intelliJ/testcli/cli/~/angular2-template-loader!D:/intelliJ/testcli/cli/src/app/app.component.ts:8,0][main.9e857c22c48e133aa50b.bundle.js:38265,4]

Mention any other details that might be useful.


Thanks! We'll be in touch soon.

Most helpful comment

Any roadmap on making this an option? It appears that using "uglify-es" instead of "uglify-js" would make this possible - perhaps adding an option in the angular-cli config to use this version?

I don't know the larger ramifications of this proposed change - but it seems like a reasonable option.

All 9 comments

Uglifyjs (and by extension the CLI) currently doesn't support es6

Thanks for the info.

Is there any workaround? Any way to select another minifier?

So this means angular-cli is not compatible with es6 as a target?

@LanderBeeuwsaert At this point in time, yes.

Any roadmap on making this an option? It appears that using "uglify-es" instead of "uglify-js" would make this possible - perhaps adding an option in the angular-cli config to use this version?

I don't know the larger ramifications of this proposed change - but it seems like a reasonable option.

I have similar issue, but even with target="es5" (after using pify package that is es6)

Having the same issue here. I'm targeting es5, but UglifyJS errors when trying to create the vendor bundle. I'm importing a couple es6 files from my node_modules. It would be nice to either use Uglify-es or transpile files before sending them to Uglify-js without having to do an ng eject.

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