insin / nwb

A toolkit for React, Preact, Inferno & vanilla JS apps, React libraries and other npm modules for the web, with no configuration (until you need it)
Other
5.57k stars 331 forks source link

UglifyJs encounters SyntaxError #160

Closed brumm closed 8 years ago

brumm commented 8 years ago

Hey @insin,

I'm running into an error when trying to build an app which imports https://github.com/Cu3PO42/electron-ipc-tunnel:

SyntaxError: Unexpected token: name (IpcClient) [./~/electron-ipc-tunnel/client.js:11,0]
electron/ doesn't exist

nwb serve is working without problems, only nwb build fails :(

test repo with minimal nwb react-app which reproduces the issue is here: https://github.com/brumm/test

Env:

Darwin 15.6.0
node v5.3.0
npm  v3.3.12
insin commented 8 years ago

It looks like this module has published untranspiled ES6 to npm, which as far as I'm aware isn't supported by UglifyJS yet.

Not that it seems to make a difference in this case, but is the extra target config value valid?

brumm commented 8 years ago

Dang, I should probably have spotted this myself. Thanks for pointing me in the right direction!

Not that it seems to make a difference in this case, but is the extra target config value valid?

Yeah, it's just not documented (yet?) https://github.com/webpack/webpack/blob/314c897682b556845fea36d329de8016d1740900/lib/WebpackOptionsApply.js#L154

insin commented 8 years ago

Do people generally compress code for Electon apps? It should be possible to disable use of uglify if Node >= v4 is the target anyway.

brumm commented 8 years ago

Awesome! I tried to do this via the individual options mangle: false and compress: false but that didn't work.

cedricdelpoux commented 7 years ago

I have also a problem with this UglifyJS version with the react-element-to-jsx-string lib. See here

@insin There is an es6 version of UglifyJS2 on the harmony branch.

Could you consider use it?