Skip to content

Commit 3413fb3

Browse files
authored
refactor: Detach tsconfigs for Jest from the build (#3301)
This pull request refactors TypeScript configuration across several packages to simplify project structure and build scripts. It removes redundant or legacy `tsconfig.node.json` and related files, consolidates configuration into main `tsconfig.json` files, and updates references and build scripts accordingly. The changes aim to reduce duplication, streamline TypeScript project references, and make the build and test processes more maintainable. > [!NOTE] > > In essence, this PR > - Simplifies `build` – `tsc -b` across the board. > - Simplifies `check` – `tsc -p tsconfig.jest.json` > - Drops the Eslint-driven requirement of test files being in package-level `tsconfig.json` files. > 💡 `test/` dirs have their own `tsconfig.json` files that satisfy eslint's project service resolver. > - Renames `tsconfig.node.json` to `tsconfig.json` making it the main entrypoint of each package. > - Drop `references` field from `tsconfig.jest.json` files as these produce a lot of unnecessary noise and we don't "build" through these. > - Make the root `tsconfig.jest.json` disable emitting properly – we \*don't* reference jest tsconfigs anymore! > 💡 Although tsc does not complain, previously this behaviour was against the rules of `composite` tsconfig setup – makes it hard to predict what the outcome is (will it emit, or it won't?). > > It also covers a lot of what the following PRs offer: > - #3271 > - #3272 > - #3273 > - #3274 > - #3275 > - #3276 > - #3277 ### Changes **TypeScript configuration consolidation:** * Removed `tsconfig.node.json` and related files from multiple packages (`autocertifier-server`, `cdn-location`, `cli-tools`), consolidating configuration into main `tsconfig.json` files and updating their `extends`, `include`, and `references` fields for clarity and maintainability. [[1]](diffhunk://#diff-b8ca01c11975250ba2d1cf703ecb4dfb3a3197b14d1e0fb1c92cab47c0f393efL1-L16) [[2]](diffhunk://#diff-829757d9b00ea7fbff093ee2e216391cd3edcd5f46ddf05bde89e75eae6bfe83L1-L12) [[3]](diffhunk://#diff-4e2d6360af04c468b2d5b2f6616a8ddd0c008d6f25cb3173a8b741cd15ec77d3L1-L18) [[4]](diffhunk://#diff-4f7db719f0663c85b00b0dbfb67cd08b73003012b9de614802b30a1490546861L1-L9) [[5]](diffhunk://#diff-6911c66f995472db595934d34bed8bb3b9d4f5f4e8dcef1329a16d498928e684L2-R14) [[6]](diffhunk://#diff-6348cef142feb7833264b39ad43d4ef7281cf1ac9530f0ac807d3e6a547c9795L2-R10) [[7]](diffhunk://#diff-38daa775ecafcf440e7c2b9817052481019197dfba8e0bbb482e7ce5efe0cfafL2-R16) [[8]](diffhunk://#diff-ae13578e8d026eec67d6b00c439076ab2fc27081e16cb0744b996b414ec28a98L12-R12) * Updated `tsconfig.jest.json` files to directly include relevant source, test, and config files, and removed obsolete project references. [[1]](diffhunk://#diff-08758b3945f3c6bf5569734c2c5d0528c21904deef2ca70414543e91107e6af9R4-L7) [[2]](diffhunk://#diff-7b3ee0dcec62b1726878a419c615b3645198209626245d78f996ea5bb2a9ea31R4-L8) [[3]](diffhunk://#diff-198e2b7b2035fa308d0d3c58fddc55ee01229e98c40f7c40ac11cffb40092f83L8-L14) **Build and check script simplification:** * Simplified `check` and `build` scripts in `package.json` files to use the consolidated TypeScript configs, removing redundant or chained TypeScript invocations. [[1]](diffhunk://#diff-50299ff04a4b7e150c72c86a7d621a7a799aa89849e4885c6ac0887af7da9629L22-R22) [[2]](diffhunk://#diff-650e71c74d8235428c25ec35eb19d1ab8daa27dc303d7564f493507a8c011b26L28-R28) [[3]](diffhunk://#diff-2595495f28a036656bd9466e08f5fe32af851fb9bd3465eef7b2c202cd6ff83dL21-R21) [[4]](diffhunk://#diff-48deceddbbe98a41ff1d0f560db132548031fbd96d790c09ffeed924a20e8a05L27-R29) * Updated shell scripts and build commands to no longer rely on removed config files. **Test configuration improvements:** * Added dedicated `test/tsconfig.json` files in several packages to ensure test files are properly included and configured for TypeScript and Jest. [[1]](diffhunk://#diff-99570814e8a6d99b92ce03d11db23716ed24927bbc40da26f16424cb9135917cR1-R6) [[2]](diffhunk://#diff-d33492e918ed4916dd23554eb003330d2983698030d26bbf2667c472e2bb0166R1-R6) Overall, these changes make the TypeScript setup across packages more consistent, easier to understand, and less error-prone.
1 parent 728d1e6 commit 3413fb3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+227
-297
lines changed

