Skip to content

Commit 259a1f4

Browse files
chore: replace deprecated webpack and babel plugins with modern alternatives (#2447)
* chore: add CONTRIBUTION_ROADMAP.md and update .gitignore * docs: update CONTRIBUTION_ROADMAP marking A2 as completed * docs: mark tasks B5 and A3 as completed in CONTRIBUTION_ROADMAP * chore: replace deprecated webpack and babel plugins with modern alternatives
1 parent f593294 commit 259a1f4

5 files changed

Lines changed: 542 additions & 365 deletions

File tree

CONTRIBUTION_ROADMAP.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ React (complete View)
152152

153153
---
154154

155-
#### A3 — Add test coverage with thresholds
155+
#### A3 — Add test coverage with thresholds - [COMPLETED ✔]
156156

157157
**Summary:** Configure minimum test coverage and mandatory thresholds, establishing a quality baseline.
158158

@@ -301,7 +301,7 @@ React (complete View)
301301

302302
---
303303

304-
#### B5 — Remove unnecessary polyfills and investigate node-polyfill-webpack-plugin
304+
#### B5 — Remove unnecessary polyfills and investigate node-polyfill-webpack-plugin - [COMPLETED ✔]
305305

306306
**Summary:** Remove unnecessary polyfills that increase bundle size without real benefit.
307307

client/.babelrc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
"@babel/preset-react"
1212
],
1313
"plugins": [
14-
"@babel/plugin-proposal-class-properties",
14+
"@babel/plugin-transform-class-properties",
1515
"@babel/plugin-syntax-dynamic-import",
1616
"@babel/plugin-transform-modules-commonjs",
17-
"@babel/plugin-proposal-private-methods",
18-
"@babel/plugin-proposal-private-property-in-object"
17+
"@babel/plugin-transform-private-methods",
18+
"@babel/plugin-transform-private-property-in-object"
1919
],
2020
"env": {
2121
"test": {
@@ -29,4 +29,4 @@
2929
]
3030
}
3131
}
32-
}
32+
}

