Shared CSS bundle configuration
m-mujica opened this issue · comments
The current logic to write out the sharedBundles
object of the slim loader (used to map bundle ids to an array of shared bundles that need to be loaded first), assumes that only javascript bundles are split by steal-tools.
steal-tools/lib/node/make_slim_config_node.js
Lines 79 to 103 in 3fe582c
It seems to me that the bundle data structure in insufficient to tell the buildType of the shared bundle, consider the following example taken from bitballs.
If you loop over the bundles steal-tools creates, you will find bundles/details-details-details
which is a bundle of the most shared modules between
"bitballs@0.4.1#components/game/details/details"
"bitballs@0.4.1#components/player/details/details"
"bitballs@0.4.1#components/tournament/details/details"
The slim loader needs to know on runtime that in order to load any of the bundles listed above, it has to load bundles/details-details-details
first.
The problem is, taking the first name of the previous list:
"bitballs@0.4.1#components/game/details/details"
how can we tell what's the uniqueId
of that bundle? I can loop over all of the bundles and find the one that has it as its only bundle.bundles
.
But if you look at the data below, there are two bundles that meet the criteria, a css and a javascript bundle. In this case the bundle to match is the javascript bundle and steal-tools currently filters out all css bundles when finding the uniqueId
.
But this might cause problems for css shared bundles, we might need to decorate the bundles
object with more info to accurately know what bundle the name in bundle.bundles
refers to.
// bundles/details-details-details
{
"size": 14155,
"bundles": [
"bitballs@0.4.1#components/game/details/details",
"bitballs@0.4.1#components/player/details/details",
"bitballs@0.4.1#components/tournament/details/details"
],
nodes: [...]
"buildType": "js",
"name": "bundles/details-details-details",
"hash": "31f336bd3f35b1ea7be8be6c47c416ff",
"isDirty": true,
"uniqueId": 293
}
// bundles/bitballs/components/game/details/details.css!
{
"size": 2016,
"bundles": [
"bitballs@0.4.1#components/game/details/details"
],
nodes: [...]
"buildType": "css",
"name": "bundles/bitballs/components/game/details/details.css!",
"hash": "c8162ac088d16e46c9641ce3f3b986f9",
"isDirty": true,
"pluginName": "done-css@3.0.1#css",
"uniqueId": 296
}
// bundles/bitballs/components/game/details/details
{
"size": 90723,
"bundles": [
"bitballs@0.4.1#components/game/details/details"
],
"buildType": "js",
"name": "bundles/bitballs/components/game/details/details",
"hash": "0daf99771371f794598f7669703560fe",
"isDirty": true,
"uniqueId": 295
}