From 5418a1c7c2d89f40cb64626102a602b0e0211ebf Mon Sep 17 00:00:00 2001 From: Vio Date: Wed, 11 Oct 2023 18:16:41 +0200 Subject: [PATCH] fix(filter): Skip modules that do not belong to any chunk --- packages/plugin-webpack-filter/src/index.ts | 5 +++++ .../utils/__fixtures__/webpack-stats-1.extracted.js | 5 ----- .../jobs/__tests__/__snapshots__/create-job.ts.snap | 10 ---------- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/packages/plugin-webpack-filter/src/index.ts b/packages/plugin-webpack-filter/src/index.ts index df6da6612f..ae3800dfd1 100644 --- a/packages/plugin-webpack-filter/src/index.ts +++ b/packages/plugin-webpack-filter/src/index.ts @@ -101,6 +101,11 @@ export default ( (chunkId) => chunkId !== null && typeof chunkId !== 'undefined', ) || []; + // Skip modules that do not belong to any chunk + if (moduleChunks.length === 0) { + return agg; + } + const concatenatedModules = moduleStats.modules?.reduce( (aggConcatenatedModules, concatenatedModule) => { if (!concatenatedModule.name) { diff --git a/packages/utils/__fixtures__/webpack-stats-1.extracted.js b/packages/utils/__fixtures__/webpack-stats-1.extracted.js index 58bff9ee18..f599f76d7a 100644 --- a/packages/utils/__fixtures__/webpack-stats-1.extracted.js +++ b/packages/utils/__fixtures__/webpack-stats-1.extracted.js @@ -39,11 +39,6 @@ module.exports = { name: 'module-b', size: 2000, }, - { - chunks: [], - name: 'module-c', - size: 1000, - }, { chunks: [1], name: 'node_modules/package-a/index.js', diff --git a/packages/utils/src/jobs/__tests__/__snapshots__/create-job.ts.snap b/packages/utils/src/jobs/__tests__/__snapshots__/create-job.ts.snap index 48e7f499f6..08d147d1fd 100644 --- a/packages/utils/src/jobs/__tests__/__snapshots__/create-job.ts.snap +++ b/packages/utils/src/jobs/__tests__/__snapshots__/create-job.ts.snap @@ -277,11 +277,6 @@ exports[`createJob no baseline 1`] = ` "name": "module-b", "size": 2000, }, - { - "chunks": [], - "name": "module-c", - "size": 1000, - }, { "chunks": [ 1, @@ -656,11 +651,6 @@ exports[`createJob with baseline 1`] = ` "name": "module-b", "size": 2000, }, - { - "chunks": [], - "name": "module-c", - "size": 1000, - }, { "chunks": [ 1,