-
-
Notifications
You must be signed in to change notification settings - Fork 488
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
feat: add support to analyze gzipped bundles #379
base: master
Are you sure you want to change the base?
Conversation
README.md
Outdated
@@ -68,6 +68,7 @@ new BundleAnalyzerPlugin(options?: object) | |||
|**`statsOptions`**|`null` or `{Object}`|Default: `null`. Options for `stats.toJson()` method. For example you can exclude sources of your modules from stats file with `source: false` option. [See more options here](https://webpack.js.org/configuration/stats/). | | |||
|**`excludeAssets`**|`{null\|pattern\|pattern[]}` where `pattern` equals to `{String\|RegExp\|function}`|Default: `null`. Patterns that will be used to match against asset names to exclude them from the report. If pattern is a string it will be converted to RegExp via `new RegExp(str)`. If pattern is a function it should have the following signature `(assetName: string) => boolean` and should return `true` to *exclude* matching asset. If multiple patterns are provided asset should match at least one of them to be excluded. | | |||
|**`logLevel`**|One of: `info`, `warn`, `error`, `silent`|Default: `info`. Used to control how much details the plugin outputs.| | |||
|**`decompressExtenstion`**|`null` or `{Object}`|Default: `null`. Used to show stats for a compressed file, object has compressed file's extension as key and it's value is decompression algorithm of [zlib](https://nodejs.org/api/zlib.html) to use, like: `{ gz: { algorithm: 'unzipSync' } }`| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need this option - decompression should be transparent to the end-user. It should just work without any configuration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I too agree on this, but then should it be basis extension itself, i.e. detect for gz
/br
and apply respective decompression?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@th0r does the above comment look good?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so. We can think about customizable extensions if someone will raise an issue about it.
test/parseUtils.js
Outdated
@@ -16,7 +21,7 @@ describe('parseBundle', function () { | |||
.forEach(bundleName => { | |||
it(`should parse ${_.lowerCase(bundleName)}`, function () { | |||
const bundleFile = `${BUNDLES_DIR}/${bundleName}.js`; | |||
const bundle = parseBundle(bundleFile); | |||
const bundle = parseBundle(bundleFile, {}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Options parameter should be optional.
test/parseUtils.js
Outdated
const bundleFile = `${BUNDLES_DIR}/validBundleWithArrowFunction.js`; | ||
const compressedBundleFile = `${bundleFile}.${extension}`; | ||
const expectedModules = JSON.parse(fs.readFileSync(`${BUNDLES_DIR}/validBundleWithArrowFunction.modules.json`)); | ||
if (!zlib[algorithm]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need this condition - it swallows valid error and we won't notice it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For brotli, node version needs to be >= v11.7.0. Thus I put it to pass ci-checks which run on node 8. How do you suggest handling it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For brotli, node version needs to be >= v11.7.0
We need to mention it in the docs and properly handle in the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you suggest handling it?
Check in tests, whether current version of Node supports it and expect successful decoding in one case and throwing of expected error in the other.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to mention it in the docs and properly handle in the code.
Brotli compression works for version >= v11.7.0, so it is kind of an already set expectation for brotli assets. Would you prefer it including in docs anyway?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Maybe compression is done with some external tool instead of Node.js.
Feature request: #377
This would add functionality to generate stats for
.gz
and.br
, i.e. compressed assets.