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

ng build --prod generates error if target is es6

Open ddorigo opened this issue 10 years ago • 9 comments

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.

ddorigo avatar Nov 18 '16 11:11 ddorigo

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

clydin avatar Nov 18 '16 12:11 clydin

Thanks for the info.

ddorigo avatar Nov 18 '16 14:11 ddorigo

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

rtm avatar Mar 28 '17 16:03 rtm

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

LanderBeeuwsaert avatar Apr 24 '17 12:04 LanderBeeuwsaert

@LanderBeeuwsaert At this point in time, yes.

clydin avatar Apr 24 '17 14:04 clydin

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.

brandon-objectstudio avatar May 10 '17 19:05 brandon-objectstudio

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

kirillgroshkov avatar Aug 10 '17 10:08 kirillgroshkov

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.

jscharett avatar Aug 25 '17 14:08 jscharett

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.