Skip to content

Commit e5b617e

Browse files
authored
Fixes #417 missing module chunks (#433)
* Fixes #417 missing module chunks * triger build * test fix * test fix
1 parent 155edb7 commit e5b617e

File tree

4 files changed

+521
-1
lines changed

4 files changed

+521
-1
lines changed

src/analyzer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ function getBundleModules(bundleStats) {
190190

191191
function assetHasModule(statAsset, statModule) {
192192
// Checking if this module is the part of asset chunks
193-
return statModule.chunks.some(moduleChunk =>
193+
return (statModule.chunks || []).some(moduleChunk =>
194194
statAsset.chunks.includes(moduleChunk)
195195
);
196196
}

test/analyzer.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,23 @@ describe('Analyzer', function () {
131131
});
132132
});
133133

134+
it('should gracefully process missing chunks', async function () {
135+
generateReportFrom('with-missing-module-chunks/stats.json');
136+
const chartData = await getChartData();
137+
const invalidChunk = _.find(chartData, {label: 'invalid-chunk.js'});
138+
expect(invalidChunk).to.exist;
139+
expect(invalidChunk.statSize).to.equal(568);
140+
forEachChartItem([invalidChunk], item => {
141+
expect(typeof item.statSize).to.equal('number');
142+
expect(item.parsedSize).to.be.undefined;
143+
});
144+
const validChunk = _.find(chartData, {label: 'valid-chunk.js'});
145+
forEachChartItem([validChunk], item => {
146+
expect(typeof item.statSize).to.equal('number');
147+
expect(typeof item.parsedSize).to.equal('number');
148+
});
149+
});
150+
134151
it('should support stats files with js modules chunk', async function () {
135152
generateReportFrom('with-modules-chunk.json');
136153
await expectValidReport({bundleLabel: 'bundle.mjs'});

0 commit comments

Comments
 (0)