Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"unused" option in uglifyjs webpack prod config behaves unexpectedly #5044

Closed
jslegers opened this issue Sep 20, 2018 · 3 comments
Closed

"unused" option in uglifyjs webpack prod config behaves unexpectedly #5044

jslegers opened this issue Sep 20, 2018 · 3 comments

Comments

@jslegers
Copy link

Is this a bug report?

Yes

Steps to Reproduce

  1. Install app
  2. run dev server
  3. build app
  4. run build

Expected Behavior

Both the dev code & the built code should behave the same.

Actual Behavior

Some of the built code behaved incorrectly.

More specifically, some WebGL code generated with Emscripten did not behave as expected in the built code.

In my app, I expected to see this :
Image of Yaktocat

Instead, I saw this :
Image of Yaktocat

Setting the "unused" flag to "false" fixes this problem.

Demo

A demo app can be found at https://github.com/jslegers/luciadria-react-app.

Unfortunately, this demo requires LuciadRIA as a local dependency, and unfortunately I'm not allowed to share this code as it is proprietary. However, it should give an idea of what I'm trying to achieve.

Considering the behavior of the "unused" flag is unreliable, it makes sense to set it's default value to "false", like the "comparisons" flag.

@gaearon
Copy link
Contributor

gaearon commented Sep 20, 2018

Would it be more appropriate to file this with Uglify?

@jslegers
Copy link
Author

jslegers commented Sep 20, 2018

@Gaeron :

I can't really tell which of the underlying components is responsible. Is it webpack-contrib/uglifyjs-webpack-plugin? Or maybe mishoo/UglifyJS2? I'm not sure how to tell.

I can, however, tell that setting the unused flag in the webpack.config.prod.js config file of facebook/create-react-app fixes the issue.

And considering setting the unused flag to true can actually break an app and this behavior is unpredictable, it seems reasonable to me to set the default to false for a boilerplate project like facebook/create-react-app, as is already the case for the comparisons flag (see #2376).

You don't agree?

@stale
Copy link

stale bot commented Nov 2, 2018

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 7 days if no further activity occurs.

@stale stale bot added the stale label Nov 2, 2018
@Timer Timer closed this as completed Nov 2, 2018
@lock lock bot locked and limited conversation to collaborators Jan 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants