Skip to content

Commit

Permalink
Chunk module submodules
Browse files Browse the repository at this point in the history
Also take into account that
chunk modules may have
submodules.

Fixes #8493
  • Loading branch information
caalador committed Jun 8, 2020
1 parent 82f466f commit aa4cecb
Showing 1 changed file with 31 additions and 15 deletions.
46 changes: 31 additions & 15 deletions flow-server/src/main/resources/webpack.generated.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,11 @@ function collectChunks(statsJson, acceptedChunks) {
const slimModule = {
id: module.id,
name: module.name,
source: module.source,
source: module.source
};
if(module.modules) {
slimModule.modules = collectSubModules(module);
}
modules.push(slimModule);
});
const slimChunk = {
Expand Down Expand Up @@ -251,27 +254,40 @@ function collectModules(statsJson, acceptedChunks) {
statsJson.modules.forEach(function (module) {
// Add module if module chunks contain an accepted chunk and the module is generated-flow-imports.js module
if (module.chunks.filter(key => acceptedChunks.includes(key)).length > 0
&& (module.name.includes("generated-flow-imports.js") || module.name.includes("generated-flow-imports-fallback.js"))) {
let subModules = [];
// Create sub modules only if they are available
if (module.modules) {
module.modules.forEach(function (module) {
const subModule = {
name: module.name,
source: module.source
};
subModules.push(subModule);
});
}
&& (module.name.includes("generated-flow-imports.js") || module.name.includes("generated-flow-imports-fallback.js"))) {
const slimModule = {
id: module.id,
name: module.name,
source: module.source,
modules: subModules
source: module.source
};
if(module.modules) {
slimModule.modules = collectSubModules(module);
}
modules.push(slimModule);
}
});
}
return modules;
}

/**
* Collect any modules under a module (aka. submodules);
*
* @param module module to get submodules for
*/
function collectSubModules(module) {
let modules = [];
module.modules.forEach(function (submodule) {
if (submodule.source) {
const slimModule = {
name: submodule.name,
source: submodule.source,
};
if(submodule.id) {
slimModule.id = submodule.id;
}
modules.push(slimModule);
}
});
return modules;
}

0 comments on commit aa4cecb

Please sign in to comment.