-
Notifications
You must be signed in to change notification settings - Fork 365
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
Webpack 5 upgrade #7351
base: main
Are you sure you want to change the base?
Webpack 5 upgrade #7351
Conversation
- Rewrite webpack aliased paths like ~terriajs-variables and ~terriajs-mixins to plain relative paths so that we can run the auto migrator. This was done using the following shell command: ``` find lib/ -name '*.scss' -exec bash -c 'sed -i "s|~terriajs-variables|$(realpath -s --relative-to=$(dirname "$1") lib/Sass/common/_variables)|" $1' bash {} \; ``` - Run auto migrator ``` find lib/ -name '*.scss' -exec npx sass-migrator module {} \; ```
Instead of using 'raw-loader!' etc in the import path, we now handle these import in webpack config. See webpack.config.make.js.
Removes use of 'raw-loader!' etc in import paths. Instead handle the imports in webpack config.
Webpack literally works only for 'process.env.NODE_ENV'.
"bottleneck": "^2.19.5", | ||
"catalog-converter": "^0.0.9", | ||
"classnames": "^2.3.1", | ||
"clipboard": "^2.0.8", | ||
"commander": "^11.1.0 ", | ||
"commander": "^12.1.0 ", |
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.
Commit 0a451d1 downgraded commander to 11.1.0 so it would work with node 16.
I'm not against bumping the engine version though, I would prefer to bump engines to node >= 20 so we could "easily" get rid of the security issues in terriajs-server as well while we're at 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.
Agree that we should bump the engine version, will look into it. In this case though commander is only used for a couple of CLI things and the CI hasn't tripped on it. So it should be fine i guess.
@@ -165,25 +161,22 @@ | |||
"react-virtual": "~2.3.2", | |||
"resolve-url-loader": "^5.0.0", | |||
"retry": "^0.12.0", | |||
"sass-loader": "^10", | |||
"sass-loader": "^16.0.3", |
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 fairly sure this also requires bumping the engine version.
I looked through this and besides the things I commented on, the things that are there looks good to me. Would love to get the (approved) CJS to ESM PR merged soon so this PR doesn't end up in limbo. |
"css-loader": "^2.1.0", | ||
"css-modules-typescript-loader": "^2.0.4", | ||
"css-loader": "^7.1.2", | ||
"terriajs-typings-for-css-modules-loader": "^2.5.2", |
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.
Non-alphabetical sorting, so this package will be shuffled down to the other terriajs-packages the next time someone runs yarn add
.
@na9da just noticed that the late revert of polyfill.js in CJS-to-ESM PR changed the |
const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin"); | ||
const ForkTsCheckerNotifierWebpackPlugin = require("fork-ts-checker-notifier-webpack-plugin"); | ||
const webpack = require("webpack"); | ||
|
||
function configureWebpack( | ||
/** |
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.
👍
Since this repository was just converted to ESM, should the other terriajs-repositories (that aren't forks of something else) also be converted to ESM? I had a look at terriajs-server and it seems quite easy, but I had to upgrade jasmine and yargs. |
Yep, i'll make those changes in this PR. I didn't want to create two successive breaking changes. |
What this PR does
Fixes #6998
Depends on TerriaJS/TerriaMap#718 and #7311
Upgrades webpack and other build dependencies to the latest version.
Note: bulk of the changes are from running the saas-migrator that upgrades
.scss
files to modern api.Changes summary
webpack, ...
plugin-proposal-class-properties
,proposal-object-rest-spread
,plugin-syntax-dynamic-import
. These must now be well supported by browsers.raw-loader
file-loader
url-loader
etc with builtin asset modulesraw-loader!file-loader
etc to make it more ESM compliant. Added extra config in webpack to correctly handle imports of static files (like csv and xml).hot
reload config. AFAICT this was not being used and required maintaining two different code paths in webpack configuration. If required we can add it back later after testing that it works.configureWebpack
parameters with a single options parameter.string-replace-webpack-plugin
as it was outdated and has a few vulnerabilities.sass-migrator
script)~terriajs-variables
and~terriajs-mixins
with respective relative path. This was necessary to run the migrator. Also it means simpler webpack config.css-modules-typescript-loader
that generates TS types for SASS modules is outdated and no longer works with webpack 5. I have made a repo from a fork of another similar package that can generate types. The other alternative would be to use this TS plugin - but not sure if it'll slow down compilation/editing.svg-sprite-loader
. It appears to be not maintained and has a bunch of audit warnings.I'll annotate the changes to make review easier.
Test me
Checklist
doc/
.