Skip to content

Commit 7d6add0

Browse files
committed
fix(build): replace ts-node with tsx to resolve issues with modules (#1977)
This pull request resolves #1926 and prevents issues like it from happening in the future ## Rationale for this PR This PR changes the TypeScript execution package for use in scripts like `build:registry` from `ts-node` to `tsx`. This is because `ts-node` has many difficult quirks to work through (and is slow). In addition, it also has a difficult to understand error for newcomers that *is* reproducible. ### The ts-node error As shown in #1926, using `ts-node` (specifically in `build:registry`) results in this error: `Unknown file extension ".ts" for /ui/apps/www/scripts/build-registry.ts`. There are many issues in the `ts-node` repository documenting this problem: * TypeStrong/ts-node/issues/1062 * TypeStrong/ts-node/issues/2033 * TypeStrong/ts-node/issues/1997 Switching the typescript-in-node system to `tsx`, which uses esbuild under the hood, resolves this error. This PR shouldn't affect tests, representation, etc. and is merely a change of build tools. There is no urgent need to merge this. I accidentally deleted the head repository on #1937. That will not happen again.
1 parent 222271b commit 7d6add0

File tree

3 files changed

+265
-6
lines changed

3 files changed

+265
-6
lines changed

apps/www/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"scripts": {
66
"dev": "next dev -p 3001",
77
"build": "contentlayer build && pnpm build:registry && next build",
8-
"build:registry": "ts-node --esm --project ./tsconfig.scripts.json ./scripts/build-registry.ts",
9-
"seed:tasks": "ts-node --esm --project ./tsconfig.scripts.json ./app/examples/tasks/data/seed.ts",
8+
"build:registry": "tsx --tsconfig ./tsconfig.scripts.json ./scripts/build-registry.ts",
9+
"seed:tasks": "tsx --tsconfig ./tsconfig.scripts.json ./app/examples/tasks/data/seed.ts",
1010
"start": "next start -p 3001",
1111
"lint": "next lint",
1212
"lint:fix": "next lint --fix",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"pretty-quick": "^3.1.3",
6464
"tailwindcss": "^3.4.0",
6565
"tailwindcss-animate": "^1.0.5",
66-
"ts-node": "^10.9.1",
66+
"tsx": "^4.1.4",
6767
"turbo": "^1.9.9",
6868
"typescript": "^4.9.5",
6969
"vite-tsconfig-paths": "^4.2.0",

0 commit comments

Comments
 (0)