Skip to content
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

Upgrade webpack from v4 to v5 #734

Merged
merged 6 commits into from
Oct 24, 2024
Merged

Upgrade webpack from v4 to v5 #734

merged 6 commits into from
Oct 24, 2024

Conversation

pradeepnschrodinger
Copy link
Collaborator

@pradeepnschrodinger pradeepnschrodinger commented Oct 8, 2024

Primary: @AmanGupta2708 or @karry08
JIRA: https://schrodinger.atlassian.net/browse/LDTOOLS-233

Description

This upgrades webpack from v4 to v5.
I followed webpack's docs for the migration.

Motivation and Context

Fixes #730.

How Has This Been Tested?

Tested with local examples.
TODO: Test on sandbox.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.

dependabot bot and others added 3 commits August 29, 2024 08:31
Bumps [webpack](https://github.com/webpack/webpack) from 4.46.0 to 5.94.0.
- [Release notes](https://github.com/webpack/webpack/releases)
- [Commits](webpack/webpack@v4.46.0...v5.94.0)

---
updated-dependencies:
- dependency-name: webpack
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <[email protected]>
@wiz-inc-87ff8274df
Copy link

wiz-inc-87ff8274df bot commented Oct 8, 2024

Wiz Scan Summary

Scan Module Critical High Medium Low Info Total
Vulnerabilities 0 5 3 0 0 8
Secrets 0 0 0 0 0 0
Total 0 5 3 0 0 8

View scan details in Wiz

To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension.

@pradeepnschrodinger pradeepnschrodinger added the dependencies Pull requests that update a dependency file label Oct 8, 2024
@@ -43,13 +43,11 @@
"babel-loader": "^8.2.2",
"babel-plugin-rewire": "1.2.0",
"babel-plugin-syntax-trailing-function-commas": "^6.8.0",
"bundle-loader": "0.5.6",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused

"css-loader": "^5.2.7",
"eslint": "7",
"eslint-config-prettier": "6.10.0",
"except": "^0.1.3",
"faker": "^5.5.3",
"file-loader": "4.2.0",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

file-loader is deprecated. Webpack recommends to use asset modules instead.
See https://v4.webpack.js.org/loaders/file-loader/

@@ -77,8 +75,7 @@
"rollup-plugin-terser": "^7.0.2",
"style-loader": "1.0.0",
"terser-webpack-plugin": "4.2.3",
"url-loader": "2.1.0",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

url-loader is also deprecated in favor of asset modules.

@@ -14,7 +15,7 @@ module.exports = {

output: {
path: path.resolve(__dirname, '../__site__/'),
filename: isDev ? '[name].js' : '[name]-[hash].js',
filename: isDev ? '[name].js' : '[name]-[contentHash].js',
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Webpack recommends using contentHash instead of hash.

When using [hash] placeholder in webpack configuration, consider changing it to [contenthash]. It is not the same, but proven to be more effective.

@@ -24,10 +25,15 @@ module.exports = {
rules: [
{
test: /\.md$/,
loader: [
'html-loader?{"minimize":false}',
use: [
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Older syntax no longer supported in webpack v5

@@ -74,6 +82,9 @@ module.exports = {
'fixed-data-table-2/css': path.join(__dirname, '../src/css'),
'fixed-data-table-2': path.join(__dirname, '../src/index'),
},
fallback: {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The core node url package is no longer included by webpack by default.
But it doesn't look like we need them, so I'm setting resolve.fallback.url to false.

@@ -12,7 +13,9 @@ module.exports = {
output: {
path: path.resolve(__dirname, '../__site_prerender__/'),
filename: 'renderPath.js',
libraryTarget: 'commonjs2',
library: {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

output.libraryTarget changed to output.library.type

@karry08
Copy link
Collaborator

karry08 commented Oct 22, 2024

lgtm

@pradeepnschrodinger pradeepnschrodinger merged commit 55c53f6 into master Oct 24, 2024
10 checks passed
@pradeepnschrodinger pradeepnschrodinger deleted the UpgradeWebpackv5 branch October 24, 2024 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants