Skip to content

Commit

Permalink
fix(build): replace ts-node with tsx to resolve issues with modules (#…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
Gravy59 committed Jan 28, 2024
1 parent 9a9c5b1 commit f3ff4a4
Show file tree
Hide file tree
Showing 3 changed files with 265 additions and 6 deletions.
4 changes: 2 additions & 2 deletions apps/www/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"scripts": {
"dev": "next dev -p 3001",
"build": "contentlayer build && pnpm build:registry && next build",
"build:registry": "ts-node --esm --project ./tsconfig.scripts.json ./scripts/build-registry.ts",
"seed:tasks": "ts-node --esm --project ./tsconfig.scripts.json ./app/examples/tasks/data/seed.ts",
"build:registry": "tsx --tsconfig ./tsconfig.scripts.json ./scripts/build-registry.ts",
"seed:tasks": "tsx --tsconfig ./tsconfig.scripts.json ./app/examples/tasks/data/seed.ts",
"start": "next start -p 3001",
"lint": "next lint",
"lint:fix": "next lint --fix",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"pretty-quick": "^3.1.3",
"tailwindcss": "^3.4.0",
"tailwindcss-animate": "^1.0.5",
"ts-node": "^10.9.1",
"tsx": "^4.1.4",
"turbo": "^1.9.9",
"typescript": "^4.9.5",
"vite-tsconfig-paths": "^4.2.0",
Expand Down
Loading

1 comment on commit f3ff4a4

@vercel
Copy link

@vercel vercel bot commented on f3ff4a4 Jan 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

ui – ./apps/www

ui-git-main-shadcn-pro.vercel.app
ui.shadcn.com
ui-shadcn-pro.vercel.app
example-playground.vercel.app

Please sign in to comment.