Upgrade to webpack 5
Background
We are currently using webpack 4, but webpack 5 was recently released. We don't directly depend on webpack but use webpack-stream
(for integration with Gulp) which still depends on webpack 4, but it supports passing in an arbitrary version of webpack.
There is an incentive to get on webpack 5 in order to leverage upcoming features (e.g. named imports from CommonJS in strict ESM mode, and top-level await
).
What to change
- Add a dependency to latest webpack (
npm install --save-dev webpack
). - Import
webpack
and pass it towebpack-stream
. - Adapt for breaking changes in webpack 5.
- webpack 5 picks up
"type": "module"
frompackage.json
and as a result all.js
files will be parsed asjavascript/esm
which may or may not require changes adapting for stricter ESM semantics.- Also this means that we can now remove the dummy exports (i.e.
export default void 0
) which have been added so that webpack recognized those modules as ESM when parsed asjavascript/auto
.
- Also this means that we can now remove the dummy exports (i.e.
- webpack 5 no longer provides polyfills for built-in Node.js modules by default. That breaks
import assert from "assert"
in the unit tests. - The
devtool
setting is validated more strictly (e.g.source-maps
has to be changed tosource-map
).
- webpack 5 picks up