-
Notifications
You must be signed in to change notification settings - Fork 60
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
children chunks are not able to access $jscomp polyfills because code is wrapped in IIFE wrapper #123
Comments
Child chunks are definitely not supposed to get polyfills. However this seems to point that your entry chunk isn't getting executed first. |
I created this long back. Not sure if the problem is present anymore. Entry chunk was getting executed, problem was code getting wrapped in outputWrapper causing $jscomp variable being local and not available to child chunks. Specifically following had worked. |
Can confirm that this is still there. Is there some config I am missing which can fix this? |
This is still exists with v2.5.0 and
Isn't the |
I'm also hitting this when there is an async function in a child chunk and out_language < 2017. With Closure in debug mode, the exception is: The definition for that jscomp function is in the entry chunk as (function(){ // Start of chunk outputWrapper
...
function $$jscomp$asyncExecutePromiseGeneratorFunction$$($generatorFunction$$) {
return $$jscomp$asyncExecutePromiseGenerator$$($generatorFunction$$());
}
...
).call(this || window) // End of chunk outputWrapper Because Closure isn't aware of this chunk outputWrapper, it's not aware that other chunks don't have access to The @ChadKillingsworth what was the original intent of this wrapper? Just to prevent polluting global scope? My only concern with dropping it is we also have |
Migrating from https://github.com/roman01la/webpack-closure-compiler to this plugin.
In standard mode output wrapper is hardcoded like this
outputWrapper: '(function(){%s}).call(this || window)',
Not sure how but this affects when there are dynamically loaded chunks are present. All polyfills are injected only in the main chunks and child chunks don't get the polyfills added to them. This causes $jscomp is not defined error in application.
I have already tried below compiler options without any success.
force_inject_library: 'es6_runtime'
isolation_mode: 'NONE'
I tried
outputWrapper: ''
in the code and that works because now code is not wrapped in IIFE anymore. $jscomp object created is available in the global scope and other chunks can see it.Since there is no way of sending outputWrapper from outside, how can we work around this. I think bug is somewhere else; because older plugin used to add polyfills in children chunks as well which is not happening with this plugin.
I can create reproducible small project over the weekend if needed.
The text was updated successfully, but these errors were encountered: