Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #417 missing module chunks #433

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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