Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use typia with tsx? #1265

Open
victor314159 opened this issue Sep 8, 2024 · 5 comments
Open

How to use typia with tsx? #1265

victor314159 opened this issue Sep 8, 2024 · 5 comments
Assignees
Labels
question Further information is requested

Comments

@victor314159
Copy link

Big fan of typia here, thanks for this amazing lib !

I'm trying to use typiawhen starting my backend in development mode with tsx

I use tsx because it allows very easy hot reloading when developping.

    "scripts": {
        "serve": "tsx watch ./lib/index.ts",
    },

Long story short, typia works fin in production mode (with tsc), but I don't know how to make it work with tsx

Is it possible ?

@samchon
Copy link
Owner

samchon commented Sep 8, 2024

No way, use ts-node instead.

@samchon samchon self-assigned this Sep 8, 2024
@samchon samchon added the question Further information is requested label Sep 8, 2024
@jairmedeiros
Copy link

TypeStrong/ts-node#2133 😭

@victor314159
Copy link
Author

victor314159 commented Sep 9, 2024

This is how I fixed it:

 "serve": "tsx watch --inspect=0.0.0.0:9229 ./lib/index.ts", // stop using tsx
 "serve": "npx concurrently \"tsc --watch\" \"nodemon -L --inspect=0.0.0.0:9229 ./dist/index.js\"", // use tsc --watch option, so Typia works fine

because I'm running in a docker container, the node --watch wouldn't work, so I've used nodemon

Also added it to tsconfig.json (because tsc --wtach wouldn't work otherwise because of the container running on Windows.)

    "watchOptions": {
        "watchFile": "dynamicPriorityPolling"
    }

@douglasg14b
Copy link

douglasg14b commented Sep 25, 2024

ts-node has issues that tsx elegantly solves for. We use tsx almost exclusively due to compatibility & pipeline issues with ts-node which we had to drop support for after a good week of trying to use it.

It's unfortunate if the official stance is that tsx will never be supported because ts-node exists. Despite practical and longevity issues with ts-node 😥


Are there ways to work around this problem? We don't even necessarily need it with watch mode either.


When running vi tsx, we get:

'Internal Server Error: Error on typia.validate(): no transform has been configured. Read and follow https://typia.io/docs/setup please.',

Despite this setup already being completed.


Edit: Looks like TSX cannot use esbuild plugins . It uses esbuild internally, but cannot make use of plugins from the sound of it.

we can't because tsx uses esbuild's Transform API to process TypeScript, which doesn't support plugins.

Edit 2: https://github.com/privatenumber/pkgroll support might be a partial alternative or use case? Looks like it uses rollup and esbuild though :/

@douglasg14b
Copy link

douglasg14b commented Sep 25, 2024

Can we use this lib to instead codegen, and we can just consume that generated code with our normal build tools?

Edit: https://typia.io/docs/setup/#generation

Need a way to ass eslint ignores though, so many any errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants