From cea9f249f7550a1154cf88bcfa3812ebb78a500f Mon Sep 17 00:00:00 2001 From: Eliseu Monar dos Santos Date: Fri, 7 May 2021 23:08:56 -0300 Subject: [PATCH] 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. --- packages/webpack-plugin/src/index.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/webpack-plugin/src/index.js b/packages/webpack-plugin/src/index.js index 6a48eadcc..3cba3467e 100644 --- a/packages/webpack-plugin/src/index.js +++ b/packages/webpack-plugin/src/index.js @@ -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, @@ -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)