Skip to content

Commit

Permalink
feat: Support nested children
Browse files Browse the repository at this point in the history
  • Loading branch information
d4rkr00t committed Apr 19, 2018
1 parent 519cba3 commit 921a5b7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/analyze.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,12 @@ const postProcessModules = (modules, ignore, updateProgressBar) => {
};

function joinStats(children) {
const flattenChildren = (children, id = "0") =>
children.reduce((acc, child, index) => {
child.id = `${id}.${index}`;
acc = acc.concat(child);
acc = acc.concat(flattenChildren(child.children || [], child.id));
}, []);
return children.reduce(
(acc, child) => {
acc.chunks = child.chunks ? acc.chunks.concat(child.chunks) : acc.chunks;
Expand Down Expand Up @@ -331,6 +337,7 @@ module.exports = function analyze(
(!rawStats.chunks || !rawStats.chunks.length)
? joinStats(rawStats.children)
: rawStats;

const chunks = getChunksData(stats);
const rawModules = flattenChunks(stats);
const ignorePatterns = [].concat(DEFAULT_IGNORE).concat(ignore);
Expand Down

0 comments on commit 921a5b7

Please sign in to comment.