react-request icon indicating copy to clipboard operation
react-request copied to clipboard

UglifyJS fails to minify library files

Open illarionvk opened this issue 7 years ago • 5 comments

I enjoy using react-request in my project, thanks for creating it!

I decided to try the new version 3 today, but UglifyJS fails to minify it because of the let keywords in the CommonJS version of the library.

I think it happens because the babel-env plugin configuration is missing the targets section and newer language features are not transpiled.

I am going to amend my configuration to transpile the new react-request version, but it would be nice to have it transpiled out of the box. Moreover, the majority of bundler configuration docs and tutorials assume the code in node_modules is already transpiled to ES5.

uglifyjs-error uglifyjs-error-2

illarionvk avatar Apr 25 '18 10:04 illarionvk

I was wrong, the issue is not related to version 3 only because the let keyword was introduced in February commit.

Still, would you consider transpiling the library files to ES5?

illarionvk avatar Apr 25 '18 10:04 illarionvk

I've solved the issue for my project by importing react-request/dist/react-request.js which is already transpiled.

illarionvk avatar Apr 25 '18 11:04 illarionvk

Hi @illarionvk ! I’ll look into this. Sorry for the trouble!

Can you share more information about your build step? Are you using webpack? How are you running Uglify? What version of Uglify? And so on. Thanks!

jamesplease avatar Apr 25 '18 14:04 jamesplease

Hi @jamesplease! I'm using Browserify and UglifyJS 3. Uglify supports ES5 only.

Webpack users might experience the issue too because most configurations exclude the node_modules folder in babel-loader config.

The files from your /dist folder are transpiled to ES5 and work well for me.

illarionvk avatar May 08 '18 13:05 illarionvk

Thanks for providing more details @illarionvk . I agree that the other folders should also be transpiled down to ES5, but I am glad you found a workaround in the meantime.

jamesplease avatar May 08 '18 14:05 jamesplease