Skip to content

Commit

Permalink
Fixes #417 missing module chunks (#433)
Browse files Browse the repository at this point in the history
* Fixes #417 missing module chunks

* triger build

* test fix

* test fix
  • Loading branch information
deanshub committed Apr 13, 2021
1 parent 155edb7 commit e5b617e
Show file tree
Hide file tree
Showing 4 changed files with 521 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/analyzer.js
Expand Up @@ -190,7 +190,7 @@ function getBundleModules(bundleStats) {

function assetHasModule(statAsset, statModule) {
// Checking if this module is the part of asset chunks
return statModule.chunks.some(moduleChunk =>
return (statModule.chunks || []).some(moduleChunk =>
statAsset.chunks.includes(moduleChunk)
);
}
Expand Down
17 changes: 17 additions & 0 deletions test/analyzer.js
Expand Up @@ -131,6 +131,23 @@ describe('Analyzer', function () {
});
});

it('should gracefully process missing chunks', async function () {
generateReportFrom('with-missing-module-chunks/stats.json');
const chartData = await getChartData();
const invalidChunk = _.find(chartData, {label: 'invalid-chunk.js'});
expect(invalidChunk).to.exist;
expect(invalidChunk.statSize).to.equal(568);
forEachChartItem([invalidChunk], item => {
expect(typeof item.statSize).to.equal('number');
expect(item.parsedSize).to.be.undefined;
});
const validChunk = _.find(chartData, {label: 'valid-chunk.js'});
forEachChartItem([validChunk], item => {
expect(typeof item.statSize).to.equal('number');
expect(typeof item.parsedSize).to.equal('number');
});
});

it('should support stats files with js modules chunk', async function () {
generateReportFrom('with-modules-chunk.json');
await expectValidReport({bundleLabel: 'bundle.mjs'});
Expand Down

0 comments on commit e5b617e

Please sign in to comment.