Skip to content

Commit

Permalink
feat: webpack plugin doesn't need all chunk info (#735)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
eliseumds committed May 8, 2021
1 parent 8f10896 commit cea9f24
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/webpack-plugin/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class LoadablePlugin {
const stats = compilation.getStats().toJson({
all: false,
assets: true,
chunks: true,
chunks: false,
chunkGroups: true,
chunkGroupChildren: true,
hash: true,
Expand All @@ -34,11 +34,12 @@ class LoadablePlugin {
stats.generator = 'loadable-components'

// we don't need all chunk information, only a type
stats.chunks = stats.chunks.map(chunk => ({
...chunk,
modules: [], // in case modules array is big
origins: [], // in case origins array is big
}))
stats.chunks = [...compilation.chunks].map((chunk) => {
return {
id: chunk.id,
files: [...chunk.files],
};
});

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

Expand Down

0 comments on commit cea9f24

Please sign in to comment.