-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: normalize stats before analyzing
- Loading branch information
Showing
12 changed files
with
93 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* @flow */ | ||
|
||
/*:: | ||
import type { WebpackStats, NormalizedWebpackStats } from "./analyze"; | ||
*/ | ||
|
||
module.exports = function normalizeStats( | ||
stats /*: WebpackStats */ | ||
) /*: NormalizedWebpackStats */ { | ||
let modules = new Map(); | ||
let chunks = {}; | ||
|
||
(stats.chunks || []).forEach(chunk => { | ||
chunks[chunk.id] = { | ||
id: chunk.id, | ||
names: chunk.names, | ||
size: chunk.size | ||
}; | ||
|
||
(chunk.modules || []).forEach(m => { | ||
modules.set(m.id, m); | ||
}); | ||
}); | ||
|
||
(stats.modules || []).forEach(m => { | ||
modules.set(m.id, m); | ||
}); | ||
|
||
(stats.children || []).forEach(child => { | ||
let normalizedChild = normalizeStats(child); | ||
chunks = { ...chunks, ...normalizedChild.chunks }; | ||
normalizedChild.modules.forEach(m => { | ||
modules.set(m.id, m); | ||
}); | ||
}); | ||
|
||
return { modules: Array.from(modules.values()), chunks }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.