Can nodejs
( version > 23) also run *.tsx
("jsx": "react"
) files natively?
#57070
Replies: 1 comment 4 replies
-
The experimental Node option uses a TypeScript wrapper called Amaro (https://github.com/nodejs/amaro). However, this is an example for SWC, not Amaro, because Amaro is actually a development of the TypeScript parser SWC (https://swc.rs/) for WebAssembly. In the SWC documentation there is a mention of support for JSX (https://swc.rs/blog/swc-1#what-can-swc-do) so theoretically Node.js v23 should support transpilation of JSX, as well as TSX. You may also be interested in the NanoJSX library (https://nanojsx.io/), which is a lightweight library for rendering JSX on the server side, it is easy to implement. |
Beta Was this translation helpful? Give feedback.
-
I found out at https://nodejs.org/en/learn/typescript/run-natively that starting with version 23, nodejs can run TypeScript (
*.ts
) scripts natively without prior transpilation.I wonder, how can I make it run/import
*.tsx
files natively? Is it supported? I realize that it's actually some mixture of TypeScript and JSX. How would you recommend running on nodejs TypeScript scripts importing stuff from*.tsx
companion files (for server-side SSG-like rendering using https://github.com/facebook/lexical).tsconfig.json
might contain"jsx" : "react"
, what should be the equivalent for native nodejs?Thanks!
Beta Was this translation helpful? Give feedback.
All reactions