From 8e5d581b9bd126b80753e86871c4132de24dc56d Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Wed, 7 Feb 2024 17:25:42 +0100 Subject: [PATCH 1/8] Move tsconfig.web.json to tsconfig.browser.json Rename the config files for the browser build of modules to better communicate that it's purpose is to compile code for a browser environment rather than the Web UI in particular. This also aligns with the "browser" option in package.json, the existing browser.ts entrypoint in lib, and how the browser environment is typically referred to. --- ...tsconfig.web.json => tsconfig.browser.json} | 6 +++--- ...tsconfig.web.json => tsconfig.browser.json} | 2 +- ...tsconfig.web.json => tsconfig.browser.json} | 4 ++-- packages/web_ui/webpack.common.js | 2 +- plugins/global_chat/tsconfig.browser.json | 11 +++++++++++ plugins/global_chat/tsconfig.web.json | 11 ----------- plugins/inventory_sync/tsconfig.browser.json | 11 +++++++++++ plugins/inventory_sync/tsconfig.web.json | 11 ----------- plugins/player_auth/tsconfig.browser.json | 11 +++++++++++ plugins/player_auth/tsconfig.web.json | 11 ----------- plugins/research_sync/tsconfig.browser.json | 11 +++++++++++ plugins/research_sync/tsconfig.web.json | 11 ----------- .../statistics_exporter/tsconfig.browser.json | 11 +++++++++++ plugins/statistics_exporter/tsconfig.web.json | 11 ----------- plugins/subspace_storage/tsconfig.browser.json | 11 +++++++++++ plugins/subspace_storage/tsconfig.web.json | 11 ----------- tsconfig.web.json => tsconfig.browser.json | 0 tsconfig.json | 18 +++++++++--------- 18 files changed, 82 insertions(+), 82 deletions(-) rename packages/controller/{tsconfig.web.json => tsconfig.browser.json} (54%) rename packages/lib/{tsconfig.web.json => tsconfig.browser.json} (93%) rename packages/web_ui/{tsconfig.web.json => tsconfig.browser.json} (62%) create mode 100644 plugins/global_chat/tsconfig.browser.json delete mode 100644 plugins/global_chat/tsconfig.web.json create mode 100644 plugins/inventory_sync/tsconfig.browser.json delete mode 100644 plugins/inventory_sync/tsconfig.web.json create mode 100644 plugins/player_auth/tsconfig.browser.json delete mode 100644 plugins/player_auth/tsconfig.web.json create mode 100644 plugins/research_sync/tsconfig.browser.json delete mode 100644 plugins/research_sync/tsconfig.web.json create mode 100644 plugins/statistics_exporter/tsconfig.browser.json delete mode 100644 plugins/statistics_exporter/tsconfig.web.json create mode 100644 plugins/subspace_storage/tsconfig.browser.json delete mode 100644 plugins/subspace_storage/tsconfig.web.json rename tsconfig.web.json => tsconfig.browser.json (100%) diff --git a/packages/controller/tsconfig.web.json b/packages/controller/tsconfig.browser.json similarity index 54% rename from packages/controller/tsconfig.web.json rename to packages/controller/tsconfig.browser.json index 6685a163..3fff0691 100644 --- a/packages/controller/tsconfig.web.json +++ b/packages/controller/tsconfig.browser.json @@ -1,8 +1,8 @@ { - "extends": "../../tsconfig.web.json", + "extends": "../../tsconfig.browser.json", "references": [ - { "path": "../lib/tsconfig.web.json" }, - { "path": "../web_ui/tsconfig.web.json" }, + { "path": "../lib/tsconfig.browser.json" }, + { "path": "../web_ui/tsconfig.browser.json" }, ], "include": [ "web/**/*.tsx", "web/**/*.ts", "package.json" ], "compilerOptions": { diff --git a/packages/lib/tsconfig.web.json b/packages/lib/tsconfig.browser.json similarity index 93% rename from packages/lib/tsconfig.web.json rename to packages/lib/tsconfig.browser.json index a4349659..36ebfbd9 100644 --- a/packages/lib/tsconfig.web.json +++ b/packages/lib/tsconfig.browser.json @@ -1,5 +1,5 @@ { - "extends": "../../tsconfig.web.json", + "extends": "../../tsconfig.browser.json", "include": [ "browser.ts", "package.json", diff --git a/packages/web_ui/tsconfig.web.json b/packages/web_ui/tsconfig.browser.json similarity index 62% rename from packages/web_ui/tsconfig.web.json rename to packages/web_ui/tsconfig.browser.json index 65754630..8d0236e7 100644 --- a/packages/web_ui/tsconfig.web.json +++ b/packages/web_ui/tsconfig.browser.json @@ -1,7 +1,7 @@ { - "extends": "../../tsconfig.web.json", + "extends": "../../tsconfig.browser.json", "references": [ - { "path": "../lib/tsconfig.web.json" }, + { "path": "../lib/tsconfig.browser.json" }, ], "include": [ "src/**/*.tsx", "src/**/*.ts", "package.json", "global.d.ts" ], "compilerOptions": { diff --git a/packages/web_ui/webpack.common.js b/packages/web_ui/webpack.common.js index e8a5d8b7..99825c4b 100644 --- a/packages/web_ui/webpack.common.js +++ b/packages/web_ui/webpack.common.js @@ -79,7 +79,7 @@ module.exports = (env = {}) => ({ use: { loader: require.resolve("ts-loader"), options: { - configFile: "tsconfig.web.json", + configFile: "tsconfig.browser.json", projectReferences: true, }, }, diff --git a/plugins/global_chat/tsconfig.browser.json b/plugins/global_chat/tsconfig.browser.json new file mode 100644 index 00000000..a3109220 --- /dev/null +++ b/plugins/global_chat/tsconfig.browser.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.browser.json", + "references": [ + { "path": "../../packages/lib/tsconfig.browser.json" }, + { "path": "../../packages/web_ui/tsconfig.browser.json" }, + ], + "include": [ "web/**/*.tsx", "web/**/*.ts", "messages.ts", "package.json" ], + "compilerOptions": { + "outDir": "dist/web/build", + } +} diff --git a/plugins/global_chat/tsconfig.web.json b/plugins/global_chat/tsconfig.web.json deleted file mode 100644 index c37f9141..00000000 --- a/plugins/global_chat/tsconfig.web.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "../../tsconfig.web.json", - "references": [ - { "path": "../../packages/lib/tsconfig.web.json" }, - { "path": "../../packages/web_ui/tsconfig.web.json" }, - ], - "include": [ "web/**/*.tsx", "web/**/*.ts", "messages.ts", "package.json" ], - "compilerOptions": { - "outDir": "dist/web/build", - } -} diff --git a/plugins/inventory_sync/tsconfig.browser.json b/plugins/inventory_sync/tsconfig.browser.json new file mode 100644 index 00000000..a3109220 --- /dev/null +++ b/plugins/inventory_sync/tsconfig.browser.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.browser.json", + "references": [ + { "path": "../../packages/lib/tsconfig.browser.json" }, + { "path": "../../packages/web_ui/tsconfig.browser.json" }, + ], + "include": [ "web/**/*.tsx", "web/**/*.ts", "messages.ts", "package.json" ], + "compilerOptions": { + "outDir": "dist/web/build", + } +} diff --git a/plugins/inventory_sync/tsconfig.web.json b/plugins/inventory_sync/tsconfig.web.json deleted file mode 100644 index c37f9141..00000000 --- a/plugins/inventory_sync/tsconfig.web.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "../../tsconfig.web.json", - "references": [ - { "path": "../../packages/lib/tsconfig.web.json" }, - { "path": "../../packages/web_ui/tsconfig.web.json" }, - ], - "include": [ "web/**/*.tsx", "web/**/*.ts", "messages.ts", "package.json" ], - "compilerOptions": { - "outDir": "dist/web/build", - } -} diff --git a/plugins/player_auth/tsconfig.browser.json b/plugins/player_auth/tsconfig.browser.json new file mode 100644 index 00000000..a3109220 --- /dev/null +++ b/plugins/player_auth/tsconfig.browser.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.browser.json", + "references": [ + { "path": "../../packages/lib/tsconfig.browser.json" }, + { "path": "../../packages/web_ui/tsconfig.browser.json" }, + ], + "include": [ "web/**/*.tsx", "web/**/*.ts", "messages.ts", "package.json" ], + "compilerOptions": { + "outDir": "dist/web/build", + } +} diff --git a/plugins/player_auth/tsconfig.web.json b/plugins/player_auth/tsconfig.web.json deleted file mode 100644 index c37f9141..00000000 --- a/plugins/player_auth/tsconfig.web.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "../../tsconfig.web.json", - "references": [ - { "path": "../../packages/lib/tsconfig.web.json" }, - { "path": "../../packages/web_ui/tsconfig.web.json" }, - ], - "include": [ "web/**/*.tsx", "web/**/*.ts", "messages.ts", "package.json" ], - "compilerOptions": { - "outDir": "dist/web/build", - } -} diff --git a/plugins/research_sync/tsconfig.browser.json b/plugins/research_sync/tsconfig.browser.json new file mode 100644 index 00000000..a3109220 --- /dev/null +++ b/plugins/research_sync/tsconfig.browser.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.browser.json", + "references": [ + { "path": "../../packages/lib/tsconfig.browser.json" }, + { "path": "../../packages/web_ui/tsconfig.browser.json" }, + ], + "include": [ "web/**/*.tsx", "web/**/*.ts", "messages.ts", "package.json" ], + "compilerOptions": { + "outDir": "dist/web/build", + } +} diff --git a/plugins/research_sync/tsconfig.web.json b/plugins/research_sync/tsconfig.web.json deleted file mode 100644 index c37f9141..00000000 --- a/plugins/research_sync/tsconfig.web.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "../../tsconfig.web.json", - "references": [ - { "path": "../../packages/lib/tsconfig.web.json" }, - { "path": "../../packages/web_ui/tsconfig.web.json" }, - ], - "include": [ "web/**/*.tsx", "web/**/*.ts", "messages.ts", "package.json" ], - "compilerOptions": { - "outDir": "dist/web/build", - } -} diff --git a/plugins/statistics_exporter/tsconfig.browser.json b/plugins/statistics_exporter/tsconfig.browser.json new file mode 100644 index 00000000..0454f6c4 --- /dev/null +++ b/plugins/statistics_exporter/tsconfig.browser.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.browser.json", + "references": [ + { "path": "../../packages/lib/tsconfig.browser.json" }, + { "path": "../../packages/web_ui/tsconfig.browser.json" }, + ], + "include": [ "web/**/*.tsx", "web/**/*.ts", "package.json" ], + "compilerOptions": { + "outDir": "dist/web/build", + } +} diff --git a/plugins/statistics_exporter/tsconfig.web.json b/plugins/statistics_exporter/tsconfig.web.json deleted file mode 100644 index decec50c..00000000 --- a/plugins/statistics_exporter/tsconfig.web.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "../../tsconfig.web.json", - "references": [ - { "path": "../../packages/lib/tsconfig.web.json" }, - { "path": "../../packages/web_ui/tsconfig.web.json" }, - ], - "include": [ "web/**/*.tsx", "web/**/*.ts", "package.json" ], - "compilerOptions": { - "outDir": "dist/web/build", - } -} diff --git a/plugins/subspace_storage/tsconfig.browser.json b/plugins/subspace_storage/tsconfig.browser.json new file mode 100644 index 00000000..a3109220 --- /dev/null +++ b/plugins/subspace_storage/tsconfig.browser.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.browser.json", + "references": [ + { "path": "../../packages/lib/tsconfig.browser.json" }, + { "path": "../../packages/web_ui/tsconfig.browser.json" }, + ], + "include": [ "web/**/*.tsx", "web/**/*.ts", "messages.ts", "package.json" ], + "compilerOptions": { + "outDir": "dist/web/build", + } +} diff --git a/plugins/subspace_storage/tsconfig.web.json b/plugins/subspace_storage/tsconfig.web.json deleted file mode 100644 index c37f9141..00000000 --- a/plugins/subspace_storage/tsconfig.web.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "../../tsconfig.web.json", - "references": [ - { "path": "../../packages/lib/tsconfig.web.json" }, - { "path": "../../packages/web_ui/tsconfig.web.json" }, - ], - "include": [ "web/**/*.tsx", "web/**/*.ts", "messages.ts", "package.json" ], - "compilerOptions": { - "outDir": "dist/web/build", - } -} diff --git a/tsconfig.web.json b/tsconfig.browser.json similarity index 100% rename from tsconfig.web.json rename to tsconfig.browser.json diff --git a/tsconfig.json b/tsconfig.json index c9f896d7..fbb6a7ec 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,23 +2,23 @@ "files": [], "references": [ { "path": "./packages/lib" }, - { "path": "./packages/lib/tsconfig.web.json" }, { "path": "./packages/controller" }, - { "path": "./packages/controller/tsconfig.web.json" }, { "path": "./packages/host" }, { "path": "./packages/ctl" }, - { "path": "./packages/web_ui/tsconfig.web.json" }, { "path": "./plugins/global_chat" }, - { "path": "./plugins/global_chat/tsconfig.web.json" }, { "path": "./plugins/inventory_sync" }, - { "path": "./plugins/inventory_sync/tsconfig.web.json" }, { "path": "./plugins/player_auth" }, - { "path": "./plugins/player_auth/tsconfig.web.json" }, { "path": "./plugins/research_sync" }, - { "path": "./plugins/research_sync/tsconfig.web.json" }, { "path": "./plugins/statistics_exporter" }, - { "path": "./plugins/statistics_exporter/tsconfig.web.json" }, { "path": "./plugins/subspace_storage" }, - { "path": "./plugins/subspace_storage/tsconfig.web.json" }, + { "path": "./packages/lib/tsconfig.browser.json" }, + { "path": "./packages/controller/tsconfig.browser.json" }, + { "path": "./packages/web_ui/tsconfig.browser.json" }, + { "path": "./plugins/global_chat/tsconfig.browser.json" }, + { "path": "./plugins/inventory_sync/tsconfig.browser.json" }, + { "path": "./plugins/player_auth/tsconfig.browser.json" }, + { "path": "./plugins/research_sync/tsconfig.browser.json" }, + { "path": "./plugins/statistics_exporter/tsconfig.browser.json" }, + { "path": "./plugins/subspace_storage/tsconfig.browser.json" }, ], } From 152eb7d45433ae09bf38b3baad80345ba869b3d9 Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Wed, 7 Feb 2024 17:50:48 +0100 Subject: [PATCH 2/8] Move TypeScript browser build to dist/browser Use dist/browser as the output of the browser oriented TypeScript build of packages instead of dist/web/build. This distinguishes it better from the Web UI bundle which is put together with webpack. --- packages/controller/.npmignore | 2 +- packages/controller/tsconfig.browser.json | 2 +- packages/lib/.npmignore | 2 +- packages/lib/tsconfig.browser.json | 2 +- packages/web_ui/package.json | 2 +- packages/web_ui/tsconfig.browser.json | 2 +- plugins/global_chat/.npmignore | 2 +- plugins/global_chat/tsconfig.browser.json | 2 +- plugins/inventory_sync/.npmignore | 2 +- plugins/inventory_sync/tsconfig.browser.json | 2 +- plugins/player_auth/.npmignore | 2 +- plugins/player_auth/tsconfig.browser.json | 2 +- plugins/research_sync/.npmignore | 2 +- plugins/research_sync/tsconfig.browser.json | 2 +- plugins/statistics_exporter/.npmignore | 2 +- plugins/statistics_exporter/tsconfig.browser.json | 2 +- plugins/subspace_storage/.npmignore | 2 +- plugins/subspace_storage/tsconfig.browser.json | 2 +- 18 files changed, 18 insertions(+), 18 deletions(-) diff --git a/packages/controller/.npmignore b/packages/controller/.npmignore index ebd99907..55622581 100644 --- a/packages/controller/.npmignore +++ b/packages/controller/.npmignore @@ -1,2 +1,2 @@ webpack.config.js -dist/web/build +dist/browser diff --git a/packages/controller/tsconfig.browser.json b/packages/controller/tsconfig.browser.json index 3fff0691..154bd176 100644 --- a/packages/controller/tsconfig.browser.json +++ b/packages/controller/tsconfig.browser.json @@ -7,6 +7,6 @@ "include": [ "web/**/*.tsx", "web/**/*.ts", "package.json" ], "compilerOptions": { "rootDir": "..", - "outDir": "dist/web/build", + "outDir": "dist/browser", } } diff --git a/packages/lib/.npmignore b/packages/lib/.npmignore index 5dfa68f1..55239636 100644 --- a/packages/lib/.npmignore +++ b/packages/lib/.npmignore @@ -1 +1 @@ -dist/web/build +dist/browser diff --git a/packages/lib/tsconfig.browser.json b/packages/lib/tsconfig.browser.json index 36ebfbd9..a53b11d7 100644 --- a/packages/lib/tsconfig.browser.json +++ b/packages/lib/tsconfig.browser.json @@ -25,6 +25,6 @@ ], "compilerOptions": { "rootDir": ".", - "outDir": "dist/web/build", + "outDir": "dist/browser", } } diff --git a/packages/web_ui/package.json b/packages/web_ui/package.json index 796c3242..fb77d82d 100644 --- a/packages/web_ui/package.json +++ b/packages/web_ui/package.json @@ -5,7 +5,7 @@ "license": "MIT", "version": "2.0.0-alpha.16", "browser": "src/index.ts", - "main": "dist/src/index.js", + "main": "dist/browser/src/index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, diff --git a/packages/web_ui/tsconfig.browser.json b/packages/web_ui/tsconfig.browser.json index 8d0236e7..62dbe09d 100644 --- a/packages/web_ui/tsconfig.browser.json +++ b/packages/web_ui/tsconfig.browser.json @@ -5,6 +5,6 @@ ], "include": [ "src/**/*.tsx", "src/**/*.ts", "package.json", "global.d.ts" ], "compilerOptions": { - "outDir": "dist", + "outDir": "dist/browser", } } diff --git a/plugins/global_chat/.npmignore b/plugins/global_chat/.npmignore index ebd99907..55622581 100644 --- a/plugins/global_chat/.npmignore +++ b/plugins/global_chat/.npmignore @@ -1,2 +1,2 @@ webpack.config.js -dist/web/build +dist/browser diff --git a/plugins/global_chat/tsconfig.browser.json b/plugins/global_chat/tsconfig.browser.json index a3109220..e1b39d0f 100644 --- a/plugins/global_chat/tsconfig.browser.json +++ b/plugins/global_chat/tsconfig.browser.json @@ -6,6 +6,6 @@ ], "include": [ "web/**/*.tsx", "web/**/*.ts", "messages.ts", "package.json" ], "compilerOptions": { - "outDir": "dist/web/build", + "outDir": "dist/browser", } } diff --git a/plugins/inventory_sync/.npmignore b/plugins/inventory_sync/.npmignore index ebd99907..55622581 100644 --- a/plugins/inventory_sync/.npmignore +++ b/plugins/inventory_sync/.npmignore @@ -1,2 +1,2 @@ webpack.config.js -dist/web/build +dist/browser diff --git a/plugins/inventory_sync/tsconfig.browser.json b/plugins/inventory_sync/tsconfig.browser.json index a3109220..e1b39d0f 100644 --- a/plugins/inventory_sync/tsconfig.browser.json +++ b/plugins/inventory_sync/tsconfig.browser.json @@ -6,6 +6,6 @@ ], "include": [ "web/**/*.tsx", "web/**/*.ts", "messages.ts", "package.json" ], "compilerOptions": { - "outDir": "dist/web/build", + "outDir": "dist/browser", } } diff --git a/plugins/player_auth/.npmignore b/plugins/player_auth/.npmignore index ebd99907..55622581 100644 --- a/plugins/player_auth/.npmignore +++ b/plugins/player_auth/.npmignore @@ -1,2 +1,2 @@ webpack.config.js -dist/web/build +dist/browser diff --git a/plugins/player_auth/tsconfig.browser.json b/plugins/player_auth/tsconfig.browser.json index a3109220..e1b39d0f 100644 --- a/plugins/player_auth/tsconfig.browser.json +++ b/plugins/player_auth/tsconfig.browser.json @@ -6,6 +6,6 @@ ], "include": [ "web/**/*.tsx", "web/**/*.ts", "messages.ts", "package.json" ], "compilerOptions": { - "outDir": "dist/web/build", + "outDir": "dist/browser", } } diff --git a/plugins/research_sync/.npmignore b/plugins/research_sync/.npmignore index ebd99907..55622581 100644 --- a/plugins/research_sync/.npmignore +++ b/plugins/research_sync/.npmignore @@ -1,2 +1,2 @@ webpack.config.js -dist/web/build +dist/browser diff --git a/plugins/research_sync/tsconfig.browser.json b/plugins/research_sync/tsconfig.browser.json index a3109220..e1b39d0f 100644 --- a/plugins/research_sync/tsconfig.browser.json +++ b/plugins/research_sync/tsconfig.browser.json @@ -6,6 +6,6 @@ ], "include": [ "web/**/*.tsx", "web/**/*.ts", "messages.ts", "package.json" ], "compilerOptions": { - "outDir": "dist/web/build", + "outDir": "dist/browser", } } diff --git a/plugins/statistics_exporter/.npmignore b/plugins/statistics_exporter/.npmignore index ebd99907..55622581 100644 --- a/plugins/statistics_exporter/.npmignore +++ b/plugins/statistics_exporter/.npmignore @@ -1,2 +1,2 @@ webpack.config.js -dist/web/build +dist/browser diff --git a/plugins/statistics_exporter/tsconfig.browser.json b/plugins/statistics_exporter/tsconfig.browser.json index 0454f6c4..f2dc36da 100644 --- a/plugins/statistics_exporter/tsconfig.browser.json +++ b/plugins/statistics_exporter/tsconfig.browser.json @@ -6,6 +6,6 @@ ], "include": [ "web/**/*.tsx", "web/**/*.ts", "package.json" ], "compilerOptions": { - "outDir": "dist/web/build", + "outDir": "dist/browser", } } diff --git a/plugins/subspace_storage/.npmignore b/plugins/subspace_storage/.npmignore index ebd99907..55622581 100644 --- a/plugins/subspace_storage/.npmignore +++ b/plugins/subspace_storage/.npmignore @@ -1,2 +1,2 @@ webpack.config.js -dist/web/build +dist/browser diff --git a/plugins/subspace_storage/tsconfig.browser.json b/plugins/subspace_storage/tsconfig.browser.json index a3109220..e1b39d0f 100644 --- a/plugins/subspace_storage/tsconfig.browser.json +++ b/plugins/subspace_storage/tsconfig.browser.json @@ -6,6 +6,6 @@ ], "include": [ "web/**/*.tsx", "web/**/*.ts", "messages.ts", "package.json" ], "compilerOptions": { - "outDir": "dist/web/build", + "outDir": "dist/browser", } } From 8c4d2db19211cd3bcdad847b232945ee8f6231d1 Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Wed, 7 Feb 2024 18:27:46 +0100 Subject: [PATCH 3/8] Move TypeScript Node.js build to dist/node Use a separate folder for the TypeScript build for Node.js in the dist folder. This makes each type of build consistently have its own output folder instead of being interleaved with the Node.js build. --- .eslintrc.js | 2 +- docs/devs/plugin-migration-to-alpha-14.md | 2 +- packages/controller/package.json | 4 ++-- packages/controller/src/Controller.ts | 8 ++++---- packages/controller/tsconfig.json | 2 +- packages/ctl/package.json | 4 ++-- packages/ctl/tsconfig.json | 2 +- packages/host/package.json | 4 ++-- packages/host/src/Instance.ts | 2 +- packages/host/src/export.ts | 4 ++-- packages/host/tsconfig.json | 2 +- packages/lib/package.json | 2 +- packages/lib/scripts/compile_validator.js | 6 +++--- packages/lib/tsconfig.json | 2 +- plugins/global_chat/index.ts | 4 ++-- plugins/global_chat/package.json | 2 +- plugins/global_chat/test/plugin.js | 6 +++--- plugins/global_chat/tsconfig.json | 2 +- plugins/inventory_sync/index.ts | 4 ++-- plugins/inventory_sync/package.json | 2 +- plugins/inventory_sync/tsconfig.json | 2 +- plugins/player_auth/index.ts | 4 ++-- plugins/player_auth/package.json | 2 +- plugins/player_auth/test/plugin.js | 8 ++++---- plugins/player_auth/tsconfig.json | 2 +- plugins/research_sync/index.ts | 4 ++-- plugins/research_sync/package.json | 2 +- plugins/research_sync/test/missing.js | 4 ++-- plugins/research_sync/tsconfig.json | 2 +- plugins/statistics_exporter/index.ts | 2 +- plugins/statistics_exporter/package.json | 2 +- plugins/statistics_exporter/test/plugin.js | 4 ++-- plugins/statistics_exporter/tsconfig.json | 2 +- plugins/subspace_storage/index.ts | 4 ++-- plugins/subspace_storage/package.json | 2 +- plugins/subspace_storage/test/missing.js | 8 ++++---- plugins/subspace_storage/test/routes.js | 2 +- plugins/subspace_storage/tsconfig.json | 2 +- test/controller/HttpCloser.js | 2 +- test/controller/routes.js | 2 +- test/host.js | 4 ++-- test/host/Instance.js | 2 +- test/host/export.js | 4 ++-- test/host/patch.js | 2 +- test/host/server.js | 2 +- test/integration/export.js | 4 ++-- test/integration/index.js | 10 +++++----- test/integration/patch.js | 2 +- test/integration/server.js | 2 +- test/mock.js | 4 ++-- 50 files changed, 82 insertions(+), 82 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 1487649a..d4cbf768 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -391,7 +391,7 @@ module.exports = { "node/process-exit-as-throw": "error", "node/shebang": ["error", { "convertPath": { - "*.ts": ["^(.+)\\.ts$", "dist/$1.js"], + "*.ts": ["^(.+)\\.ts$", "dist/node/$1.js"], }, }], }, diff --git a/docs/devs/plugin-migration-to-alpha-14.md b/docs/devs/plugin-migration-to-alpha-14.md index 91962795..28266664 100644 --- a/docs/devs/plugin-migration-to-alpha-14.md +++ b/docs/devs/plugin-migration-to-alpha-14.md @@ -78,7 +78,7 @@ import { BaseInstancePlugin } from "@clusterio/host"; Previously the info of a plugin would be loaded by requiring `./plugin_dir/info`, this has been changed to require `./plugin_dir` which in turn means that `info.js` is no longer the default entrypoint. To solve this you can either add `"main": "info.js",` to package.json or rename `info.js` to `index.js` (the rest of this guide assumes the entrypoint was renamed to `index.js`). -The motivation behind this change was to allow TypeScript to output its build to a sub-folder of the plugin, if you're using TypeScript you'll likely have the entrypoint be located in `dist/index.js` instead. +The motivation behind this change was to allow TypeScript to output its build to a sub-folder of the plugin, if you're using TypeScript you'll likely have the entrypoint be located in `dist/node/index.js` instead. The expected place where the declaration of a plugin is exported has also changed from `module.exports` to `module.exports.plugin`: diff --git a/packages/controller/package.json b/packages/controller/package.json index a3da2405..7446edbd 100644 --- a/packages/controller/package.json +++ b/packages/controller/package.json @@ -4,13 +4,13 @@ "author": "Hornwitser", "license": "MIT", "version": "2.0.0-alpha.16", - "main": "dist/index.js", + "main": "dist/node/index.js", "scripts": { "prepare": "tsc --build && webpack-cli --env production", "test": "echo \"Error: no test specified\" && exit 1" }, "bin": { - "clusteriocontroller": "./dist/controller.js" + "clusteriocontroller": "./dist/node/controller.js" }, "keywords": [ "factorio" diff --git a/packages/controller/src/Controller.ts b/packages/controller/src/Controller.ts index 5422fedf..7bd67a52 100644 --- a/packages/controller/src/Controller.ts +++ b/packages/controller/src/Controller.ts @@ -274,7 +274,7 @@ export default class Controller { Controller.addAppRoutes(this.app, this.pluginInfos); if (!args.dev) { - let manifestPath = path.join(__dirname, "..", "web", "manifest.json"); + let manifestPath = path.join(__dirname, "..", "..", "web", "manifest.json"); let manifest = await Controller.loadJsonObject(manifestPath); if (!manifest["main.js"]) { @@ -333,7 +333,7 @@ export default class Controller { if (args.dev) { // eslint-disable-next-line node/no-missing-require - webpackConfigs.push(require("../../webpack.config")({})); // Path outside of build + webpackConfigs.push(require("../../../webpack.config")({})); // Path outside of build } if (args.devPlugin) { let devPlugins = new Map(); @@ -737,7 +737,7 @@ export default class Controller { // Set folder to serve static content from (the website) const staticOptions = { immutable: true, maxAge: 1000 * 86400 * 365 }; app.use("/static", - express.static(path.join(__dirname, "..", "..", "dist", "web", "static"), staticOptions) + express.static(path.join(__dirname, "..", "..", "web", "static"), staticOptions) ); app.use("/static", express.static("static", staticOptions)); // Used for data export files @@ -1226,7 +1226,7 @@ export default class Controller { mainBundle = stats.toJson().assetsByChunkName["main"]; } - fs.readFile(path.join(__dirname, "..", "..", "web", "index.html"), "utf8").then((content) => { + fs.readFile(path.join(__dirname, "..", "..", "..", "web", "index.html"), "utf8").then((content) => { res.type("text/html"); res.send(content .replace(/__CLUSTER_NAME__/g, res.app.locals.controller.config.get("controller.name")) diff --git a/packages/controller/tsconfig.json b/packages/controller/tsconfig.json index 335b8b16..8dcc9b8b 100644 --- a/packages/controller/tsconfig.json +++ b/packages/controller/tsconfig.json @@ -5,6 +5,6 @@ ], "include": ["index.ts", "controller.ts", "package.json", "src/**/*.ts"], "compilerOptions": { - "outDir": "dist", + "outDir": "dist/node", }, } diff --git a/packages/ctl/package.json b/packages/ctl/package.json index 8793f1bb..7d5f6707 100644 --- a/packages/ctl/package.json +++ b/packages/ctl/package.json @@ -4,13 +4,13 @@ "author": "Hornwitser", "license": "MIT", "version": "2.0.0-alpha.16", - "main": "dist/index.js", + "main": "dist/node/index.js", "scripts": { "prepare": "tsc --build", "test": "echo \"Error: no test specified\" && exit 1" }, "bin": { - "clusterioctl": "./dist/ctl.js" + "clusterioctl": "./dist/node/ctl.js" }, "keywords": [ "factorio" diff --git a/packages/ctl/tsconfig.json b/packages/ctl/tsconfig.json index 574dad9d..134019a5 100644 --- a/packages/ctl/tsconfig.json +++ b/packages/ctl/tsconfig.json @@ -5,6 +5,6 @@ ], "include": ["index.ts", "package.json", "ctl.ts", "src/**/*.ts"], "compilerOptions": { - "outDir": "dist", + "outDir": "dist/node", }, } diff --git a/packages/host/package.json b/packages/host/package.json index ce801590..c9f8446a 100644 --- a/packages/host/package.json +++ b/packages/host/package.json @@ -4,13 +4,13 @@ "author": "Hornwitser", "license": "MIT", "version": "2.0.0-alpha.16", - "main": "dist/index.js", + "main": "dist/node/index.js", "scripts": { "prepare": "tsc --build", "test": "echo \"Error: no test specified\" && exit 1" }, "bin": { - "clusteriohost": "./dist/host.js" + "clusteriohost": "./dist/node/host.js" }, "keywords": [ "factorio" diff --git a/packages/host/src/Instance.ts b/packages/host/src/Instance.ts index 98d4d0eb..f6163611 100644 --- a/packages/host/src/Instance.ts +++ b/packages/host/src/Instance.ts @@ -800,7 +800,7 @@ rcon.print(game.table_to_json(players))`.replace(/\r?\n/g, " "); // Find stand alone modules to load // XXX for now only the included clusterio module is loaded - let modulesDirectory = path.join(__dirname, "..", "..", "modules"); + let modulesDirectory = path.join(__dirname, "..", "..", "..", "modules"); for (let entry of await fs.readdir(modulesDirectory, { withFileTypes: true })) { if (entry.isDirectory()) { if (modules.has(entry.name)) { diff --git a/packages/host/src/export.ts b/packages/host/src/export.ts index dcd2b01a..938836d4 100644 --- a/packages/host/src/export.ts +++ b/packages/host/src/export.ts @@ -5,7 +5,7 @@ import Jimp from "jimp"; import JSZip from "jszip"; import * as lib from "@clusterio/lib"; -import * as libBuildMod from "@clusterio/lib/dist/build_mod"; +import * as libBuildMod from "@clusterio/lib/dist/node/build_mod"; import type { FactorioServer } from "./server"; interface Prototype { @@ -62,7 +62,7 @@ async function generateExportMod(server: FactorioServer) { clean: false, build: true, pack: true, - sourceDir: path.join(__dirname, "..", "..", "lua", "export"), + sourceDir: path.join(__dirname, "..", "..", "..", "lua", "export"), outputDir: server.writePath("mods"), bumpPatch: false, factorioVersion: server.version.replace(/\.\d+$/, ""), diff --git a/packages/host/tsconfig.json b/packages/host/tsconfig.json index bc67208a..13df203e 100644 --- a/packages/host/tsconfig.json +++ b/packages/host/tsconfig.json @@ -5,6 +5,6 @@ ], "include": ["index.ts", "host.ts", "package.json", "src/**/*.ts", "src/**/*.js"], "compilerOptions": { - "outDir": "dist", + "outDir": "dist/node", }, } diff --git a/packages/lib/package.json b/packages/lib/package.json index 538f5d75..1c5cd2d6 100644 --- a/packages/lib/package.json +++ b/packages/lib/package.json @@ -8,7 +8,7 @@ "prepare": "tsc --build && pnpm run compile_validator", "compile_validator": "node scripts/compile_validator.js" }, - "main": "dist/index.js", + "main": "dist/node/index.js", "browser": "browser.ts", "keywords": [ "factorio" diff --git a/packages/lib/scripts/compile_validator.js b/packages/lib/scripts/compile_validator.js index e2eafeb3..9dd5fabd 100644 --- a/packages/lib/scripts/compile_validator.js +++ b/packages/lib/scripts/compile_validator.js @@ -7,9 +7,9 @@ const standaloneCode = require("ajv/dist/standalone").default; /* eslint-disable node/no-sync */ // Provide an empty file for message_core to load -fs.outputFileSync(path.join(__dirname, "../dist/src/data/message_validate.js"), ""); +fs.outputFileSync(path.join(__dirname, "../dist/node/src/data/message_validate.js"), ""); -const { Message } = require("../dist/src/data/messages_core"); +const { Message } = require("../dist/node/src/data/messages_core"); const ajv = new Ajv({ allowUnionTypes: true, @@ -28,5 +28,5 @@ function write(output) { `// generated by scripts/compile_validator.js\n// @ts-nocheck\n/* eslint-disable */\n${moduleCode}` ); } -write("../dist/src/data/message_validate.js"); +write("../dist/node/src/data/message_validate.js"); write("../src/data/message_validate.js"); diff --git a/packages/lib/tsconfig.json b/packages/lib/tsconfig.json index dbc005eb..d3dab4e1 100644 --- a/packages/lib/tsconfig.json +++ b/packages/lib/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.node.json", "include": ["index.ts", "browser.ts", "build_mod.js", "src/**/*.ts", "src/**/*.js"], "compilerOptions": { - "outDir": "dist", + "outDir": "dist/node", "allowJs": true, }, } diff --git a/plugins/global_chat/index.ts b/plugins/global_chat/index.ts index 620a8ecc..97c0985a 100644 --- a/plugins/global_chat/index.ts +++ b/plugins/global_chat/index.ts @@ -6,8 +6,8 @@ export const plugin: lib.PluginDeclaration = { name: "global_chat", title: "Global Chat", description: "Forwards chat between instances.", - instanceEntrypoint: "dist/plugin/instance", - ctlEntrypoint: "dist/plugin/control", + instanceEntrypoint: "dist/node/instance", + ctlEntrypoint: "dist/node/control", messages: [ ChatEvent, diff --git a/plugins/global_chat/package.json b/plugins/global_chat/package.json index 09d9adb6..26518d2c 100644 --- a/plugins/global_chat/package.json +++ b/plugins/global_chat/package.json @@ -6,7 +6,7 @@ "homepage": "https://github.com/clusterio/clusterio#readme", "license": "MIT", "repository": "clusterio/clusterio", - "main": "dist/plugin/index.js", + "main": "dist/node/index.js", "scripts": { "prepare": "tsc --build && webpack-cli --env production", "test": "echo \"Error: run tests from root\" && exit 1" diff --git a/plugins/global_chat/test/plugin.js b/plugins/global_chat/test/plugin.js index d8b9b860..315df7eb 100644 --- a/plugins/global_chat/test/plugin.js +++ b/plugins/global_chat/test/plugin.js @@ -4,9 +4,9 @@ const lib = require("@clusterio/lib"); const mock = require("../../../test/mock"); const lines = require("../../../test/lib/factorio/lines"); -const instance = require("../dist/plugin/instance"); -const info = require("../dist/plugin/index").plugin; -const { ChatEvent } = require("../dist/plugin/messages"); +const instance = require("../dist/node/instance"); +const info = require("../dist/node/index").plugin; +const { ChatEvent } = require("../dist/node/messages"); describe("global_chat plugin", function() { diff --git a/plugins/global_chat/tsconfig.json b/plugins/global_chat/tsconfig.json index 087576d6..15815646 100644 --- a/plugins/global_chat/tsconfig.json +++ b/plugins/global_chat/tsconfig.json @@ -6,6 +6,6 @@ "include": ["./**/*.ts"], "exclude": ["test/*", "./dist/*"], "compilerOptions": { - "outDir": "dist/plugin", + "outDir": "dist/node", }, } diff --git a/plugins/inventory_sync/index.ts b/plugins/inventory_sync/index.ts index 029e3a46..a796ee97 100644 --- a/plugins/inventory_sync/index.ts +++ b/plugins/inventory_sync/index.ts @@ -22,7 +22,7 @@ export const plugin: lib.PluginDeclaration = { title: "Inventory sync", description: "Synchronizes players inventories between instances", - instanceEntrypoint: "dist/plugin/instance", + instanceEntrypoint: "dist/node/instance", instanceConfigFields: { "inventory_sync.rcon_chunk_size": { title: "Rcon inventory chunk size", @@ -33,7 +33,7 @@ export const plugin: lib.PluginDeclaration = { }, }, - controllerEntrypoint: "dist/plugin/controller", + controllerEntrypoint: "dist/node/controller", controllerConfigFields: { "inventory_sync.player_lock_timeout": { title: "Player Lock Timeout", diff --git a/plugins/inventory_sync/package.json b/plugins/inventory_sync/package.json index 384a64dd..2bf25a2a 100644 --- a/plugins/inventory_sync/package.json +++ b/plugins/inventory_sync/package.json @@ -6,7 +6,7 @@ "homepage": "https://github.com/clusterio/factorioClusterio#readme", "license": "MIT", "repository": "clusterio/factorioClusterio", - "main": "dist/plugin/index.js", + "main": "dist/node/index.js", "scripts": { "prepare": "tsc --build && webpack-cli --env production", "test": "echo \"Error: run tests from root\" && exit 1" diff --git a/plugins/inventory_sync/tsconfig.json b/plugins/inventory_sync/tsconfig.json index 087576d6..15815646 100644 --- a/plugins/inventory_sync/tsconfig.json +++ b/plugins/inventory_sync/tsconfig.json @@ -6,6 +6,6 @@ "include": ["./**/*.ts"], "exclude": ["test/*", "./dist/*"], "compilerOptions": { - "outDir": "dist/plugin", + "outDir": "dist/node", }, } diff --git a/plugins/player_auth/index.ts b/plugins/player_auth/index.ts index a181c508..62e7b109 100644 --- a/plugins/player_auth/index.ts +++ b/plugins/player_auth/index.ts @@ -15,8 +15,8 @@ export const plugin: lib.PluginDeclaration = { name: "player_auth", title: "Player Auth", description: "Provides authentication to the cluster via logging into a Factorio server.", - controllerEntrypoint: "dist/plugin/controller", - instanceEntrypoint: "dist/plugin/instance", + controllerEntrypoint: "dist/node/controller", + instanceEntrypoint: "dist/node/instance", webEntrypoint: "./web", controllerConfigFields: { "player_auth.code_length": { diff --git a/plugins/player_auth/package.json b/plugins/player_auth/package.json index 8cf5b5c9..733ebf7a 100644 --- a/plugins/player_auth/package.json +++ b/plugins/player_auth/package.json @@ -6,7 +6,7 @@ "homepage": "https://github.com/clusterio/clusterio#readme", "license": "MIT", "repository": "clusterio/clusterio", - "main": "dist/plugin/index.js", + "main": "dist/node/index.js", "scripts": { "prepare": "tsc --build && webpack-cli --env production", "test": "echo \"Error: run tests from root\" && exit 1" diff --git a/plugins/player_auth/test/plugin.js b/plugins/player_auth/test/plugin.js index 8dc59142..6b90348e 100644 --- a/plugins/player_auth/test/plugin.js +++ b/plugins/player_auth/test/plugin.js @@ -5,10 +5,10 @@ const jwt = require("jsonwebtoken"); const mock = require("../../../test/mock"); -const controller = require("../dist/plugin/controller"); -const instance = require("../dist/plugin/instance"); -const info = require("../dist/plugin/index").plugin; -const { FetchPlayerCodeRequest, SetVerifyCodeRequest } = require("../dist/plugin/messages"); +const controller = require("../dist/node/controller"); +const instance = require("../dist/node/instance"); +const info = require("../dist/node/index").plugin; +const { FetchPlayerCodeRequest, SetVerifyCodeRequest } = require("../dist/node/messages"); const lib = require("@clusterio/lib"); diff --git a/plugins/player_auth/tsconfig.json b/plugins/player_auth/tsconfig.json index 087576d6..15815646 100644 --- a/plugins/player_auth/tsconfig.json +++ b/plugins/player_auth/tsconfig.json @@ -6,6 +6,6 @@ "include": ["./**/*.ts"], "exclude": ["test/*", "./dist/*"], "compilerOptions": { - "outDir": "dist/plugin", + "outDir": "dist/node", }, } diff --git a/plugins/research_sync/index.ts b/plugins/research_sync/index.ts index af7c8364..42f162d5 100644 --- a/plugins/research_sync/index.ts +++ b/plugins/research_sync/index.ts @@ -6,8 +6,8 @@ export const plugin: lib.PluginDeclaration = { name: "research_sync", title: "Research Sync", description: "Synchronises technology research progress between instances.", - instanceEntrypoint: "dist/plugin/instance", - controllerEntrypoint: "dist/plugin/controller", + instanceEntrypoint: "dist/node/instance", + controllerEntrypoint: "dist/node/controller", messages: [ messages.ContributionEvent, diff --git a/plugins/research_sync/package.json b/plugins/research_sync/package.json index fb9d4424..f5a74600 100644 --- a/plugins/research_sync/package.json +++ b/plugins/research_sync/package.json @@ -6,7 +6,7 @@ "homepage": "https://github.com/clusterio/clusterio#readme", "license": "MIT", "repository": "clusterio/clusterio", - "main": "dist/plugin/index.js", + "main": "dist/node/index.js", "scripts": { "prepare": "tsc --build && webpack-cli --env production", "test": "echo \"Error: run tests from root\" && exit 1" diff --git a/plugins/research_sync/test/missing.js b/plugins/research_sync/test/missing.js index 790baadb..ae16e8f1 100644 --- a/plugins/research_sync/test/missing.js +++ b/plugins/research_sync/test/missing.js @@ -2,5 +2,5 @@ // required here in order to track coverage for them. "use strict"; -require("../dist/plugin/instance"); -require("../dist/plugin/controller"); +require("../dist/node/instance"); +require("../dist/node/controller"); diff --git a/plugins/research_sync/tsconfig.json b/plugins/research_sync/tsconfig.json index 087576d6..15815646 100644 --- a/plugins/research_sync/tsconfig.json +++ b/plugins/research_sync/tsconfig.json @@ -6,6 +6,6 @@ "include": ["./**/*.ts"], "exclude": ["test/*", "./dist/*"], "compilerOptions": { - "outDir": "dist/plugin", + "outDir": "dist/node", }, } diff --git a/plugins/statistics_exporter/index.ts b/plugins/statistics_exporter/index.ts index 8748224c..5de5fc80 100644 --- a/plugins/statistics_exporter/index.ts +++ b/plugins/statistics_exporter/index.ts @@ -12,7 +12,7 @@ export const plugin: lib.PluginDeclaration = { description: "Provides in-game item/fluid production, builds, kills, and pollution "+ "statistics to the cluster's Prometheus endpoint.", - instanceEntrypoint: "dist/plugin/instance", + instanceEntrypoint: "dist/node/instance", instanceConfigFields: { "statistics_exporter.command_timeout": { title: "Command Timeout", diff --git a/plugins/statistics_exporter/package.json b/plugins/statistics_exporter/package.json index c8e5a12f..21c9c87f 100644 --- a/plugins/statistics_exporter/package.json +++ b/plugins/statistics_exporter/package.json @@ -6,7 +6,7 @@ "homepage": "https://github.com/clusterio/clusterio#readme", "license": "MIT", "repository": "clusterio/clusterio", - "main": "dist/plugin/index.js", + "main": "dist/node/index.js", "scripts": { "prepare": "tsc --build && webpack-cli --env production", "test": "echo \"Error: run tests from root\" && exit 1" diff --git a/plugins/statistics_exporter/test/plugin.js b/plugins/statistics_exporter/test/plugin.js index e54184a4..18251e27 100644 --- a/plugins/statistics_exporter/test/plugin.js +++ b/plugins/statistics_exporter/test/plugin.js @@ -2,8 +2,8 @@ const assert = require("assert").strict; const mock = require("../../../test/mock"); -const instance = require("../dist/plugin/instance"); -const info = require("../dist/plugin/index").plugin; +const instance = require("../dist/node/instance"); +const info = require("../dist/node/index").plugin; describe("statistics_exporter plugin", function() { diff --git a/plugins/statistics_exporter/tsconfig.json b/plugins/statistics_exporter/tsconfig.json index 087576d6..15815646 100644 --- a/plugins/statistics_exporter/tsconfig.json +++ b/plugins/statistics_exporter/tsconfig.json @@ -6,6 +6,6 @@ "include": ["./**/*.ts"], "exclude": ["test/*", "./dist/*"], "compilerOptions": { - "outDir": "dist/plugin", + "outDir": "dist/node", }, } diff --git a/plugins/subspace_storage/index.ts b/plugins/subspace_storage/index.ts index 6543cd6c..1909ef29 100644 --- a/plugins/subspace_storage/index.ts +++ b/plugins/subspace_storage/index.ts @@ -22,7 +22,7 @@ export const plugin: lib.PluginDeclaration = { name: "subspace_storage", title: "Subspace Storage", description: "Provides shared storage across instances for the Subspace Storage mod", - instanceEntrypoint: "dist/plugin/instance", + instanceEntrypoint: "dist/node/instance", instanceConfigFields: { "subspace_storage.log_item_transfers": { title: "Log Item Transfers", @@ -32,7 +32,7 @@ export const plugin: lib.PluginDeclaration = { }, }, - controllerEntrypoint: "dist/plugin/controller", + controllerEntrypoint: "dist/node/controller", controllerConfigFields: { "subspace_storage.division_method": { title: "Division Method", diff --git a/plugins/subspace_storage/package.json b/plugins/subspace_storage/package.json index 892e9ca9..5dce5e9b 100644 --- a/plugins/subspace_storage/package.json +++ b/plugins/subspace_storage/package.json @@ -6,7 +6,7 @@ "homepage": "https://github.com/clusterio/clusterio#readme", "license": "MIT", "repository": "clusterio/clusterio", - "main": "dist/plugin/index.js", + "main": "dist/node/index.js", "scripts": { "prepare": "tsc --build && webpack-cli --env production", "test": "echo \"Error: run tests from root\" && exit 1" diff --git a/plugins/subspace_storage/test/missing.js b/plugins/subspace_storage/test/missing.js index 6f7e6a1b..ab3009d7 100644 --- a/plugins/subspace_storage/test/missing.js +++ b/plugins/subspace_storage/test/missing.js @@ -2,7 +2,7 @@ // required here in order to track coverage for them. "use strict"; -require("../dist/plugin/instance"); -require("../dist/plugin/controller"); -require("../dist/plugin/dole"); -require("../dist/plugin/dole_nn_base"); +require("../dist/node/instance"); +require("../dist/node/controller"); +require("../dist/node/dole"); +require("../dist/node/dole_nn_base"); diff --git a/plugins/subspace_storage/test/routes.js b/plugins/subspace_storage/test/routes.js index 00de92b0..2753b41e 100644 --- a/plugins/subspace_storage/test/routes.js +++ b/plugins/subspace_storage/test/routes.js @@ -1,7 +1,7 @@ "use strict"; const assert = require("assert").strict; -const routes = require("../dist/plugin/routes"); +const routes = require("../dist/node/routes"); const { get } = require("../../../test/integration"); diff --git a/plugins/subspace_storage/tsconfig.json b/plugins/subspace_storage/tsconfig.json index 087576d6..15815646 100644 --- a/plugins/subspace_storage/tsconfig.json +++ b/plugins/subspace_storage/tsconfig.json @@ -6,6 +6,6 @@ "include": ["./**/*.ts"], "exclude": ["test/*", "./dist/*"], "compilerOptions": { - "outDir": "dist/plugin", + "outDir": "dist/node", }, } diff --git a/test/controller/HttpCloser.js b/test/controller/HttpCloser.js index 6c48ba2a..d630600b 100644 --- a/test/controller/HttpCloser.js +++ b/test/controller/HttpCloser.js @@ -7,7 +7,7 @@ const util = require("util"); const phin = require("phin"); -const HttpCloser = require("@clusterio/controller/dist/src/HttpCloser").default; +const HttpCloser = require("@clusterio/controller/dist/node/src/HttpCloser").default; // Time to wait during async operations to ensure they happened in order. const tick = 20; diff --git a/test/controller/routes.js b/test/controller/routes.js index a598f276..e69449ca 100644 --- a/test/controller/routes.js +++ b/test/controller/routes.js @@ -7,7 +7,7 @@ const http = require("http"); const phin = require("phin"); const { wait } = require("@clusterio/lib"); -const routes = require("@clusterio/controller/dist/src/routes"); +const routes = require("@clusterio/controller/dist/node/src/routes"); const mock = require("../mock"); diff --git a/test/host.js b/test/host.js index 3aa8162e..75244b9e 100644 --- a/test/host.js +++ b/test/host.js @@ -3,8 +3,8 @@ const assert = require("assert").strict; const path = require("path"); const lib = require("@clusterio/lib"); -const Host = require("@clusterio/host/dist/src/Host").default; -const { _discoverInstances } = require("@clusterio/host/dist/src/Host"); +const Host = require("@clusterio/host/dist/node/src/Host").default; +const { _discoverInstances } = require("@clusterio/host/dist/node/src/Host"); describe("Host testing", function() { describe("discoverInstances()", function() { diff --git a/test/host/Instance.js b/test/host/Instance.js index b899a335..9df6a598 100644 --- a/test/host/Instance.js +++ b/test/host/Instance.js @@ -4,7 +4,7 @@ const path = require("path"); const lib = require("@clusterio/lib"); const { PlayerStats, wait } = lib; -const Instance = require("@clusterio/host/dist/src/Instance").default; +const Instance = require("@clusterio/host/dist/node/src/Instance").default; const { MockConnector, MockServer } = require("../mock"); const addr = lib.Address.fromShorthand; diff --git a/test/host/export.js b/test/host/export.js index f99b53ba..b0de6a0a 100644 --- a/test/host/export.js +++ b/test/host/export.js @@ -2,8 +2,8 @@ const assert = require("assert").strict; const path = require("path"); -const { FactorioServer } = require("@clusterio/host/dist/src/server"); -const { _exportLocale } = require("@clusterio/host/dist/src/export"); +const { FactorioServer } = require("@clusterio/host/dist/node/src/server"); +const { _exportLocale } = require("@clusterio/host/dist/node/src/export"); describe("host/src/export", function() { diff --git a/test/host/patch.js b/test/host/patch.js index 9998bccc..8655aabd 100644 --- a/test/host/patch.js +++ b/test/host/patch.js @@ -5,7 +5,7 @@ const JSZip = require("jszip"); const path = require("path"); const lib = require("@clusterio/lib"); -const patch = require("@clusterio/host/dist/src/patch"); +const patch = require("@clusterio/host/dist/node/src/patch"); describe("host/patch", function() { diff --git a/test/host/server.js b/test/host/server.js index 12ade2e0..ea92a06c 100644 --- a/test/host/server.js +++ b/test/host/server.js @@ -4,7 +4,7 @@ const events = require("events"); const fs = require("fs-extra"); const path = require("path"); -const hostServer = require("@clusterio/host/dist/src/server"); +const hostServer = require("@clusterio/host/dist/node/src/server"); const lib = require("@clusterio/lib"); const { wait } = lib; const { testLines } = require("../lib/factorio/lines"); diff --git a/test/integration/export.js b/test/integration/export.js index 3ab962cc..a0d8345a 100644 --- a/test/integration/export.js +++ b/test/integration/export.js @@ -2,8 +2,8 @@ const assert = require("assert").strict; const path = require("path"); -const { _exportLocale } = require("@clusterio/host/dist/src/export"); -const { FactorioServer } = require("@clusterio/host/dist/src/server"); +const { _exportLocale } = require("@clusterio/host/dist/node/src/export"); +const { FactorioServer } = require("@clusterio/host/dist/node/src/server"); describe("Integration of lib/factorio/export", function() { diff --git a/test/integration/index.js b/test/integration/index.js index 6932e283..22450cbd 100644 --- a/test/integration/index.js +++ b/test/integration/index.js @@ -12,11 +12,11 @@ const lib = require("@clusterio/lib"); const { LineSplitter, ConsoleTransport, logger } = lib; // Make sure permissions from plugins are loaded -require("../../plugins/global_chat/dist/plugin/index"); -require("../../plugins/player_auth/dist/plugin/index"); -require("../../plugins/research_sync/dist/plugin/index"); -require("../../plugins/statistics_exporter/dist/plugin/index"); -require("../../plugins/subspace_storage/dist/plugin/index"); +require("../../plugins/global_chat/dist/node/index"); +require("../../plugins/player_auth/dist/node/index"); +require("../../plugins/research_sync/dist/node/index"); +require("../../plugins/statistics_exporter/dist/node/index"); +require("../../plugins/subspace_storage/dist/node/index"); const subspaceStorageVersion = "1.99.8"; const subspaceStorageGitHubTag = "1.99.6"; // Tag subspaceStorageVersion was released under on GitHub diff --git a/test/integration/patch.js b/test/integration/patch.js index bfc1f224..3b2cc72d 100644 --- a/test/integration/patch.js +++ b/test/integration/patch.js @@ -4,7 +4,7 @@ const fs = require("fs-extra"); const JSZip = require("jszip"); const path = require("path"); -const { patch, SaveModule } = require("@clusterio/host/dist/src/patch"); +const { patch, SaveModule } = require("@clusterio/host/dist/node/src/patch"); const lib = require("@clusterio/lib"); const { slowTest } = require("./index"); diff --git a/test/integration/server.js b/test/integration/server.js index 0aeac758..9073bbb8 100644 --- a/test/integration/server.js +++ b/test/integration/server.js @@ -5,7 +5,7 @@ const fs = require("fs-extra"); const path = require("path"); const lib = require("@clusterio/lib"); -const { FactorioServer, _getVersion } = require("@clusterio/host/dist/src/server"); +const { FactorioServer, _getVersion } = require("@clusterio/host/dist/node/src/server"); const { logger } = lib; const { slowTest } = require("./index"); diff --git a/test/mock.js b/test/mock.js index 4d2a8564..1c1fb84b 100644 --- a/test/mock.js +++ b/test/mock.js @@ -5,8 +5,8 @@ const express = require("express"); const lib = require("@clusterio/lib"); -const UserManager = require("@clusterio/controller/dist/src/UserManager").default; -const ControllerUser = require("@clusterio/controller/dist/src/ControllerUser").default; +const UserManager = require("@clusterio/controller/dist/node/src/UserManager").default; +const ControllerUser = require("@clusterio/controller/dist/node/src/ControllerUser").default; const addr = lib.Address.fromShorthand; From e4f90b348036b5b8039930bb49952327617c254b Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Wed, 7 Feb 2024 19:17:11 +0100 Subject: [PATCH 4/8] Move tsconfig.json to tsconfig.node.json Distinguish the Node.js build in the same way the browser build is with the .node suffix to the tsconfig files it uses. This means tsconfig.node outputs to dist/node and tsconfig.browser outputs to dist/browser. --- .../{tsconfig.json => tsconfig.node.json} | 2 +- .../ctl/{tsconfig.json => tsconfig.node.json} | 2 +- .../{tsconfig.json => tsconfig.node.json} | 2 +- .../lib/{tsconfig.json => tsconfig.node.json} | 0 .../tsconfig.node.json} | 2 +- .../tsconfig.node.json} | 2 +- .../tsconfig.node.json} | 2 +- .../tsconfig.node.json} | 2 +- plugins/statistics_exporter/tsconfig.json | 11 ---------- .../statistics_exporter/tsconfig.node.json | 11 ++++++++++ plugins/subspace_storage/tsconfig.json | 11 ---------- plugins/subspace_storage/tsconfig.node.json | 11 ++++++++++ tsconfig.json | 20 +++++++++---------- 13 files changed, 39 insertions(+), 39 deletions(-) rename packages/controller/{tsconfig.json => tsconfig.node.json} (81%) rename packages/ctl/{tsconfig.json => tsconfig.node.json} (80%) rename packages/host/{tsconfig.json => tsconfig.node.json} (82%) rename packages/lib/{tsconfig.json => tsconfig.node.json} (100%) rename plugins/{inventory_sync/tsconfig.json => global_chat/tsconfig.node.json} (76%) rename plugins/{player_auth/tsconfig.json => inventory_sync/tsconfig.node.json} (76%) rename plugins/{research_sync/tsconfig.json => player_auth/tsconfig.node.json} (76%) rename plugins/{global_chat/tsconfig.json => research_sync/tsconfig.node.json} (76%) delete mode 100644 plugins/statistics_exporter/tsconfig.json create mode 100644 plugins/statistics_exporter/tsconfig.node.json delete mode 100644 plugins/subspace_storage/tsconfig.json create mode 100644 plugins/subspace_storage/tsconfig.node.json diff --git a/packages/controller/tsconfig.json b/packages/controller/tsconfig.node.json similarity index 81% rename from packages/controller/tsconfig.json rename to packages/controller/tsconfig.node.json index 8dcc9b8b..9dcc91db 100644 --- a/packages/controller/tsconfig.json +++ b/packages/controller/tsconfig.node.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.node.json", "references": [ - { "path": "../lib" }, + { "path": "../lib/tsconfig.node.json" }, ], "include": ["index.ts", "controller.ts", "package.json", "src/**/*.ts"], "compilerOptions": { diff --git a/packages/ctl/tsconfig.json b/packages/ctl/tsconfig.node.json similarity index 80% rename from packages/ctl/tsconfig.json rename to packages/ctl/tsconfig.node.json index 134019a5..3a0fb105 100644 --- a/packages/ctl/tsconfig.json +++ b/packages/ctl/tsconfig.node.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.node.json", "references": [ - { "path": "../lib" }, + { "path": "../lib/tsconfig.node.json" }, ], "include": ["index.ts", "package.json", "ctl.ts", "src/**/*.ts"], "compilerOptions": { diff --git a/packages/host/tsconfig.json b/packages/host/tsconfig.node.json similarity index 82% rename from packages/host/tsconfig.json rename to packages/host/tsconfig.node.json index 13df203e..e7a488be 100644 --- a/packages/host/tsconfig.json +++ b/packages/host/tsconfig.node.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.node.json", "references": [ - { "path": "../lib" }, + { "path": "../lib/tsconfig.node.json" }, ], "include": ["index.ts", "host.ts", "package.json", "src/**/*.ts", "src/**/*.js"], "compilerOptions": { diff --git a/packages/lib/tsconfig.json b/packages/lib/tsconfig.node.json similarity index 100% rename from packages/lib/tsconfig.json rename to packages/lib/tsconfig.node.json diff --git a/plugins/inventory_sync/tsconfig.json b/plugins/global_chat/tsconfig.node.json similarity index 76% rename from plugins/inventory_sync/tsconfig.json rename to plugins/global_chat/tsconfig.node.json index 15815646..b6197500 100644 --- a/plugins/inventory_sync/tsconfig.json +++ b/plugins/global_chat/tsconfig.node.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.node.json", "references": [ - { "path": "../../packages/lib" }, + { "path": "../../packages/lib/tsconfig.node.json" }, ], "include": ["./**/*.ts"], "exclude": ["test/*", "./dist/*"], diff --git a/plugins/player_auth/tsconfig.json b/plugins/inventory_sync/tsconfig.node.json similarity index 76% rename from plugins/player_auth/tsconfig.json rename to plugins/inventory_sync/tsconfig.node.json index 15815646..b6197500 100644 --- a/plugins/player_auth/tsconfig.json +++ b/plugins/inventory_sync/tsconfig.node.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.node.json", "references": [ - { "path": "../../packages/lib" }, + { "path": "../../packages/lib/tsconfig.node.json" }, ], "include": ["./**/*.ts"], "exclude": ["test/*", "./dist/*"], diff --git a/plugins/research_sync/tsconfig.json b/plugins/player_auth/tsconfig.node.json similarity index 76% rename from plugins/research_sync/tsconfig.json rename to plugins/player_auth/tsconfig.node.json index 15815646..b6197500 100644 --- a/plugins/research_sync/tsconfig.json +++ b/plugins/player_auth/tsconfig.node.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.node.json", "references": [ - { "path": "../../packages/lib" }, + { "path": "../../packages/lib/tsconfig.node.json" }, ], "include": ["./**/*.ts"], "exclude": ["test/*", "./dist/*"], diff --git a/plugins/global_chat/tsconfig.json b/plugins/research_sync/tsconfig.node.json similarity index 76% rename from plugins/global_chat/tsconfig.json rename to plugins/research_sync/tsconfig.node.json index 15815646..b6197500 100644 --- a/plugins/global_chat/tsconfig.json +++ b/plugins/research_sync/tsconfig.node.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.node.json", "references": [ - { "path": "../../packages/lib" }, + { "path": "../../packages/lib/tsconfig.node.json" }, ], "include": ["./**/*.ts"], "exclude": ["test/*", "./dist/*"], diff --git a/plugins/statistics_exporter/tsconfig.json b/plugins/statistics_exporter/tsconfig.json deleted file mode 100644 index 15815646..00000000 --- a/plugins/statistics_exporter/tsconfig.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "../../tsconfig.node.json", - "references": [ - { "path": "../../packages/lib" }, - ], - "include": ["./**/*.ts"], - "exclude": ["test/*", "./dist/*"], - "compilerOptions": { - "outDir": "dist/node", - }, -} diff --git a/plugins/statistics_exporter/tsconfig.node.json b/plugins/statistics_exporter/tsconfig.node.json new file mode 100644 index 00000000..b6197500 --- /dev/null +++ b/plugins/statistics_exporter/tsconfig.node.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.node.json", + "references": [ + { "path": "../../packages/lib/tsconfig.node.json" }, + ], + "include": ["./**/*.ts"], + "exclude": ["test/*", "./dist/*"], + "compilerOptions": { + "outDir": "dist/node", + }, +} diff --git a/plugins/subspace_storage/tsconfig.json b/plugins/subspace_storage/tsconfig.json deleted file mode 100644 index 15815646..00000000 --- a/plugins/subspace_storage/tsconfig.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "../../tsconfig.node.json", - "references": [ - { "path": "../../packages/lib" }, - ], - "include": ["./**/*.ts"], - "exclude": ["test/*", "./dist/*"], - "compilerOptions": { - "outDir": "dist/node", - }, -} diff --git a/plugins/subspace_storage/tsconfig.node.json b/plugins/subspace_storage/tsconfig.node.json new file mode 100644 index 00000000..b6197500 --- /dev/null +++ b/plugins/subspace_storage/tsconfig.node.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.node.json", + "references": [ + { "path": "../../packages/lib/tsconfig.node.json" }, + ], + "include": ["./**/*.ts"], + "exclude": ["test/*", "./dist/*"], + "compilerOptions": { + "outDir": "dist/node", + }, +} diff --git a/tsconfig.json b/tsconfig.json index fbb6a7ec..e108f361 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,16 +1,16 @@ { "files": [], "references": [ - { "path": "./packages/lib" }, - { "path": "./packages/controller" }, - { "path": "./packages/host" }, - { "path": "./packages/ctl" }, - { "path": "./plugins/global_chat" }, - { "path": "./plugins/inventory_sync" }, - { "path": "./plugins/player_auth" }, - { "path": "./plugins/research_sync" }, - { "path": "./plugins/statistics_exporter" }, - { "path": "./plugins/subspace_storage" }, + { "path": "./packages/lib/tsconfig.node.json" }, + { "path": "./packages/controller/tsconfig.node.json" }, + { "path": "./packages/host/tsconfig.node.json" }, + { "path": "./packages/ctl/tsconfig.node.json" }, + { "path": "./plugins/global_chat/tsconfig.node.json" }, + { "path": "./plugins/inventory_sync/tsconfig.node.json" }, + { "path": "./plugins/player_auth/tsconfig.node.json" }, + { "path": "./plugins/research_sync/tsconfig.node.json" }, + { "path": "./plugins/statistics_exporter/tsconfig.node.json" }, + { "path": "./plugins/subspace_storage/tsconfig.node.json" }, { "path": "./packages/lib/tsconfig.browser.json" }, { "path": "./packages/controller/tsconfig.browser.json" }, { "path": "./packages/web_ui/tsconfig.browser.json" }, From 597d080d71577f9e3ff85e4fd0236afcbf1eff38 Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Wed, 7 Feb 2024 19:29:49 +0100 Subject: [PATCH 5/8] Add tsconfig.json that references both builds Add back unqualified tsconfig.json files to each package that references both the Node.js build and the browser build. This makes tsc --build compile both builds when the variant to do is not specified. --- packages/controller/tsconfig.json | 7 ++++++ packages/ctl/tsconfig.json | 6 +++++ packages/host/tsconfig.json | 6 +++++ packages/lib/tsconfig.json | 7 ++++++ packages/web_ui/tsconfig.json | 6 +++++ plugins/global_chat/tsconfig.json | 7 ++++++ plugins/inventory_sync/tsconfig.json | 7 ++++++ plugins/player_auth/tsconfig.json | 7 ++++++ plugins/research_sync/tsconfig.json | 7 ++++++ plugins/statistics_exporter/tsconfig.json | 7 ++++++ plugins/subspace_storage/tsconfig.json | 7 ++++++ tsconfig.json | 30 +++++++++-------------- 12 files changed, 85 insertions(+), 19 deletions(-) create mode 100644 packages/controller/tsconfig.json create mode 100644 packages/ctl/tsconfig.json create mode 100644 packages/host/tsconfig.json create mode 100644 packages/lib/tsconfig.json create mode 100644 packages/web_ui/tsconfig.json create mode 100644 plugins/global_chat/tsconfig.json create mode 100644 plugins/inventory_sync/tsconfig.json create mode 100644 plugins/player_auth/tsconfig.json create mode 100644 plugins/research_sync/tsconfig.json create mode 100644 plugins/statistics_exporter/tsconfig.json create mode 100644 plugins/subspace_storage/tsconfig.json diff --git a/packages/controller/tsconfig.json b/packages/controller/tsconfig.json new file mode 100644 index 00000000..e074e85f --- /dev/null +++ b/packages/controller/tsconfig.json @@ -0,0 +1,7 @@ +{ + "files": [], + "references": [ + { "path": "./tsconfig.node.json" }, + { "path": "./tsconfig.browser.json" }, + ], +} diff --git a/packages/ctl/tsconfig.json b/packages/ctl/tsconfig.json new file mode 100644 index 00000000..20b10c53 --- /dev/null +++ b/packages/ctl/tsconfig.json @@ -0,0 +1,6 @@ +{ + "files": [], + "references": [ + { "path": "./tsconfig.node.json" }, + ], +} diff --git a/packages/host/tsconfig.json b/packages/host/tsconfig.json new file mode 100644 index 00000000..20b10c53 --- /dev/null +++ b/packages/host/tsconfig.json @@ -0,0 +1,6 @@ +{ + "files": [], + "references": [ + { "path": "./tsconfig.node.json" }, + ], +} diff --git a/packages/lib/tsconfig.json b/packages/lib/tsconfig.json new file mode 100644 index 00000000..e074e85f --- /dev/null +++ b/packages/lib/tsconfig.json @@ -0,0 +1,7 @@ +{ + "files": [], + "references": [ + { "path": "./tsconfig.node.json" }, + { "path": "./tsconfig.browser.json" }, + ], +} diff --git a/packages/web_ui/tsconfig.json b/packages/web_ui/tsconfig.json new file mode 100644 index 00000000..d96583bf --- /dev/null +++ b/packages/web_ui/tsconfig.json @@ -0,0 +1,6 @@ +{ + "files": [], + "references": [ + { "path": "./tsconfig.browser.json" }, + ], +} diff --git a/plugins/global_chat/tsconfig.json b/plugins/global_chat/tsconfig.json new file mode 100644 index 00000000..e074e85f --- /dev/null +++ b/plugins/global_chat/tsconfig.json @@ -0,0 +1,7 @@ +{ + "files": [], + "references": [ + { "path": "./tsconfig.node.json" }, + { "path": "./tsconfig.browser.json" }, + ], +} diff --git a/plugins/inventory_sync/tsconfig.json b/plugins/inventory_sync/tsconfig.json new file mode 100644 index 00000000..e074e85f --- /dev/null +++ b/plugins/inventory_sync/tsconfig.json @@ -0,0 +1,7 @@ +{ + "files": [], + "references": [ + { "path": "./tsconfig.node.json" }, + { "path": "./tsconfig.browser.json" }, + ], +} diff --git a/plugins/player_auth/tsconfig.json b/plugins/player_auth/tsconfig.json new file mode 100644 index 00000000..e074e85f --- /dev/null +++ b/plugins/player_auth/tsconfig.json @@ -0,0 +1,7 @@ +{ + "files": [], + "references": [ + { "path": "./tsconfig.node.json" }, + { "path": "./tsconfig.browser.json" }, + ], +} diff --git a/plugins/research_sync/tsconfig.json b/plugins/research_sync/tsconfig.json new file mode 100644 index 00000000..e074e85f --- /dev/null +++ b/plugins/research_sync/tsconfig.json @@ -0,0 +1,7 @@ +{ + "files": [], + "references": [ + { "path": "./tsconfig.node.json" }, + { "path": "./tsconfig.browser.json" }, + ], +} diff --git a/plugins/statistics_exporter/tsconfig.json b/plugins/statistics_exporter/tsconfig.json new file mode 100644 index 00000000..e074e85f --- /dev/null +++ b/plugins/statistics_exporter/tsconfig.json @@ -0,0 +1,7 @@ +{ + "files": [], + "references": [ + { "path": "./tsconfig.node.json" }, + { "path": "./tsconfig.browser.json" }, + ], +} diff --git a/plugins/subspace_storage/tsconfig.json b/plugins/subspace_storage/tsconfig.json new file mode 100644 index 00000000..e074e85f --- /dev/null +++ b/plugins/subspace_storage/tsconfig.json @@ -0,0 +1,7 @@ +{ + "files": [], + "references": [ + { "path": "./tsconfig.node.json" }, + { "path": "./tsconfig.browser.json" }, + ], +} diff --git a/tsconfig.json b/tsconfig.json index e108f361..df2b7168 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,24 +1,16 @@ { "files": [], "references": [ - { "path": "./packages/lib/tsconfig.node.json" }, - { "path": "./packages/controller/tsconfig.node.json" }, - { "path": "./packages/host/tsconfig.node.json" }, - { "path": "./packages/ctl/tsconfig.node.json" }, - { "path": "./plugins/global_chat/tsconfig.node.json" }, - { "path": "./plugins/inventory_sync/tsconfig.node.json" }, - { "path": "./plugins/player_auth/tsconfig.node.json" }, - { "path": "./plugins/research_sync/tsconfig.node.json" }, - { "path": "./plugins/statistics_exporter/tsconfig.node.json" }, - { "path": "./plugins/subspace_storage/tsconfig.node.json" }, - { "path": "./packages/lib/tsconfig.browser.json" }, - { "path": "./packages/controller/tsconfig.browser.json" }, - { "path": "./packages/web_ui/tsconfig.browser.json" }, - { "path": "./plugins/global_chat/tsconfig.browser.json" }, - { "path": "./plugins/inventory_sync/tsconfig.browser.json" }, - { "path": "./plugins/player_auth/tsconfig.browser.json" }, - { "path": "./plugins/research_sync/tsconfig.browser.json" }, - { "path": "./plugins/statistics_exporter/tsconfig.browser.json" }, - { "path": "./plugins/subspace_storage/tsconfig.browser.json" }, + { "path": "./packages/lib/" }, + { "path": "./packages/controller/" }, + { "path": "./packages/host/" }, + { "path": "./packages/ctl/" }, + { "path": "./packages/web_ui/" }, + { "path": "./plugins/global_chat/" }, + { "path": "./plugins/inventory_sync/" }, + { "path": "./plugins/player_auth/" }, + { "path": "./plugins/research_sync/" }, + { "path": "./plugins/statistics_exporter/" }, + { "path": "./plugins/subspace_storage/" }, ], } From ebb93ada9453b08ff6f836cbf129bb8b41c1bdb7 Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Thu, 8 Feb 2024 03:02:35 +0100 Subject: [PATCH 6/8] Replace babel and ts-loader with swc Build and minify the Web UI using swc instead of babel, tsc and terser. This results in a significant speedup of the build process as it skips checking types and uses native code to do the minification. To prevent accidental type errors being introduced the TypeScript compiler is still used to perform type checking on the Web UI files. Due to peer dependency resolving shenanigans the swc/core package had to be added to the workspace, controller and web_ui to avoid pnpm creating a duplicate install of webpack that break the build. --- .npmrc | 1 + package.json | 1 + packages/controller/package.json | 1 + packages/web_ui/package.json | 6 ++--- packages/web_ui/webpack.common.js | 45 ++++++++++++++++++++----------- tsconfig.browser.json | 2 +- 6 files changed, 36 insertions(+), 20 deletions(-) create mode 100644 .npmrc diff --git a/.npmrc b/.npmrc new file mode 100644 index 00000000..f301fedf --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +auto-install-peers=false diff --git a/package.json b/package.json index 336edd58..fbf50444 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "@clusterio/ctl": "workspace:*", "@clusterio/host": "workspace:*", "@clusterio/lib": "workspace:*", + "@swc/core": "^1.4.0", "@typescript-eslint/eslint-plugin": "^6.4.1", "@typescript-eslint/parser": "^6.4.1", "eslint": "^8.45.0", diff --git a/packages/controller/package.json b/packages/controller/package.json index 7446edbd..97fd5f36 100644 --- a/packages/controller/package.json +++ b/packages/controller/package.json @@ -36,6 +36,7 @@ }, "devDependencies": { "@clusterio/web_ui": "^2.0.0-alpha.16", + "@swc/core": "^1.4.0", "@types/busboy": "^1.5.0", "@types/compression": "^1.7.2", "@types/express": "^4.17.17", diff --git a/packages/web_ui/package.json b/packages/web_ui/package.json index fb77d82d..a1f2575a 100644 --- a/packages/web_ui/package.json +++ b/packages/web_ui/package.json @@ -17,12 +17,10 @@ }, "dependencies": { "@ant-design/icons": "^5.1.4", - "@babel/core": "^7.22.9", - "@babel/preset-react": "^7.22.5", "@clusterio/lib": "^2.0.0-alpha.16", + "@swc/core": "^1.4.0", "antd": "^5.13.0", "assert": "^2.0.0", - "babel-loader": "^9.1.3", "browserify-zlib": "^0.2.0", "buffer": "^6.0.3", "clean-webpack-plugin": "^4.0.0", @@ -39,8 +37,8 @@ "react-router-dom": "^6.14.2", "stream-browserify": "^3.0.0", "style-loader": "^3.3.3", + "swc-loader": "^0.2.6", "terser-webpack-plugin": "^5.3.9", - "ts-loader": "^9.4.4", "typescript": "^5.1.6", "util": "^0.12.5", "webpack": "^5.88.2", diff --git a/packages/web_ui/webpack.common.js b/packages/web_ui/webpack.common.js index 99825c4b..73cae8e8 100644 --- a/packages/web_ui/webpack.common.js +++ b/packages/web_ui/webpack.common.js @@ -65,32 +65,47 @@ module.exports = (env = {}) => ({ }, ], }, - { - test: /\.js$/, - resolve: { - // XXX Required due to bug in babel-runtime - // see: https://github.com/babel/babel/issues/12058 - fullySpecified: false, - }, - }, { test: /\.tsx?$/, exclude: /node_modules/, use: { - loader: require.resolve("ts-loader"), + loader: require.resolve("swc-loader"), options: { - configFile: "tsconfig.browser.json", - projectReferences: true, + sourceMaps: true, + jsc: { + parser: { + syntax: "typescript", + tsx: true, + }, + target: "es2022", + transform: { + react: { + runtime: "automatic", + }, + }, + }, }, }, }, { - test: /\.jsx$/, + test: /\.jsx?$/, exclude: /node_modules/, use: { - loader: require.resolve("babel-loader"), + loader: require.resolve("swc-loader"), options: { - presets: [require.resolve("@babel/preset-react")], + sourceMaps: true, + jsc: { + parser: { + syntax: "ecmascript", + jsx: true, + }, + target: "es2022", + transform: { + react: { + runtime: "automatic", + }, + }, + }, }, }, }, @@ -123,10 +138,10 @@ module.exports = (env = {}) => ({ moduleIds: "deterministic", minimizer: [ new TerserPlugin({ + minify: TerserPlugin.swcMinify, terserOptions: { compress: { keep_classnames: true, - passes: 2, }, mangle: { keep_classnames: true, diff --git a/tsconfig.browser.json b/tsconfig.browser.json index 7edb5691..605c2c61 100644 --- a/tsconfig.browser.json +++ b/tsconfig.browser.json @@ -5,7 +5,7 @@ "module": "es2022", "moduleResolution": "bundler", "target": "es2022", - "jsx": "react", + "jsx": "react-jsx", "noEmitOnError": true, }, } From f70b4f74b160cdbd596ddf7bcac5fcb31bab23e8 Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Thu, 8 Feb 2024 05:23:48 +0100 Subject: [PATCH 7/8] Add watch script to rebuild on changes --- docs/contributing.md | 3 +++ package.json | 1 + 2 files changed, 4 insertions(+) diff --git a/docs/contributing.md b/docs/contributing.md index 44582f4a..eb5b82d1 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -81,6 +81,9 @@ Note that to use `clusterioctl` you will have to create a control config first: Once you've set up the cluster you can use `node packages/controller run` to run the controller and `node packages/host run` to run the host which connects to the controller. +When editing TypeScript files runned on Node.js you need run `pnpm build` in order to compile the files to JavaScript before restarting the controller/host/ctl for changes take effect. +To have TypeScript watch for changes and rebuild immediadly you may run `pnpm watch` instead. + For web development on the controller there are also the following flags: `--dev` - Recompile the `web_ui` package on the fly providing live reloading of it. diff --git a/package.json b/package.json index fbf50444..a5f4a506 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "private": true, "scripts": { "build": "tsc --build", + "watch": "tsc --build --watch", "test": "pnpm run build && mocha --check-leaks -R spec --recursive test \"plugins/*/test/**\"", "fast-test": "FAST_TEST=y pnpm test", "cover": "nyc pnpm test", From e990134b7045cf56947fe2e83dfdf36bb401954f Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Sun, 11 Feb 2024 21:40:32 +0100 Subject: [PATCH 8/8] Use suggested wording in docs/contributing.md Co-authored-by: Cooldude2606 <25043174+Cooldude2606@users.noreply.github.com> --- docs/contributing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/contributing.md b/docs/contributing.md index eb5b82d1..8f1d73fe 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -81,7 +81,7 @@ Note that to use `clusterioctl` you will have to create a control config first: Once you've set up the cluster you can use `node packages/controller run` to run the controller and `node packages/host run` to run the host which connects to the controller. -When editing TypeScript files runned on Node.js you need run `pnpm build` in order to compile the files to JavaScript before restarting the controller/host/ctl for changes take effect. +When editing TypeScript files ran by Node.js you need to run `pnpm build` to compile the files to JavaScript before restarting the controller/host/ctl for changes take effect. To have TypeScript watch for changes and rebuild immediadly you may run `pnpm watch` instead. For web development on the controller there are also the following flags: