Skip to content

Commit cea9f24

Browse files
authored
feat: webpack plugin doesn't need all chunk info (#735)
I'm currently working on a pretty massive project with hundreds of split points, thousands of modules (plus node_modules), CSS, hot reloading, all the goodies... but *LoadablePlugin* was taking a very significant amount of time to run (about 1.2s). With these changes it went down to ~7ms.
1 parent 8f10896 commit cea9f24

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

packages/webpack-plugin/src/index.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class LoadablePlugin {
2222
const stats = compilation.getStats().toJson({
2323
all: false,
2424
assets: true,
25-
chunks: true,
25+
chunks: false,
2626
chunkGroups: true,
2727
chunkGroupChildren: true,
2828
hash: true,
@@ -34,11 +34,12 @@ class LoadablePlugin {
3434
stats.generator = 'loadable-components'
3535

3636
// we don't need all chunk information, only a type
37-
stats.chunks = stats.chunks.map(chunk => ({
38-
...chunk,
39-
modules: [], // in case modules array is big
40-
origins: [], // in case origins array is big
41-
}))
37+
stats.chunks = [...compilation.chunks].map((chunk) => {
38+
return {
39+
id: chunk.id,
40+
files: [...chunk.files],
41+
};
42+
});
4243

4344
const result = JSON.stringify(stats, null, 2)
4445

0 commit comments

Comments
 (0)