From c3d78a8cb87c472cb663a710334c92cf055117f5 Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Sat, 26 Aug 2023 16:23:24 +0200 Subject: [PATCH] Organise TSConfig files using inheritance Removed duplicated TSConfig options by using a shared base config which all plugins inherit shared settings from. --- packages/controller/tsconfig.json | 20 +++++--------------- packages/ctl/tsconfig.json | 22 +++++----------------- packages/host/tsconfig.json | 22 +++++----------------- packages/lib/build_mod.d.ts | 10 ++++++++++ packages/lib/tsconfig.json | 22 ++++++---------------- plugins/global_chat/tsconfig.json | 12 ++---------- plugins/inventory_sync/tsconfig.json | 13 ++----------- plugins/player_auth/tsconfig.json | 12 ++---------- plugins/research_sync/tsconfig.json | 12 ++---------- plugins/statistics_exporter/tsconfig.json | 12 ++---------- plugins/subspace_storage/tsconfig.json | 12 ++---------- tsconfig.base.json | 12 ++++++++++++ tsconfig.node.json | 12 ++++++++++++ 13 files changed, 67 insertions(+), 126 deletions(-) create mode 100644 packages/lib/build_mod.d.ts create mode 100644 tsconfig.base.json create mode 100644 tsconfig.node.json diff --git a/packages/controller/tsconfig.json b/packages/controller/tsconfig.json index a0c4cf46..58902a7a 100644 --- a/packages/controller/tsconfig.json +++ b/packages/controller/tsconfig.json @@ -1,17 +1,7 @@ { - "include": ["controller.ts", "package.json", "src/**/*.ts"], - "compilerOptions": { - "lib": ["es2023"], - "module": "commonjs", - "target": "es2022", - "rootDir": ".", - "outDir": "dist/controller", - "composite": true, - "sourceMap": true, - "strict": true, - "alwaysStrict": true, - "esModuleInterop": true, - "skipLibCheck": true, - "resolveJsonModule": true - } + "extends": "../../tsconfig.node.json", + "include": ["controller.ts", "package.json", "src/**/*.ts"], + "compilerOptions": { + "outDir": "dist/controller", + }, } diff --git a/packages/ctl/tsconfig.json b/packages/ctl/tsconfig.json index b3104ba5..eccb6bdc 100644 --- a/packages/ctl/tsconfig.json +++ b/packages/ctl/tsconfig.json @@ -1,19 +1,7 @@ { - "include": ["package.json", "ctl.ts", "src/**/*.ts"], - "compilerOptions": { - "lib": ["es2023"], - "module": "commonjs", - "target": "es2022", - "rootDir": ".", - "outDir": "dist", - "composite": true, - "sourceMap": true, - "strict": true, - "alwaysStrict": true, - "allowJs": true, - "checkJs": false, - "resolveJsonModule": true, - "esModuleInterop": true, - "skipLibCheck": true - } + "extends": "../../tsconfig.node.json", + "include": ["package.json", "ctl.ts", "src/**/*.ts"], + "compilerOptions": { + "outDir": "dist", + }, } diff --git a/packages/host/tsconfig.json b/packages/host/tsconfig.json index 0d450dbb..a7c73ecc 100644 --- a/packages/host/tsconfig.json +++ b/packages/host/tsconfig.json @@ -1,19 +1,7 @@ { - "include": ["host.ts", "package.json", "src/**/*.ts", "src/**/*.js"], - "compilerOptions": { - "lib": ["es2023"], - "module": "commonjs", - "target": "es2022", - "rootDir": ".", - "outDir": "dist", - "composite": true, - "sourceMap": true, - "strict": true, - "alwaysStrict": true, - "allowJs": true, - "checkJs": false, - "resolveJsonModule": true, - "esModuleInterop": true, - "skipLibCheck": true - } + "extends": "../../tsconfig.node.json", + "include": ["host.ts", "package.json", "src/**/*.ts", "src/**/*.js"], + "compilerOptions": { + "outDir": "dist", + }, } diff --git a/packages/lib/build_mod.d.ts b/packages/lib/build_mod.d.ts new file mode 100644 index 00000000..064d7e81 --- /dev/null +++ b/packages/lib/build_mod.d.ts @@ -0,0 +1,10 @@ +export interface BuildArgs { + factorioVersion?: string; + dependencies?: Record; + clean?: boolean; + pack?: boolean; + build?: boolean; + outputDir: string; + sourceDir: string; +}; +export function build(args: BuildArgs): Promise; diff --git a/packages/lib/tsconfig.json b/packages/lib/tsconfig.json index f4ae38e6..e64350e1 100644 --- a/packages/lib/tsconfig.json +++ b/packages/lib/tsconfig.json @@ -1,18 +1,8 @@ { - "include": ["index.ts", "build_mod.js", "src/**/*.ts", "src/**/*.js"], - "compilerOptions": { - "lib": ["es2023"], - "module": "commonjs", - "target": "es2022", - "rootDir": ".", - "outDir": "dist", - "composite": true, - "sourceMap": true, - "strict": true, - "alwaysStrict": true, - "allowJs": true, - "checkJs": false, - "esModuleInterop": true, - "skipLibCheck": true - } + "extends": "../../tsconfig.node.json", + "include": ["index.ts", "build_mod.js", "src/**/*.ts", "src/**/*.js"], + "compilerOptions": { + "outDir": "dist", + "allowJs": true, + }, } diff --git a/plugins/global_chat/tsconfig.json b/plugins/global_chat/tsconfig.json index 5408f6b2..d930730d 100644 --- a/plugins/global_chat/tsconfig.json +++ b/plugins/global_chat/tsconfig.json @@ -1,16 +1,8 @@ { + "extends": "../../tsconfig.node.json", "include": ["./**/*.ts"], "exclude": ["test/*", "./dist/*"], "compilerOptions": { - "lib": ["es2023"], - "module": "commonjs", - "target": "es2022", - "rootDir": ".", "outDir": "dist/plugin", - "sourceMap": true, - "strict": true, - "alwaysStrict": true, - "esModuleInterop": true, - "skipLibCheck": true - } + }, } diff --git a/plugins/inventory_sync/tsconfig.json b/plugins/inventory_sync/tsconfig.json index cf0cf5e6..d930730d 100644 --- a/plugins/inventory_sync/tsconfig.json +++ b/plugins/inventory_sync/tsconfig.json @@ -1,17 +1,8 @@ { + "extends": "../../tsconfig.node.json", "include": ["./**/*.ts"], "exclude": ["test/*", "./dist/*"], "compilerOptions": { - "lib": ["es2023"], - "module": "commonjs", - "target": "es2022", - "rootDir": ".", "outDir": "dist/plugin", - "sourceMap": true, - "strict": true, - "alwaysStrict": true, - "esModuleInterop": true, - "resolveJsonModule": true, - "skipLibCheck": true - } + }, } diff --git a/plugins/player_auth/tsconfig.json b/plugins/player_auth/tsconfig.json index 5408f6b2..d930730d 100644 --- a/plugins/player_auth/tsconfig.json +++ b/plugins/player_auth/tsconfig.json @@ -1,16 +1,8 @@ { + "extends": "../../tsconfig.node.json", "include": ["./**/*.ts"], "exclude": ["test/*", "./dist/*"], "compilerOptions": { - "lib": ["es2023"], - "module": "commonjs", - "target": "es2022", - "rootDir": ".", "outDir": "dist/plugin", - "sourceMap": true, - "strict": true, - "alwaysStrict": true, - "esModuleInterop": true, - "skipLibCheck": true - } + }, } diff --git a/plugins/research_sync/tsconfig.json b/plugins/research_sync/tsconfig.json index 5408f6b2..d930730d 100644 --- a/plugins/research_sync/tsconfig.json +++ b/plugins/research_sync/tsconfig.json @@ -1,16 +1,8 @@ { + "extends": "../../tsconfig.node.json", "include": ["./**/*.ts"], "exclude": ["test/*", "./dist/*"], "compilerOptions": { - "lib": ["es2023"], - "module": "commonjs", - "target": "es2022", - "rootDir": ".", "outDir": "dist/plugin", - "sourceMap": true, - "strict": true, - "alwaysStrict": true, - "esModuleInterop": true, - "skipLibCheck": true - } + }, } diff --git a/plugins/statistics_exporter/tsconfig.json b/plugins/statistics_exporter/tsconfig.json index 5408f6b2..d930730d 100644 --- a/plugins/statistics_exporter/tsconfig.json +++ b/plugins/statistics_exporter/tsconfig.json @@ -1,16 +1,8 @@ { + "extends": "../../tsconfig.node.json", "include": ["./**/*.ts"], "exclude": ["test/*", "./dist/*"], "compilerOptions": { - "lib": ["es2023"], - "module": "commonjs", - "target": "es2022", - "rootDir": ".", "outDir": "dist/plugin", - "sourceMap": true, - "strict": true, - "alwaysStrict": true, - "esModuleInterop": true, - "skipLibCheck": true - } + }, } diff --git a/plugins/subspace_storage/tsconfig.json b/plugins/subspace_storage/tsconfig.json index 5408f6b2..d930730d 100644 --- a/plugins/subspace_storage/tsconfig.json +++ b/plugins/subspace_storage/tsconfig.json @@ -1,16 +1,8 @@ { + "extends": "../../tsconfig.node.json", "include": ["./**/*.ts"], "exclude": ["test/*", "./dist/*"], "compilerOptions": { - "lib": ["es2023"], - "module": "commonjs", - "target": "es2022", - "rootDir": ".", "outDir": "dist/plugin", - "sourceMap": true, - "strict": true, - "alwaysStrict": true, - "esModuleInterop": true, - "skipLibCheck": true - } + }, } diff --git a/tsconfig.base.json b/tsconfig.base.json new file mode 100644 index 00000000..02016d99 --- /dev/null +++ b/tsconfig.base.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "composite": true, + "declaration": true, + "declarationMap": true, + "incremental": true, + "sourceMap": true, + "strict": true, + "resolveJsonModule": true, + "skipLibCheck": true, + }, +} diff --git a/tsconfig.node.json b/tsconfig.node.json new file mode 100644 index 00000000..daa42608 --- /dev/null +++ b/tsconfig.node.json @@ -0,0 +1,12 @@ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "lib": ["es2023"], + "module": "node16", + "moduleResolution": "node16", + "target": "es2022", + "esModuleInterop": true, + "alwaysStrict": true, + "forceConsistentCasingInFileNames": true, + }, +}