You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Referencing dependencies from one chunk in another #369
I've got chunks split between head and body end, in some of the body end chunks it needs to reference things that were defined in the head chunk. If I require it in the body chunk, the dependency will end up in both head and body chunks. The only solution I can think of is having multiple compiler points and exporting the head dependencies and using them as externals in the body chunk, but I don't really want to do that. Is there a better way?
@sokra Hm, that doesn't seem to be working (webpack 1.3.2-beta1). Now I have the duplicated dependency in head.js and the body chunk (instead of body.js).
A little more details:
In "head" there is an amd module called "track-stub" which provides a simple API stub for tracking calls before the full API is implemented in body.
In body, there is an amd module called "track" which required "track-stub" so it can fill out the API.
This results in "track-stub" being defined in head (good) but it also gets duplicated in body (bad) because of the define call that lists it as a dependency.
@sokra Confirmed that it's working. Both of the modules are using the AMD web + global pattern, but since they are inside webpack bundles this is just an empty Object. Changing it to window fixed it :)
@sokra Now I have a similar issue when trying to reference dependencies in different bundles. For example, I have a "common/head" bundle and a "common/body" bundle which load common assets that go inside the <head> tag and at the end of the <body> tag, respectively. The solution above works fine for these two files (where "common/body" depends on something in "common/head") -- but now I'm getting duplication in my entry files, for example "page1" entry that depends on something defined in "common/body" -- is there an easy way to link these dependencies other than looping through all of the defined entry points and adding more CommonsChunkPlugin instances for them?
varplugins=[// Automatically split commonly used assets into the "common/body" bundle.newwebpack.optimize.CommonsChunkPlugin("common/body","[name].js",nonCommonEntryPoints),// Make sure dependencies that are loaded in "common/head" bundle// and depended on in "common/body" bundle don't get duplicated.newwebpack.optimize.CommonsChunkPlugin("common/head","[name].js",["common/body"],Infinity),];
Where nonCommonEntryPoints is an array of entry points without the common files included, like:
Activity
sokra commentedon Jul 21, 2014
You can do it this way:
kflorence commentedon Jul 21, 2014
@sokra Hm, that doesn't seem to be working (webpack 1.3.2-beta1). Now I have the duplicated dependency in head.js and the body chunk (instead of body.js).
A little more details:
This results in "track-stub" being defined in head (good) but it also gets duplicated in body (bad) because of the define call that lists it as a dependency.
Here is my full config:
sokra commentedon Jul 21, 2014
ups I got it wrong. It's
kflorence commentedon Jul 21, 2014
After updating to webpack 1.3.2-beta3 and changing my config to:
It seems to be working correctly. I will confirm shortly.
kflorence commentedon Jul 21, 2014
Haha, just figured that out as well :) BTW what does the
Infinitydo?kflorence commentedon Jul 21, 2014
@sokra Confirmed that it's working. Both of the modules are using the AMD web + global pattern, but since they are inside webpack bundles
thisis just an empty Object. Changing it towindowfixed it :)kflorence commentedon Aug 7, 2014
@sokra Now I have a similar issue when trying to reference dependencies in different bundles. For example, I have a "common/head" bundle and a "common/body" bundle which load common assets that go inside the
<head>tag and at the end of the<body>tag, respectively. The solution above works fine for these two files (where "common/body" depends on something in "common/head") -- but now I'm getting duplication in my entry files, for example "page1" entry that depends on something defined in "common/body" -- is there an easy way to link these dependencies other than looping through all of the defined entry points and adding more CommonsChunkPlugin instances for them?kflorence commentedon Aug 7, 2014
Also, I think this will be a fairly common case for users with multiple bundles where some of those bundles store common dependencies.
kflorence commentedon Aug 7, 2014
Basically I'm wanting to set up something like this: https://github.com/requirejs/example-multipage/blob/master/tools/build.js
sokra commentedon Aug 7, 2014
These r.js config maps to this webpack config:
kflorence commentedon Aug 8, 2014
@sokra I think I've got it figured out:
Where
nonCommonEntryPointsis an array of entry points without the common files included, like:Thanks for your help, as always.
test(css): hold every lowering to the whole computed style, not the p…
test(css): hold every lowering to the whole computed style, not the p…
test(css): hold every lowering to the whole computed style, not the p…
test(css): hold every lowering to the whole computed style, not the p…
perf(css): drop what a declaration, a slot or a query already says (#…