client/package.json

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@
5555
"devDependencies": {
5656
"@babel/core": "^7.5.5",
5757
"@babel/eslint-parser": "^7.17.0",
58-
"@babel/plugin-proposal-class-properties": "^7.14.5",
59-
"@babel/plugin-proposal-private-methods": "^7.16.11",
60-
"@babel/plugin-proposal-private-property-in-object": "^7.16.7",
6158
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
59+
"@babel/plugin-transform-class-properties": "^7.28.6",
6260
"@babel/plugin-transform-modules-commonjs": "^7.5.0",
61+
"@babel/plugin-transform-private-methods": "^7.28.6",
62+
"@babel/plugin-transform-private-property-in-object": "^7.28.6",
6363
"@babel/plugin-transform-runtime": "^7.5.5",
6464
"@babel/preset-env": "^7.5.5",
6565
"@babel/preset-flow": "^7.14.5",
@@ -80,6 +80,7 @@
8080
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
8181
"compression-webpack-plugin": "^10.0.0",
8282
"css-loader": "^3.5.3",
83+
"css-minimizer-webpack-plugin": "^8.0.0",
8384
"eslint": "^7.6.0",
8485
"eslint-config-airbnb": "^18.0.1",
8586
"eslint-import-resolver-webpack": "^0.12.1",
@@ -90,16 +91,14 @@
9091
"eslint-plugin-jsx-a11y": "^6.2.3",
9192
"eslint-plugin-react": "^7.14.3",
9293
"eslint-plugin-react-hooks": "^5.0.0",
93-
"extract-css-chunks-webpack-plugin": "^4.9.0",
94-
"file-loader": "^6.0.0",
9594
"flow-bin": "^0.309.0",
9695
"flow-typed": "^3.8.0",
9796
"glob": "^8.0.3",
9897
"identity-obj-proxy": "^3.0.0",
9998
"jest": "^29.x",
10099
"jest-canvas-mock": "^2.4.0",
101100
"jest-environment-jsdom": "^29.x",
102-
"optimize-css-assets-webpack-plugin": "^6.0.1",
101+
"mini-css-extract-plugin": "^2.10.2",
103102
"prettier-eslint": "^11.0.0",
104103
"react-test-renderer": "^17.0.2",
105104
"sass": "^1.50.0",
@@ -108,7 +107,6 @@
108107
"stylelint-config-standard": "^20.0.0",
109108
"surge": "^0.23.1",
110109
"terser-webpack-plugin": "^5.3.6",
111-
"url-loader": "^4.0.0",
112110
"webpack": "^5.104.1",
113111
"webpack-cli": "^5.1.4",
114112
"webpack-manifest-plugin": "^5.0.0",
@@ -138,7 +136,7 @@
138136
"lcov"
139137
],
140138
"coverageDirectory": "coverage",
141-
"coverageThreshold": {
139+
"coverageThreshold": {
142140
"global": {
143141
"statements": 80,
144142
"branches": 70,

client/webpack.config.js

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
const glob = require('glob');
66
const { resolve } = require('path');
77
const CompressionPlugin = require('compression-webpack-plugin');
8-
const ExtractCssChunks = require('extract-css-chunks-webpack-plugin');
98
const { WebpackManifestPlugin } = require('webpack-manifest-plugin');
10-
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
9+
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
10+
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
1111
const webpackConfigLoader = require('react-on-rails/webpackConfigLoader');
1212
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin');
1313
const TerserPlugin = require('terser-webpack-plugin');
@@ -83,13 +83,7 @@ const config = {
8383
},
8484
},
8585
minimizer: devOrTestMode ? [] : [
86-
new OptimizeCssAssetsPlugin({
87-
cssProcessorOptions: {
88-
discardComments: {
89-
removeAll: true,
90-
},
91-
},
92-
}),
86+
new CssMinimizerPlugin(),
9387
new CompressionPlugin({
9488
filename: '[path][base].gz[query]',
9589
algorithm: 'gzip',
@@ -102,10 +96,9 @@ const config = {
10296
},
10397

10498
plugins: [
105-
new ExtractCssChunks({
99+
new MiniCssExtractPlugin({
106100
filename: `${outputFilename}.css`,
107101
chunkFilename: `${outputFilename}.chunk.css`,
108-
hot: !!devOrTestMode,
109102
}),
110103
new WebpackManifestPlugin({ publicPath: output.publicPath, writeToFileEmit: true }),
111104
// only load moment.js data for locales we support (see config/locale.rb)
@@ -124,7 +117,7 @@ const config = {
124117
test: /\.css$/,
125118
include: /node_modules/,
126119
use: [
127-
ExtractCssChunks.loader,
120+
MiniCssExtractPlugin.loader,
128121
{
129122
loader: 'css-loader',
130123
options: {
@@ -140,15 +133,15 @@ const config = {
140133
test: /\.css$/,
141134
exclude: /node_modules/,
142135
use: [
143-
ExtractCssChunks.loader,
136+
MiniCssExtractPlugin.loader,
144137
cssLoaderWithModules,
145138
],
146139
},
147140
{
148141
test: /\.(sass|scss)$/,
149142
include: /node_modules/,
150143
use: [
151-
ExtractCssChunks.loader,
144+
MiniCssExtractPlugin.loader,
152145
{
153146
loader: 'css-loader',
154147
options: {
@@ -165,7 +158,7 @@ const config = {
165158
test: /\.(sass|scss)$/,
166159
exclude: /node_modules/,
167160
use: [
168-
ExtractCssChunks.loader,
161+
MiniCssExtractPlugin.loader,
169162
cssLoaderWithModules,
170163
'sass-loader',
171164
],
@@ -176,27 +169,23 @@ const config = {
176169
},
177170
{
178171
test: /\.(png|jp(e*)g|svg|webp)$/,
179-
use: [
180-
{
181-
loader: 'url-loader',
182-
options: {
183-
limit: 8000,
184-
name: 'images/[contenthash]-[name].[ext]',
185-
},
172+
type: 'asset',
173+
parser: {
174+
dataUrlCondition: {
175+
maxSize: 8000,
186176
},
187-
],
177+
},
178+
generator: {
179+
filename: 'images/[contenthash]-[name][ext]',
180+
}
188181
},
189182
{
190183
test: /\.(eot|svg|ttf|woff|woff2)$/,
191184
include: /node_modules/,
192-
use: [
193-
{
194-
loader: 'file-loader',
195-
options: {
196-
name: 'fonts/[contenthash]-[name].[ext]',
197-
},
198-
},
199-
],
185+
type: 'asset/resource',
186+
generator: {
187+
filename: 'fonts/[contenthash]-[name][ext]',
188+
}
200189
},
201190
],
202191
},

0 commit comments

Comments
 (0)