Skip to content
This repository has been archived by the owner on Dec 5, 2019. It is now read-only.

Turn off inlining in optimization until UglifyJS issue is fixed. #264

Closed
webpack-bot opened this issue Mar 19, 2018 · 23 comments · Fixed by #308
Closed

Turn off inlining in optimization until UglifyJS issue is fixed. #264

webpack-bot opened this issue Mar 19, 2018 · 23 comments · Fixed by #308

Comments

@webpack-bot
Copy link

This minimization bug has been open for almost two months: mishoo/UglifyJS#2842. It has been referenced here elsewhere. The bug occurs when UglifyJS attempts to inline a call to a function with a variable of the same name as a variable in the calling function. Symptoms usually include "is not defined" or "assignment to constant variable".

In my experience, it's both easy to fall into and extremely time-consuming to diagnose.

I'd suggest turning inline: false in Webpack 4 until this is fixed. From the comments, it looks like UglifyJS2 is suffering from a lack of contributors with the skills and bandwidth needed to deal with things like this.

All of the Webpack 4 blogging has been about "Just let us do it for you." IMHO, to fulfill the implied promise, I think you need to be reactive to component issues like this.

Related: optimization.minimize and optimization.minimizer (along with the rest of optimization) need documenting.

For this particular issue, I'm using:

{
optimization:
            minimizer: [
               
                new UglifyJsPlugin({
                    parallel: true,  // Webpack default
                    cache: true      // Webpack default
                    uglifyOptions: {
                        /*
                            inlining is broken sometimes where inlined function uses the same variable name as inlining function.
                            See https://github.com/mishoo/UglifyJS2/issues/2842, https://github.com/mishoo/UglifyJS2/issues/2843
                         */
                        compress: { inline:false },
                    },
                })
            ],
}


This issue was moved from webpack/webpack#6798 by @evilebottnawi. Original issue was by @estaub.

@alexander-akait
Copy link
Member

/cc @michael-ciniawsky what do you think about this?

@gil0mendes
Copy link

Today I ran over this issue, this would be nice to be fixed. Until then, disabling the minification is a good temporary workaround.

@jamesopti
Copy link

jamesopti commented Mar 19, 2018

All of the Webpack 4 blogging has been about "Just let us do it for you." IMHO, to fulfill the implied promise, I think you need to be reactive to component issues like this.

+100 Couldn't agree more.

@michael-ciniawsky
Copy link
Member

michael-ciniawsky commented Mar 20, 2018

@evilebottnawi We can disable inlining by default, there will likely be no other option in the near future 😞. This plugin will definitely become obsolete anyways if uglify won't actually be maintained for ES2015+ code

@alexander-akait
Copy link
Member

@michael-ciniawsky yep, let's do this, and we can improve babel-minify plugin for future 👍

@alexander-akait
Copy link
Member

alexander-akait commented Mar 20, 2018

@michael-ciniawsky i can migrate cache and parallel options very fast 😄

@Reinmar
Copy link

Reinmar commented Mar 22, 2018

We've run into this issue when trying to add support for building CKEditor 5 with webpack 4 (https://github.com/ckeditor/ckeditor5-dev/issues/371).

What I found is that uglify-es is not supported anymore (#262).

So, in the light of this, I'd say that disabling inlining misses the point. We may soon run into another issue with uglify-es and what's then? Will we be disabling next uglify's features?

@alexander-akait
Copy link
Member

@Reinmar we can:

  1. Migrate on uglify-js
  2. Disable some option by default, but uglify looks very buggy and in long/mid term it is not solve
  3. Migrate on babel-minify (looks it is time for this).

@Reinmar
Copy link

Reinmar commented Mar 23, 2018

I commented on that in #262. I know that the decision is hard, though...

@estaub
Copy link

estaub commented Mar 24, 2018

Turning off inlining by default doesn't preclude a better, longer-term solution.
By way of motivation... for other victims like me:

How long did it take you to figure out what's wrong?

I have no opinion on whether to move off uglify-es; it may make sense to stay there if there's some way to bring it back into a supported status. Regardless, identifying a different ongoing solution will take time, and switching to it may require, semver-wise, a major release.

(Probably) every day, poor slobs like us are losing hours of our lives chasing this down. Doesn't it make sense to put a bandaid on this now, and not make it contingent on identifying a long-term solution?

Note that there's already a babel-minify-webpack-plugin, which folks may want to kick the tires on. I haven't yet.

@alexander-akait
Copy link
Member

@estaub @Reinmar can you test this using this branch #296?

@rdsedmundo
Copy link

People, just an insight: I spent 15 hours (literally) trying to resolve a problem on my build, and I just realized that it could be Uglify after noticing that the build was working in mode: development but not on mode: production - so I was deactivating one option at a time from Uglify until I discovered that it was compress: { inline: true } being bugged.

This is critical. Builds of everyone that relies on Webpack v4 and use mode: production could break anytime - as it has happened to me suddenly after some code changes (it was fine before).

The error that happens is completely random, in my case, it was from React, saying: Uncaught TypeError: Super expression must either be null or a function, not undefined.

This either needs to be disabled here or even directly in Webpack source code while including the plugin in case of the mode: production. @sokra

@estaub
Copy link

estaub commented Jun 1, 2018

@rdsedmundo Can you help @evilebottnawi test? I'm stuck in back-end work.

@rdsedmundo
Copy link

Not sure what was supposed to be tested.

But I installed the uglifyjs-webpack-plugin dependency with the branch from that PR. It still doesn't work. If I provide the compress: { inline: false } though it works (nothing different then comparing to the normal version).

@alexander-akait
Copy link
Member

Should be solved after merge #296

@alexander-akait
Copy link
Member

Please who faced with problem test this branch, if all good please write about this here

@rdsedmundo
Copy link

Should be solved after merge #296

No, it isn't working.

@alexander-akait
Copy link
Member

@rdsedmundo can you create issue in https://github.com/fabiosantoscode/terser?

@Reinmar
Copy link

Reinmar commented Jun 4, 2018

@evilebottnawi, everything seems to work fine on our side (https://github.com/ckeditor/ckeditor5-dev/issues/371#issuecomment-394361235). Thanks!

@alexander-akait
Copy link
Member

👍 i think we can release new version in near future, btw feel free to feedback

@jri
Copy link

jri commented Jun 5, 2018

What does this fix actually do? Does uglifyjs-webpack-plugin now call UglifyJS2 with compress: { inline: false } by default, or is the underlying UglifyJS2 bug fixed?

@kzc
Copy link

kzc commented Jun 14, 2018

Bug workaround for yarn users:

https://github.com/fabiosantoscode/terser#replacing-uglify-es-with-terser-in-a-project-using-yarn

@Reinmar
Copy link

Reinmar commented Jun 14, 2018

👍 i think we can release new version in near future, btw feel free to feedback

When do you plan to release a new version?

ZauberNerd added a commit to untool/untool that referenced this issue Jun 28, 2018
Due to a bug in UglifyJS (mishoo/UglifyJS#2842)
we should disable function inlining to avoid falling into this issue.

the uglifyjs-webpack-plugin module is considering to move to the
maintained fork of UglifyJS (terser: https://github.com/fabiosantoscode/terser):
- webpack-contrib/uglifyjs-webpack-plugin#264
- webpack-contrib/uglifyjs-webpack-plugin#296

But until that happens I'd propose to disable function inlining.
ZauberNerd added a commit to untool/untool that referenced this issue Jun 28, 2018
Due to a bug in UglifyJS (mishoo/UglifyJS#2842)
we should disable function inlining to avoid falling into this issue.

the uglifyjs-webpack-plugin module is considering to move to the
maintained fork of UglifyJS (terser: https://github.com/fabiosantoscode/terser):
- webpack-contrib/uglifyjs-webpack-plugin#264
- webpack-contrib/uglifyjs-webpack-plugin#296

But until that happens I'd propose to disable function inlining.
dmbch pushed a commit to untool/untool that referenced this issue Jun 28, 2018
Due to a bug in UglifyJS (mishoo/UglifyJS#2842)
we should disable function inlining to avoid falling into this issue.

the uglifyjs-webpack-plugin module is considering to move to the
maintained fork of UglifyJS (terser: https://github.com/fabiosantoscode/terser):
- webpack-contrib/uglifyjs-webpack-plugin#264
- webpack-contrib/uglifyjs-webpack-plugin#296

But until that happens I'd propose to disable function inlining.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants