Skip to content

Commit

Permalink
Fix Node.js 10 compatability
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Aug 2, 2023
1 parent c43302e commit 3032caa
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
5 changes: 5 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"lodash.debounce": "^4.0.8",
"lodash.escape": "^4.0.1",
"lodash.escaperegexp": "^4.1.2",
"lodash.flatten": "^4.4.0",
"lodash.invokemap": "^4.6.0",
"lodash.pullall": "^4.2.0",
"lodash.uniqby": "^4.7.0",
Expand Down
18 changes: 11 additions & 7 deletions src/analyzer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const path = require('path');
const pullAll = require('lodash.pullall');
const invokeMap = require('lodash.invokemap');
const uniqBy = require('lodash.uniqby');
const flatten = require('lodash.flatten');

const gzipSize = require('gzip-size');
const {parseChunked} = require('@discoveryjs/json-ext');
Expand Down Expand Up @@ -182,17 +183,20 @@ function readStatsFromFile(filename) {
}

function getChildAssetBundles(bundleStats, assetName) {
return (bundleStats.children || []).find((c) => Object.values(c.assetsByChunkName)
.flat()
.includes(assetName));
return flatten(
(bundleStats.children || [])
.find((c) => Object.values(c.assetsByChunkName))
)
.includes(assetName);
}

function getBundleModules(bundleStats) {
return uniqBy(
((bundleStats.chunks?.map(chunk => chunk.modules)) || [])
.concat(bundleStats.modules)
.filter(Boolean)
.flat(),
flatten(
((bundleStats.chunks?.map(chunk => chunk.modules)) || [])
.concat(bundleStats.modules)
.filter(Boolean)
),
'id'
).filter(m => !isRuntimeModule(m));
}
Expand Down

0 comments on commit 3032caa

Please sign in to comment.