diff --git a/clean.js b/clean.js index 2e50f6e8..60d4aa04 100644 --- a/clean.js +++ b/clean.js @@ -47,6 +47,9 @@ async function removeBuildArtifacts() { tasks.push( tryRemove(path.join(basePath, packageName, "dist")) ); + tasks.push( + tryRemove(path.join(basePath, packageName, "node_modules", ".cache")) + ); } } diff --git a/packages/controller/package.json b/packages/controller/package.json index 1868a960..6de37ec3 100644 --- a/packages/controller/package.json +++ b/packages/controller/package.json @@ -6,7 +6,7 @@ "version": "2.0.0-alpha.21", "main": "dist/node/index.js", "scripts": { - "prepare": "tsc --build && webpack-cli --env production", + "prepare": "tsc --build && webpack-cli --mode production", "test": "echo \"Error: no test specified\" && exit 1" }, "bin": { @@ -37,7 +37,7 @@ }, "devDependencies": { "@clusterio/web_ui": "workspace:*", - "@swc/core": "^1.11.1", + "@swc/core": "^1.13.3", "@types/busboy": "^1.5.0", "@types/compression": "^1.7.2", "@types/express": "^4.17.17", diff --git a/packages/controller/src/Controller.ts b/packages/controller/src/Controller.ts index b1ba92e2..5d2b8f07 100644 --- a/packages/controller/src/Controller.ts +++ b/packages/controller/src/Controller.ts @@ -405,7 +405,6 @@ export default class Controller { const webpackConfigs = []; if (args.dev) { - webpackConfigs.push(require("../../../webpack.config")({})); // Path outside of build } if (args.devPlugin) { diff --git a/packages/controller/webpack.config.js b/packages/controller/webpack.config.js index 25182879..44b06acb 100644 --- a/packages/controller/webpack.config.js +++ b/packages/controller/webpack.config.js @@ -5,7 +5,7 @@ const { merge } = require("webpack-merge"); const common = require("@clusterio/web_ui/webpack.common"); -module.exports = (env = {}) => merge(common(env), { +module.exports = (env = {}, argv = {}) => merge(common(env, argv), { context: __dirname, entry: "./web/index.tsx", devServer: { diff --git a/packages/create/template.js b/packages/create/template.js index d63e46b4..b8ac0d78 100644 --- a/packages/create/template.js +++ b/packages/create/template.js @@ -112,7 +112,7 @@ async function copyPluginTemplates(pluginName, templates) { // Files and dependences to support webpack if (webpack) { - prepare.push("webpack-cli --env production"); + prepare.push("webpack-cli --mode production"); files.set("webpack.config.js", path.join(commonPath, "webpack.config.js")); if (templates.includes("web")) { files.set(`web/index.${ext}x`, path.join(templatePath, `web/plugin.${ext}x`)); diff --git a/packages/create/templates/common/webpack.config.js b/packages/create/templates/common/webpack.config.js index 7be0e667..78216580 100644 --- a/packages/create/templates/common/webpack.config.js +++ b/packages/create/templates/common/webpack.config.js @@ -5,7 +5,7 @@ const { merge } = require("webpack-merge"); const common = require("@clusterio/web_ui/webpack.common"); -module.exports = (env = {}) => merge(common(env), { +module.exports = (env = {}, argv = {}) => merge(common(env, argv), { context: __dirname, entry: "./web/index.__ext__x", output: { diff --git a/packages/web_ui/package.json b/packages/web_ui/package.json index ea3f0ba1..ca912e22 100644 --- a/packages/web_ui/package.json +++ b/packages/web_ui/package.json @@ -21,7 +21,7 @@ "@ant-design/icons": "^5.6.1", "@clusterio/lib": "workspace:*", "@sinclair/typebox": "^0.30.4", - "@swc/core": "^1.11.1", + "@swc/core": "^1.13.3", "antd": "^5.24.2", "assert": "^2.0.0", "browserify-zlib": "^0.2.0", diff --git a/packages/web_ui/webpack.common.js b/packages/web_ui/webpack.common.js index 964c37a9..30bd8e99 100644 --- a/packages/web_ui/webpack.common.js +++ b/packages/web_ui/webpack.common.js @@ -4,9 +4,10 @@ const { CleanWebpackPlugin } = require("clean-webpack-plugin"); const { WebpackManifestPlugin } = require("webpack-manifest-plugin"); const TerserPlugin = require("terser-webpack-plugin"); -module.exports = (env = {}) => ({ - mode: env.production ? "production" : "development", - devtool: env.production ? "source-map" : "eval-source-map", +module.exports = (env = {}, argv = {}) => ({ + mode: argv.mode ?? "development", + devtool: argv.mode === "production" ? "source-map" : "eval-source-map", + cache: { type: "filesystem" }, performance: { maxAssetSize: 2**21, maxEntrypointSize: 2**21, @@ -34,7 +35,7 @@ module.exports = (env = {}) => ({ new webpack.NormalModuleReplacementPlugin( /@ant-design\/icons\/[A-Z]/, resource => { - resource.request = resource.request.replace(/@ant-design\/icons/, "$&/es/icons"); + resource.request = resource.request.replace("@ant-design\/icons", "$&/es/icons"); } ), ], @@ -60,7 +61,7 @@ module.exports = (env = {}) => ({ { loader: require.resolve("css-loader"), options: { - sourceMap: !env.production, + sourceMap: argv.mode !== "production", }, }, ], @@ -138,9 +139,7 @@ module.exports = (env = {}) => ({ moduleIds: "deterministic", minimizer: [ new TerserPlugin({ - // TerserPlugin.swcMinify spams log with "false" after bump to @swc/core@1.11.1 - // https://github.com/clusterio/clusterio/issues/737 - // minify: TerserPlugin.swcMinify, + minify: TerserPlugin.swcMinify, terserOptions: { compress: { keep_classnames: true, diff --git a/plugins/global_chat/package.json b/plugins/global_chat/package.json index b756dddc..311afe5f 100644 --- a/plugins/global_chat/package.json +++ b/plugins/global_chat/package.json @@ -13,7 +13,7 @@ "factorio" ], "scripts": { - "prepare": "tsc --build && webpack-cli --env production", + "prepare": "tsc --build && webpack-cli --mode production", "test": "echo \"Error: run tests from root\" && exit 1" }, "bugs": { diff --git a/plugins/global_chat/webpack.config.js b/plugins/global_chat/webpack.config.js index 39150485..43021033 100644 --- a/plugins/global_chat/webpack.config.js +++ b/plugins/global_chat/webpack.config.js @@ -5,7 +5,7 @@ const { merge } = require("webpack-merge"); const common = require("@clusterio/web_ui/webpack.common"); -module.exports = (env = {}) => merge(common(env), { +module.exports = (env = {}, argv = {}) => merge(common(env, argv), { context: __dirname, entry: "./web/index.tsx", output: { diff --git a/plugins/inventory_sync/package.json b/plugins/inventory_sync/package.json index 45bfe454..3bb967fa 100644 --- a/plugins/inventory_sync/package.json +++ b/plugins/inventory_sync/package.json @@ -13,7 +13,7 @@ "factorio" ], "scripts": { - "prepare": "tsc --build && webpack-cli --env production", + "prepare": "tsc --build && webpack-cli --mode production", "test": "echo \"Error: run tests from root\" && exit 1" }, "bugs": { diff --git a/plugins/inventory_sync/webpack.config.js b/plugins/inventory_sync/webpack.config.js index 6f4df3b1..8d2f2cc2 100644 --- a/plugins/inventory_sync/webpack.config.js +++ b/plugins/inventory_sync/webpack.config.js @@ -5,7 +5,7 @@ const { merge } = require("webpack-merge"); const common = require("@clusterio/web_ui/webpack.common"); -module.exports = (env = {}) => merge(common(env), { +module.exports = (env = {}, argv = {}) => merge(common(env, argv), { context: __dirname, entry: "./web/index.tsx", output: { diff --git a/plugins/player_auth/package.json b/plugins/player_auth/package.json index 6d15d483..31103f1e 100644 --- a/plugins/player_auth/package.json +++ b/plugins/player_auth/package.json @@ -13,7 +13,7 @@ "factorio" ], "scripts": { - "prepare": "tsc --build && webpack-cli --env production", + "prepare": "tsc --build && webpack-cli --mode production", "test": "echo \"Error: run tests from root\" && exit 1" }, "bugs": { diff --git a/plugins/player_auth/webpack.config.js b/plugins/player_auth/webpack.config.js index af39fcba..a31faea1 100644 --- a/plugins/player_auth/webpack.config.js +++ b/plugins/player_auth/webpack.config.js @@ -5,7 +5,7 @@ const { merge } = require("webpack-merge"); const common = require("@clusterio/web_ui/webpack.common"); -module.exports = (env = {}) => merge(common(env), { +module.exports = (env = {}, argv = {}) => merge(common(env, argv), { context: __dirname, entry: "./web/index.tsx", output: { diff --git a/plugins/research_sync/package.json b/plugins/research_sync/package.json index 9c17a038..51afb36e 100644 --- a/plugins/research_sync/package.json +++ b/plugins/research_sync/package.json @@ -13,7 +13,7 @@ "factorio" ], "scripts": { - "prepare": "tsc --build && webpack-cli --env production", + "prepare": "tsc --build && webpack-cli --mode production", "test": "echo \"Error: run tests from root\" && exit 1" }, "bugs": { diff --git a/plugins/research_sync/webpack.config.js b/plugins/research_sync/webpack.config.js index 52c861de..e5a4d931 100644 --- a/plugins/research_sync/webpack.config.js +++ b/plugins/research_sync/webpack.config.js @@ -5,7 +5,7 @@ const { merge } = require("webpack-merge"); const common = require("@clusterio/web_ui/webpack.common"); -module.exports = (env = {}) => merge(common(env), { +module.exports = (env = {}, argv = {}) => merge(common(env, argv), { context: __dirname, entry: "./web/index.tsx", output: { diff --git a/plugins/statistics_exporter/package.json b/plugins/statistics_exporter/package.json index e954e803..1b7e2441 100644 --- a/plugins/statistics_exporter/package.json +++ b/plugins/statistics_exporter/package.json @@ -13,7 +13,7 @@ "factorio" ], "scripts": { - "prepare": "tsc --build && webpack-cli --env production", + "prepare": "tsc --build && webpack-cli --mode production", "test": "echo \"Error: run tests from root\" && exit 1" }, "bugs": { diff --git a/plugins/statistics_exporter/webpack.config.js b/plugins/statistics_exporter/webpack.config.js index 1e25f204..bdbd99e2 100644 --- a/plugins/statistics_exporter/webpack.config.js +++ b/plugins/statistics_exporter/webpack.config.js @@ -5,7 +5,7 @@ const { merge } = require("webpack-merge"); const common = require("@clusterio/web_ui/webpack.common"); -module.exports = (env = {}) => merge(common(env), { +module.exports = (env = {}, argv = {}) => merge(common(env, argv), { context: __dirname, entry: "./web/index.tsx", output: { diff --git a/plugins/subspace_storage/package.json b/plugins/subspace_storage/package.json index 0d00d8ae..5d6aba4f 100644 --- a/plugins/subspace_storage/package.json +++ b/plugins/subspace_storage/package.json @@ -13,7 +13,7 @@ "factorio" ], "scripts": { - "prepare": "tsc --build && webpack-cli --env production", + "prepare": "tsc --build && webpack-cli --mode production", "test": "echo \"Error: run tests from root\" && exit 1" }, "bugs": { diff --git a/plugins/subspace_storage/webpack.config.js b/plugins/subspace_storage/webpack.config.js index ae97b74c..ca1c7440 100644 --- a/plugins/subspace_storage/webpack.config.js +++ b/plugins/subspace_storage/webpack.config.js @@ -5,7 +5,7 @@ const { merge } = require("webpack-merge"); const common = require("@clusterio/web_ui/webpack.common"); -module.exports = (env = {}) => merge(common(env), { +module.exports = (env = {}, argv = {}) => merge(common(env, argv), { context: __dirname, entry: "./web/index.tsx", output: {