packages/autocertifier-client/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
"generated"
1010
],
1111
"references": [
12-
{ "path": "../utils/tsconfig.node.json" }
12+
{ "path": "../utils" }
1313
]
1414
}

packages/autocertifier-server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"author": "Streamr Network AG <[email protected]>",
2626
"scripts": {
2727
"build": "tsc -b",
28-
"check": "tsc -p ./tsconfig.jest.json && tsc --noEmit -p tsconfig.node.json",
28+
"check": "tsc -p tsconfig.jest.json",
2929
"clean": "jest --clearCache || true; rm -rf dist *.tsbuildinfo node_modules/.cache || true",
3030
"eslint": "eslint --cache --cache-location=node_modules/.cache/.eslintcache/ '*/**/*.{js,ts}'",
3131
"test": "jest test/unit test/integration",
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": "../tsconfig.jest.json",
3+
"include": [
4+
"**/*"
5+
]
6+
}
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
{
22
"extends": "../../tsconfig.jest.json",
33
"include": [
4+
"bin",
5+
"src",
46
"test"
5-
],
6-
"references": [
7-
{ "path": "./tsconfig.node.json" }
87
]
98
}
Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
{
2-
"files": [],
2+
"extends": "../../tsconfig.node.json",
33
"compilerOptions": {
4-
"composite": true
4+
"outDir": "dist"
55
},
6+
"include": [
7+
"src",
8+
"bin"
9+
],
610
"references": [
7-
{ "path": "./tsconfig.node.json" },
8-
{ "path": "./tsconfig.jest.json" }
11+
{ "path": "../autocertifier-client" },
12+
{ "path": "../dht" },
13+
{ "path": "../proto-rpc" },
14+
{ "path": "../utils" }
915
]
1016
}

packages/autocertifier-server/tsconfig.node.json

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": "..",
3+
"include": [
4+
"**/*"
5+
]
6+
}

packages/cdn-location/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"author": "Streamr Network AG <[email protected]>",
2020
"scripts": {
2121
"build": "tsc -b",
22-
"check": "tsc -p ./tsconfig.jest.json && tsc --noEmit -p ./tsconfig.node.json && tsc --noEmit -p ./tsconfig.data-generation.json",
22+
"check": "tsc -p tsconfig.jest.json",
2323
"clean": "jest --clearCache || true; rm -rf dist *.tsbuildinfo node_modules/.cache || true",
2424
"eslint": "eslint --cache --cache-location=node_modules/.cache/.eslintcache/ '*/**/*.{js,ts}'",
2525
"test": "jest test/integration",
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": "../tsconfig.jest.json",
3+
"include": [
4+
"**/*"
5+
]
6+
}

packages/cdn-location/tsconfig.data-generation.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)