From a67a4a41dab8f23aef7ea3723d16f67e242f6d85 Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Sat, 9 Dec 2023 17:18:59 +0100 Subject: [PATCH] Use separate build for web version of lib Use a separate ES Module based build for the web version of the lib package. This fixes the rebuild on watched files changing in lib failing with a TS1479 error. --- packages/controller/tsconfig.web.json | 2 +- packages/lib/.npmignore | 1 + packages/lib/src/ExponentialBackoff.ts | 2 -- packages/lib/tsconfig.web.json | 30 +++++++++++++++++++ packages/web_ui/tsconfig.web.json | 2 +- plugins/global_chat/tsconfig.web.json | 2 +- plugins/inventory_sync/tsconfig.web.json | 2 +- plugins/player_auth/tsconfig.web.json | 2 +- plugins/research_sync/tsconfig.web.json | 2 +- plugins/statistics_exporter/tsconfig.web.json | 2 +- plugins/subspace_storage/tsconfig.web.json | 2 +- tsconfig.json | 1 + 12 files changed, 40 insertions(+), 10 deletions(-) create mode 100644 packages/lib/tsconfig.web.json diff --git a/packages/controller/tsconfig.web.json b/packages/controller/tsconfig.web.json index 01d0c42f..6685a163 100644 --- a/packages/controller/tsconfig.web.json +++ b/packages/controller/tsconfig.web.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.web.json", "references": [ - { "path": "../lib" }, + { "path": "../lib/tsconfig.web.json" }, { "path": "../web_ui/tsconfig.web.json" }, ], "include": [ "web/**/*.tsx", "web/**/*.ts", "package.json" ], diff --git a/packages/lib/.npmignore b/packages/lib/.npmignore index e69de29b..5dfa68f1 100644 --- a/packages/lib/.npmignore +++ b/packages/lib/.npmignore @@ -0,0 +1 @@ +dist/web/build diff --git a/packages/lib/src/ExponentialBackoff.ts b/packages/lib/src/ExponentialBackoff.ts index 1e5550b5..38b13eb9 100644 --- a/packages/lib/src/ExponentialBackoff.ts +++ b/packages/lib/src/ExponentialBackoff.ts @@ -77,5 +77,3 @@ export default class ExponentialBackoff { return Math.random() * this.base * 2 ** this._exp * 1000; } } - -module.exports = ExponentialBackoff; diff --git a/packages/lib/tsconfig.web.json b/packages/lib/tsconfig.web.json new file mode 100644 index 00000000..a4349659 --- /dev/null +++ b/packages/lib/tsconfig.web.json @@ -0,0 +1,30 @@ +{ + "extends": "../../tsconfig.web.json", + "include": [ + "browser.ts", + "package.json", + "./src/api.ts", + "./src/config/*.ts", + "./src/data/*.ts", + "./src/errors.ts", + "./src/factorio/exchange_string.ts", + "./src/helpers.ts", + "./src/hash.ts", + "./src/ini.ts", + "./src/link/*.ts", + "./src/logging.ts", + "./src/permissions.ts", + "./src/prometheus.ts", + "./src/plugin.ts", + "./src/schema.ts", + "./src/subscriptions.ts", + "./src/zip_ops.ts", + "./src/ExponentialBackoff.ts", + "./src/RateLimiter.ts", + "./src/TypedEventEmitter.ts", + ], + "compilerOptions": { + "rootDir": ".", + "outDir": "dist/web/build", + } +} diff --git a/packages/web_ui/tsconfig.web.json b/packages/web_ui/tsconfig.web.json index 3beee793..65754630 100644 --- a/packages/web_ui/tsconfig.web.json +++ b/packages/web_ui/tsconfig.web.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.web.json", "references": [ - { "path": "../lib" }, + { "path": "../lib/tsconfig.web.json" }, ], "include": [ "src/**/*.tsx", "src/**/*.ts", "package.json", "global.d.ts" ], "compilerOptions": { diff --git a/plugins/global_chat/tsconfig.web.json b/plugins/global_chat/tsconfig.web.json index 64a8f2a5..c37f9141 100644 --- a/plugins/global_chat/tsconfig.web.json +++ b/plugins/global_chat/tsconfig.web.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.web.json", "references": [ - { "path": "../../packages/lib" }, + { "path": "../../packages/lib/tsconfig.web.json" }, { "path": "../../packages/web_ui/tsconfig.web.json" }, ], "include": [ "web/**/*.tsx", "web/**/*.ts", "messages.ts", "package.json" ], diff --git a/plugins/inventory_sync/tsconfig.web.json b/plugins/inventory_sync/tsconfig.web.json index 64a8f2a5..c37f9141 100644 --- a/plugins/inventory_sync/tsconfig.web.json +++ b/plugins/inventory_sync/tsconfig.web.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.web.json", "references": [ - { "path": "../../packages/lib" }, + { "path": "../../packages/lib/tsconfig.web.json" }, { "path": "../../packages/web_ui/tsconfig.web.json" }, ], "include": [ "web/**/*.tsx", "web/**/*.ts", "messages.ts", "package.json" ], diff --git a/plugins/player_auth/tsconfig.web.json b/plugins/player_auth/tsconfig.web.json index 64a8f2a5..c37f9141 100644 --- a/plugins/player_auth/tsconfig.web.json +++ b/plugins/player_auth/tsconfig.web.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.web.json", "references": [ - { "path": "../../packages/lib" }, + { "path": "../../packages/lib/tsconfig.web.json" }, { "path": "../../packages/web_ui/tsconfig.web.json" }, ], "include": [ "web/**/*.tsx", "web/**/*.ts", "messages.ts", "package.json" ], diff --git a/plugins/research_sync/tsconfig.web.json b/plugins/research_sync/tsconfig.web.json index 64a8f2a5..c37f9141 100644 --- a/plugins/research_sync/tsconfig.web.json +++ b/plugins/research_sync/tsconfig.web.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.web.json", "references": [ - { "path": "../../packages/lib" }, + { "path": "../../packages/lib/tsconfig.web.json" }, { "path": "../../packages/web_ui/tsconfig.web.json" }, ], "include": [ "web/**/*.tsx", "web/**/*.ts", "messages.ts", "package.json" ], diff --git a/plugins/statistics_exporter/tsconfig.web.json b/plugins/statistics_exporter/tsconfig.web.json index f70c4e0d..decec50c 100644 --- a/plugins/statistics_exporter/tsconfig.web.json +++ b/plugins/statistics_exporter/tsconfig.web.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.web.json", "references": [ - { "path": "../../packages/lib" }, + { "path": "../../packages/lib/tsconfig.web.json" }, { "path": "../../packages/web_ui/tsconfig.web.json" }, ], "include": [ "web/**/*.tsx", "web/**/*.ts", "package.json" ], diff --git a/plugins/subspace_storage/tsconfig.web.json b/plugins/subspace_storage/tsconfig.web.json index 64a8f2a5..c37f9141 100644 --- a/plugins/subspace_storage/tsconfig.web.json +++ b/plugins/subspace_storage/tsconfig.web.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.web.json", "references": [ - { "path": "../../packages/lib" }, + { "path": "../../packages/lib/tsconfig.web.json" }, { "path": "../../packages/web_ui/tsconfig.web.json" }, ], "include": [ "web/**/*.tsx", "web/**/*.ts", "messages.ts", "package.json" ], diff --git a/tsconfig.json b/tsconfig.json index f2af308f..c9f896d7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,6 +2,7 @@ "files": [], "references": [ { "path": "./packages/lib" }, + { "path": "./packages/lib/tsconfig.web.json" }, { "path": "./packages/controller" }, { "path": "./packages/controller/tsconfig.web.json" }, { "path": "./packages/host" },