-
-
Notifications
You must be signed in to change notification settings - Fork 488
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
Setting output.globalObject breaks parsed + gzip #288
Comments
Sorry, I don't quite follow you. Is the piece of code you are referring to some part of |
the config setting lines are setting the webpack config. This issue describes what happens to any bundle when the configuration is as such. |
I'm having a hard time figuring out what is exactly what's happening here. Can you create a small reproduction repository to show what's happening? I'm afraid I can't help you otherwise |
https://webpack.js.org/configuration/output/#outputglobalobject This is the webpack configuration. You can use with any project. Just set that to "(typeof self !== 'undefined' ? self : this)" and add bundle analyzer |
But why would you use |
Yes but the webpack configuration expects you to put a string in there, not an object, unless I misunderstand the instructions in https://webpack.js.org/configuration/output/#outputglobalobject documentation you linked? |
"(typeof self !== 'undefined' ? self : this)" is a string literal. In javascript this is signified by the quotation marks surrounding the other characters. |
But it won't be evaluated as JS unless you put it in backticks? It means your string will be exactly what you write, not either Was this what you have, or would need? config.output.globalObject = (typeof self !== 'undefined' ? 'self' : 'this') This code will not do any conditionals: config.output.globalObject = "(typeof self !== 'undefined' ? self : this)" The result will be only the raw string |
This string is inserted in the generated code as-is - it should not be evaluated at compile time. E.g. imagine this bundle template: var global = {{ config.globalObject }}; Then resulting bundle will be: var global = (typeof self !== 'undefined' ? self : this); |
Oh wow, that wasn't obvious at all from the webpack documentation. Thanks for explaining. |
Issue description
Breaks parsed + gzip sizes. Removing it fixed them.
Technical info
Expected Behavior
Gzip and parsed should contain data bout more than just the output files - the modules inside them as well.
Actual Behavior
Only stats includes all modules. Gzip and parsed just show large blocks for each bundle piece (output file)
Code
My default:
When I analyze:
The text was updated successfully, but these errors were encountered: