-
-
Notifications
You must be signed in to change notification settings - Fork 153
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
chores(javascript): cleanup NPM and Webpack #2934
Conversation
When running `npm install`, a dependency resolution error for `webpack` comes up. `[email protected]` requires `[email protected]`, but the project requires `webpack@^5.76.0`. Resolve by uncritically updating the version of `webpack-cli` to match that of `webpack-dev-server`, `^4.10.0`. Make adjustments to `webpack.config.js` to work with this newer version (see `devServer.writeToDisk`).
Its use was removed in 1f60671. Prune it and its dependencies.
Webpack was upgraded to version 5 in 8256590, but has not been used to generate Javascript. Webpack 5 includes quite a few changes and, unfortunately, generates different compiled output. Notably, it strips and extracts license-like comments into a `LICENSE.txt` file. Handle this by using a `TerserPlugin` with a custom configuration (which is, evidently, the recommended approach). Another difference was was source-map generation. Seeing that existing files are essentially empty, remove source-maps for the time being. Sadly, nothing can be done about the different order of concatenation. Webpack 5 Release Notes: https://webpack.js.org/blog/2020-10-10-webpack-5-release/
This updates the transitive dependencies, `semver`, `word-wrap`, and `caniuse-lite`. None cause a change in the generated Javascript. This resolves the "3 moderate severity vulnerabilities" that npm would complain about and also the complaint about `Browserslist` from Webpack.
040e290
to
a00a4ce
Compare
@@ -1 +0,0 @@ | |||
{"version":3,"file":"vendor.js","sources":["webpack:///vendor.js"],"mappings":"AAAA;;;;;AA8ZA;AAyoCA;;;;AA8sKA;;;;;AAsvaA;;;;;;;AAy/FA;;;;;;;;AAkiRA;;;;;;;;AAmCA;;;;;;;;AAoTA;;;;;;;;AA28BA;;;;;;;;AA0YA;;;;;;;;AAg7DA;;;;;;;;AAkCA","sourceRoot":""} |
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’m not sure why sources
is only ["webpack:///vendor.js"]
(or how to generate this output). The good news is that it means this source map is essentially meaningless – and harmless to remove.
terserOptions: { | ||
compress: true, | ||
}, | ||
})], |
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 love this non-default plugin, but this is evidently how you preserve comments. Moving to LICENSE.txt
(the default imposed by Webpack 5) is something to consider, but, on balance, the added complication of this plugin is worth removing urgency of reconsidering our source attribution approach!
@@ -1 +0,0 @@ | |||
{"version":3,"file":"main.js","sources":["webpack:///main.js"],"mappings":"AAAA","sourceRoot":""} |
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.
cf. vendor.js.map
LGTM, thanks. |
Fixes issues:
webpack-cli
had preventednpm install
npm audit
reported several vulnerable packages