From 26c5499773427cf8884f242070b62a23a3651e94 Mon Sep 17 00:00:00 2001 From: Ian Date: Thu, 30 Nov 2023 08:20:00 -0500 Subject: [PATCH] (chore) Switch to using SwcMinifyWebpackPlugin --- packages/framework/esm-framework/package.json | 1 + packages/framework/esm-framework/webpack.config.js | 5 +++++ packages/framework/esm-styleguide/package.json | 1 + .../framework/esm-styleguide/webpack.config.js | 3 ++- packages/tooling/openmrs/package.json | 1 + packages/tooling/webpack-config/package.json | 1 + packages/tooling/webpack-config/src/index.ts | 5 ++++- yarn.lock | 14 ++++++++++++++ 8 files changed, 29 insertions(+), 2 deletions(-) diff --git a/packages/framework/esm-framework/package.json b/packages/framework/esm-framework/package.json index 4d16b26d0..7d738547e 100644 --- a/packages/framework/esm-framework/package.json +++ b/packages/framework/esm-framework/package.json @@ -66,6 +66,7 @@ "jest": "^29.7.0", "jest-cli": "^29.7.0", "jest-environment-jsdom": "^29.7.0", + "swc-minify-webpack-plugin": "^2.1.1", "webpack": "^5.88.0" } } diff --git a/packages/framework/esm-framework/webpack.config.js b/packages/framework/esm-framework/webpack.config.js index 5ec8a0a98..e5231b93d 100644 --- a/packages/framework/esm-framework/webpack.config.js +++ b/packages/framework/esm-framework/webpack.config.js @@ -3,6 +3,7 @@ const { resolve, basename } = require("path"); const { CleanWebpackPlugin } = require("clean-webpack-plugin"); const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer"); const { ModuleFederationPlugin } = require("webpack").container; +const { SwcMinifyWebpackPlugin } = require("swc-minify-webpack-plugin"); const { name, browser, main, peerDependencies } = require("./package.json"); @@ -18,6 +19,10 @@ module.exports = (env) => ({ library: { type: "system" }, }, devtool: "source-map", + optimization: { + minimize: true, + minimizer: [new SwcMinifyWebpackPlugin()], + }, module: { rules: [ { diff --git a/packages/framework/esm-styleguide/package.json b/packages/framework/esm-styleguide/package.json index 1e54052f9..230a6c78a 100644 --- a/packages/framework/esm-styleguide/package.json +++ b/packages/framework/esm-styleguide/package.json @@ -72,6 +72,7 @@ "react": "^18.1.0", "react-dom": "^18.1.0", "rxjs": "^6.5.3", + "swc-minify-webpack-plugin": "^2.1.1", "webpack": "^5.88.0" } } diff --git a/packages/framework/esm-styleguide/webpack.config.js b/packages/framework/esm-styleguide/webpack.config.js index 0faf2df35..7dd9c5e02 100644 --- a/packages/framework/esm-styleguide/webpack.config.js +++ b/packages/framework/esm-styleguide/webpack.config.js @@ -3,6 +3,7 @@ const CssMinimizerPlugin = require("css-minimizer-webpack-plugin"); const { resolve } = require("path"); const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer"); const { CleanWebpackPlugin } = require("clean-webpack-plugin"); +const { SwcMinifyWebpackPlugin } = require("swc-minify-webpack-plugin"); const { peerDependencies } = require("./package.json"); @@ -65,7 +66,7 @@ module.exports = (env) => ({ }, optimization: { minimize: true, - minimizer: [new CssMinimizerPlugin(), "..."], + minimizer: [new CssMinimizerPlugin(), new SwcMinifyWebpackPlugin()], }, plugins: [ new CleanWebpackPlugin(), diff --git a/packages/tooling/openmrs/package.json b/packages/tooling/openmrs/package.json index 9d2d1d3fe..39a3bb533 100644 --- a/packages/tooling/openmrs/package.json +++ b/packages/tooling/openmrs/package.json @@ -49,6 +49,7 @@ "postcss-loader": "^6.2.1", "rimraf": "^3.0.2", "swc-loader": "^0.2.3", + "swc-minify-webpack-plugin": "^2.1.1", "tar": "^6.0.5", "typescript": "^4.6.4", "webpack": "^5.88.0", diff --git a/packages/tooling/webpack-config/package.json b/packages/tooling/webpack-config/package.json index b46a43b99..95beb869f 100644 --- a/packages/tooling/webpack-config/package.json +++ b/packages/tooling/webpack-config/package.json @@ -41,6 +41,7 @@ "sass-loader": "^12.3.0", "style-loader": "^3.3.1", "swc-loader": "^0.2.3", + "swc-minify-webpack-plugin": "^2.1.1", "webpack": "^5.88.0", "webpack-bundle-analyzer": "^4.5.0", "webpack-stats-plugin": "^1.0.3" diff --git a/packages/tooling/webpack-config/src/index.ts b/packages/tooling/webpack-config/src/index.ts index 538f0b69c..04c864b1d 100644 --- a/packages/tooling/webpack-config/src/index.ts +++ b/packages/tooling/webpack-config/src/index.ts @@ -49,6 +49,7 @@ import { } from "webpack"; import { BundleAnalyzerPlugin } from "webpack-bundle-analyzer"; import { StatsWriterPlugin } from "webpack-stats-plugin"; +import { SwcMinifyWebpackPlugin } from "swc-minify-webpack-plugin"; // eslint-disable-next-line no-restricted-imports import { merge, mergeWith, isArray } from "lodash"; import { existsSync, statSync } from "fs"; @@ -274,7 +275,9 @@ export default ( maxAsyncRequests: 3, maxInitialRequests: 1, }, - }, + minimize: true, + minimizer: [new SwcMinifyWebpackPlugin()], + } as WebpackConfiguration["optimization"], optimizationConfig ), plugins: [ diff --git a/yarn.lock b/yarn.lock index b1d0935a1..82f52fecd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2916,6 +2916,7 @@ __metadata: jest: "npm:^29.7.0" jest-cli: "npm:^29.7.0" jest-environment-jsdom: "npm:^29.7.0" + swc-minify-webpack-plugin: "npm:^2.1.1" webpack: "npm:^5.88.0" peerDependencies: dayjs: 1.x @@ -3139,6 +3140,7 @@ __metadata: react: "npm:^18.1.0" react-dom: "npm:^18.1.0" rxjs: "npm:^6.5.3" + swc-minify-webpack-plugin: "npm:^2.1.1" webpack: "npm:^5.88.0" peerDependencies: "@openmrs/esm-extensions": 5.x @@ -3181,6 +3183,7 @@ __metadata: sass-loader: "npm:^12.3.0" style-loader: "npm:^3.3.1" swc-loader: "npm:^0.2.3" + swc-minify-webpack-plugin: "npm:^2.1.1" typescript: "npm:^4.6.4" webpack: "npm:^5.88.0" webpack-bundle-analyzer: "npm:^4.5.0" @@ -12963,6 +12966,7 @@ __metadata: postcss-loader: "npm:^6.2.1" rimraf: "npm:^3.0.2" swc-loader: "npm:^0.2.3" + swc-minify-webpack-plugin: "npm:^2.1.1" tar: "npm:^6.0.5" typescript: "npm:^4.6.4" webpack: "npm:^5.88.0" @@ -16020,6 +16024,16 @@ __metadata: languageName: node linkType: hard +"swc-minify-webpack-plugin@npm:^2.1.1": + version: 2.1.1 + resolution: "swc-minify-webpack-plugin@npm:2.1.1" + peerDependencies: + "@swc/core": ^1.0.0 + webpack: ^5.0.0 + checksum: 700b763bda9d77882b36600f14bf1859c9bd44a6953a7c0ae4ad4c21a924f2993427ca1d6c83a5dd502309d84009ead873d4033ac050718959f84a9e552df0b4 + languageName: node + linkType: hard + "swr@npm:^2.2.2": version: 2.2.2 resolution: "swr@npm:2.2.2"