-
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
Goog.Module: multiple entry points don't work properly #52
Comments
The difficulty here is you are attempting to both code split and directly reference. This probably should have been an error. |
@ChadKillingsworth well, I think this is more or less a common use-case. |
This is a deficiency in the goog.module pattern. To my knowledge, there isn't a dynamic loading function similar to The clue here was that you used an entry point to force splitting code. You should not really do that. It will duplicate the polyfills and cause the issues you noticed. You can use |
In my use-case I don't load resulting modules dynamically via js. I load them via static
Why? I had an impression that Otherwise I see no other way to tell the plugin how I'd like to split my result build. My current build process is based on plovr and its Do you think it's achievable in a current version of the plugin, or there's no way to make it work the way I want at the moment? |
It's possible to handle this. However I'm also going to be investigating the possibility of a loader that converts goog modules into standard CommonJS. |
Any news about this? I think I have the same problem. My config is quite similar to the example referenced above, except for the entry section:
I use
Any hints where this might go wrong in the plugin's code? |
The issue is that there exists a set of goog.modules that are shared between 2 different entry points. Those need split off into a common chunk. To do that with webpack, you need to have a dynamic loading statement that allows webpack to split the common files out into a unique chunk. With ES Modules you would do something like: ./module1.js import('./common.js').then(commonExports => {
console.log(commonExports.default);
}); Webpack would automatically code split at this point and create separate JS modules. For goog modules, the plugin would have to be updated to recognize this type of late loading behavior as well. You could try something like: ./module1.js goog.forwardDeclare('common');
import('./common.js').then(commonExports => {
console.log(common.foo);
}); I'm not sure that will work, but that's the best option I have. |
@ChadKillingsworth Thanks for your response! This unfortunately does not seem to work ATM. I created a minimal example project here that reproduces the crash: DreierF#1
|
Hi guys,
I have an issue with a multi-module build (I'm talking about output modules here related to code splitting and
--module
flag).Here's my webpack config:
module1.js:
module2.js:
Here's the output generated into
module2.build.js
:The problem is the inner function is never called.
When both
module1.build.js
andmodule2.build.js
are linked to the page, I only seemodule1
string in the console output.There's no
module2
string.This behaviour is reproducible for any number of modules more than 1 and any
compilation_level
.On the other hand, if I comment out
ClosurePlugin
in the config, both modules run when loaded.Here's
module2.build.js
in this case:For this one I see both
module1
andmodule2
strings in the console output.This example covers only a case with 1 output module.
I feel like it's not an intended behaviour, that's why opened this issue.
I have node v8.9.4 on OSX 10.12.6.
The text was updated successfully, but these errors were encountered: