Skip to content

Commit 6bf0d7b

Browse files
authored
refactor: Define proper package-level tsconfig.json files (#3288)
This pull request updates TypeScript configuration files across multiple packages to use project references instead of extending from `tsconfig.jest.json`. Additionally, it includes minor improvements to the SDK's Karma Webpack configuration and a script invocation in the DHT package. These changes improve TypeScript project structure, build efficiency, and code consistency. ### Changes **TypeScript project configuration updates:** * Replaced `"extends": "./tsconfig.jest.json"` with explicit `files`, `compilerOptions.composite: true`, and `references` to `tsconfig.jest.json` in the `tsconfig.json` files for the following packages: `autocertifier-client`, `autocertifier-server`, `cdn-location`, `cli-tools`, `dht`, `geoip-location`, `node`, `proto-rpc`, `sdk`, `test-utils`, `trackerless-network`, and `utils`. This enables TypeScript project references for better build performance and modularity. **Build and script improvements:** * Updated the DHT postbuild script to run `ts-node` with the `-P tsconfig.node.json` option for package.json rewriting, ensuring the correct TypeScript configuration is used for node scripts. **SDK webpack karma configuration improvements:** * Changed import of `webpack.config` in `webpack-karma.config.ts` to use `import * as defaultConfig` for compatibility. * Replaced usage of `path.resolve` with direct import of `resolve` from `path` – also for compatibility. ### Future * This here is just a rearrangement; prep for future steps. Eventually all key files will become references in package-level `tsconfig.json`. We need to clean them up first.
1 parent c31dbcd commit 6bf0d7b

File tree

14 files changed

+88
-16
lines changed

14 files changed

+88
-16
lines changed
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
{
2-
"extends": "./tsconfig.jest.json"
2+
"files": [],
3+
"compilerOptions": {
4+
"composite": true
5+
},
6+
"references": [
7+
{ "path": "./tsconfig.jest.json" }
8+
]
39
}
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
{
2-
"extends": "./tsconfig.jest.json"
2+
"files": [],
3+
"compilerOptions": {
4+
"composite": true
5+
},
6+
"references": [
7+
{ "path": "./tsconfig.jest.json" }
8+
]
39
}
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
{
2-
"extends": "./tsconfig.jest.json"
2+
"files": [],
3+
"compilerOptions": {
4+
"composite": true
5+
},
6+
"references": [
7+
{ "path": "./tsconfig.jest.json" }
8+
]
39
}

packages/cli-tools/tsconfig.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
{
2-
"extends": "./tsconfig.jest.json"
2+
"files": [],
3+
"compilerOptions": {
4+
"composite": true
5+
},
6+
"references": [
7+
{ "path": "./tsconfig.jest.json" }
8+
]
39
}

packages/dht/scripts/postbuild.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
77
cd "${SCRIPT_DIR}/.."
88

99
# Sanitize the final package.json
10-
npx ts-node scripts/rewrite-package.ts
10+
npx ts-node -P tsconfig.node.json scripts/rewrite-package.ts

packages/dht/tsconfig.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
{
2-
"extends": "./tsconfig.jest.json"
2+
"files": [],
3+
"compilerOptions": {
4+
"composite": true
5+
},
6+
"references": [
7+
{ "path": "./tsconfig.jest.json" }
8+
]
39
}
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
{
2-
"extends": "./tsconfig.jest.json"
2+
"files": [],
3+
"compilerOptions": {
4+
"composite": true
5+
},
6+
"references": [
7+
{ "path": "./tsconfig.jest.json" }
8+
]
39
}

packages/node/tsconfig.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
{
2-
"extends": "./tsconfig.jest.json"
2+
"files": [],
3+
"compilerOptions": {
4+
"composite": true
5+
},
6+
"references": [
7+
{ "path": "./tsconfig.jest.json" }
8+
]
39
}

packages/proto-rpc/tsconfig.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
{
2-
"extends": "./tsconfig.jest.json"
2+
"files": [],
3+
"compilerOptions": {
4+
"composite": true
5+
},
6+
"references": [
7+
{ "path": "./tsconfig.jest.json" }
8+
]
39
}

packages/sdk/tsconfig.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
{
2-
"extends": "./tsconfig.jest.json"
2+
"files": [],
3+
"compilerOptions": {
4+
"composite": true
5+
},
6+
"references": [
7+
{ "path": "./tsconfig.jest.json" }
8+
]
39
}

0 commit comments

Comments
 (0)