Skip to content

Commit 2131fe6

Browse files
committed
style: fix all linting issues
1 parent ed1eebe commit 2131fe6

1 file changed

Lines changed: 25 additions & 22 deletions

File tree

src/analyzer.js

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,25 @@ function getViewerData(bundleStats, bundleDir, opts) {
2626

2727
const isAssetIncluded = createAssetsFilter(excludeAssets);
2828

29-
// Handle minimal stats format that only has assetsByChunkName but no assets array
30-
if ((bundleStats.assets == null || bundleStats.assets.length === 0) && bundleStats.assetsByChunkName) {
31-
// Convert assetsByChunkName to assets array for minimal stats
32-
bundleStats.assets = [];
33-
Object.entries(bundleStats.assetsByChunkName).forEach(([chunkName, assetNames]) => {
34-
assetNames.forEach(assetName => {
35-
bundleStats.assets.push({
36-
name: assetName,
37-
chunks: [chunkName],
38-
size: 0 // Default size for minimal stats
29+
// Handle minimal stats format that only has assetsByChunkName but no assets array
30+
if ((bundleStats.assets == null || bundleStats.assets.length === 0) && bundleStats.assetsByChunkName) {
31+
// Convert assetsByChunkName to assets array for minimal stats
32+
bundleStats.assets = [];
33+
Object.entries(bundleStats.assetsByChunkName).forEach(([chunkName, assetNames]) => {
34+
assetNames.forEach(assetName => {
35+
bundleStats.assets.push({
36+
name: assetName,
37+
chunks: [chunkName],
38+
// Default size for minimal stats
39+
size: 0
40+
});
3941
});
4042
});
41-
});
42-
}
43+
}
4344

44-
// Sometimes all the information is located in `children` array (e.g. problem in #10)
45-
if ((bundleStats.assets == null || bundleStats.assets.length === 0) && bundleStats.children && bundleStats.children.length > 0) {
45+
// Sometimes all the information is located in `children` array (e.g. problem in #10)
46+
if ((bundleStats.assets == null || bundleStats.assets.length === 0) &&
47+
bundleStats.children && bundleStats.children.length > 0) {
4648
const {children} = bundleStats;
4749
bundleStats = bundleStats.children[0];
4850
// Sometimes if there are additional child chunks produced add them as child assets,
@@ -118,7 +120,8 @@ if ((bundleStats.assets == null || bundleStats.assets.length === 0) && bundleSta
118120
const asset = result[statAsset.name] = {
119121
size: statAsset.size
120122
};
121-
const assetSources = bundlesSources && Object.prototype.hasOwnProperty.call(bundlesSources, statAsset.name) ?
123+
const assetSources = bundlesSources &&
124+
Object.prototype.hasOwnProperty.call(bundlesSources, statAsset.name) ?
122125
bundlesSources[statAsset.name] : null;
123126

124127
if (assetSources) {
@@ -165,7 +168,7 @@ if ((bundleStats.assets == null || bundleStats.assets.length === 0) && bundleSta
165168
}
166169

167170
asset.modules = assetModules;
168-
asset.tree = createModulesTree(asset.modules, {compressionAlgorithm});
171+
asset.tree = createModulesTree(asset.modules, {compressionAlgorithm});
169172
return result;
170173
}, {});
171174

@@ -205,16 +208,16 @@ function getBundleModules(bundleStats) {
205208
if (!bundleStats) {
206209
return [];
207210
}
208-
211+
209212
const seenIds = new Set();
210-
213+
211214
// Safely handle chunks and modules that might be undefined
212-
const chunksModules = bundleStats.chunks ?
213-
bundleStats.chunks.map(chunk => chunk.modules || []) :
215+
const chunksModules = bundleStats.chunks ?
216+
bundleStats.chunks.map(chunk => chunk.modules || []) :
214217
[];
215-
218+
216219
const statsModules = bundleStats.modules || [];
217-
220+
218221
return flatten(chunksModules.concat(statsModules).filter(Boolean)).filter(mod => {
219222
// Filtering out Webpack's runtime modules as they don't have ids and can't be parsed (introduced in Webpack 5)
220223
if (isRuntimeModule(mod)) {

0 commit comments

Comments
 (0)