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

Fix missing child bundles throwing an error #378

Merged
merged 2 commits into from
Sep 17, 2020
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/analyzer.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,8 @@ function getViewerData(bundleStats, bundleDir, opts) {

const assets = _.transform(bundleStats.assets, (result, statAsset) => {
// If asset is a childAsset, then calculate appropriate bundle modules by looking through stats.children
const modules = statAsset.isChild ?
getBundleModules(getChildAssetBundles(bundleStats, statAsset.name)) :
getBundleModules(bundleStats);
const assetBundles = statAsset.isChild ? getChildAssetBundles(bundleStats, statAsset.name) : bundleStats;
const modules = assetBundles ? getBundleModules(assetBundles) : [];
const asset = result[statAsset.name] = _.pick(statAsset, 'size');

if (bundlesSources && _.has(bundlesSources, statAsset.name)) {
Expand Down
8 changes: 8 additions & 0 deletions test/analyzer.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ describe('Analyzer', function () {
});
});

it('should generate report when worker bundles have dynamic imports', async function () {
generateReportFrom('with-worker-loader-dynamic-import/stats.json');
const chartData = await getChartData();
expect(chartData[1]).to.containSubset({
label: '1.bundle.worker.js'
});
});

it('should support stats files with modules inside `chunks` array', async function () {
generateReportFrom('with-modules-in-chunks/stats.json');
const chartData = await getChartData();
Expand Down
1 change: 1 addition & 0 deletions test/stats/with-worker-loader-dynamic-import/1.bundle.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
self.webpackChunk([1],[,function(n,t,c){"use strict";c.r(t),c.d(t,"foo",(function(){return o}));const o=42}]);
1 change: 1 addition & 0 deletions test/stats/with-worker-loader-dynamic-import/bundle.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading