-
-
Notifications
You must be signed in to change notification settings - Fork 33.5k
Description
What is the problem this feature will solve?
Following up on nodejs/node#56322 and nodejs/node#56392.
JSX and its various flavors have undergone frequent configuration changes since their inception. While supporting JSX without any configuration might seem ideal, it is both impractical and problematic. Just as "type": "module" was introduced to address CommonJS/ESM interoperability, we must continue relying on existing configuration files—tsconfig.json or jsconfig.json—to determine the correct transformation to apply.
The presence or absence of JSX should not rely on node's recent work for supporting typescript.
JSX has multiple targets, primarily react and react-jsx, which produce different outputs from the same input. For example:
<h1>Hello world</h1>-
react-jsximport { jsx as _jsx } from "react/jsx-runtime"; _jsx("h1", { children: "Hello world" });
-
reactOutputimport React from "react"; React.createElement("h1", null, "Hello world");
-
jsxFactory– Specifies the function to replacecreateElementwhen using thereacttarget. For example, settingjsxFactory: 'h'replacesReact.createElementwithh. -
jsxFragmentFactory– Determines the function used for fragments (<></>). If set, fragments will use the specified name instead ofReact.Fragment. -
jsxImportSource– Used with thereact-jsxtarget to change the import source. For example, settingjsxImportSource: 'preact'results in:import { jsx as _jsx } from "preact/jsx-runtime";
Their combination is what is needed for any library that supports JSX, such as Vue.js, Kita, React, Preact, Astro, and others...
Given the diversity of JavaScript frameworks, adopting a default configuration favoring any single framework would inevitably create issues for others.
One alternative is to add fields to package.json to define some JSX settings, eliminating the need for a jsconfig.json or tsconfig.json file. However, rewriting this (ideal or not) standard is not something the community will like.
In the long run, adding support for a native JSX transform function, similar to Deno’s implementation, could significantly enhance Node.js performance in SSR scenarios.
Deno's native transform has demonstrated 7-20× faster rendering times and 50% reduction in garbage collection overhead. Such improvements would benefit SSR frameworks like Next.js, positioning Node.js competitively once again.
What is the feature you are proposing to solve the problem?
I propose that nodejs transform JSX syntax and support .jsx and .tsx files.
What alternatives have you considered?
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Status