You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: website/docs/en/guide/solution/react.mdx
+12-9Lines changed: 12 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,14 +45,16 @@ export default defineConfig({
45
45
46
46
## JSX transform
47
47
48
-
-**Type**:`'automatic' | 'classic' | 'preserve'`
49
-
-**Default**:`'automatic'`
48
+
-**Type:**`'automatic' | 'classic' | 'preserve'`
49
+
-**Default:**`'automatic'`
50
50
51
51
React introduced a [new JSX transform](https://legacy.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html) in version 17. This new transform removes the need to import `React` when using JSX.
52
52
53
-
By default, Rsbuild uses the new JSX transform, which is `runtime: 'automatic'`. It requires at least React `16.14.0` or higher. The `peerDependencies` should be declared as `"react": ">=16.14.0"`.
53
+
By default, Rslib uses the new JSX transform, which is `runtime: 'automatic'`. It requires at least React `16.14.0` or higher and the `peerDependencies` should be specified as `"react": ">=16.14.0"`.
54
54
55
-
To change the JSX transform, you can pass the [swcReactOptions](https://rsbuild.rs/plugins/list/plugin-react#swcreactoptionsruntime) option to the React plugin. For example, to use the classic runtime:
55
+
To change the JSX transform, you can set the [swcReactOptions](https://rsbuild.rs/plugins/list/plugin-react#swcreactoptionsruntime) option in `@rsbuild/plugin-react`.
When you need to keep native JSX in the build output, set the runtime to `'preserve'`. This mode retains JSX syntax so it can be processed later (for example by another bundler).
81
+
When you need to keep native JSX in the build output, you can set the runtime to `'preserve'` to leave JSX syntax unchanged without transforming it, which is useful for subsequent processing by other bundlers.
80
82
81
-
::: warn
83
+
::: warning
82
84
83
-
Because the files stay unbundled, you must switch to bundleless mode by setting `bundle: false`.
85
+
When using `runtime: 'preserve'`, you must set `bundle: false`to enable [bundleless mode](/guide/basic/output-structure#bundle--bundleless) to keep files unbundled.
84
86
85
87
:::
86
88
87
-
To emit `.jsx` files, configure the JS filename template through [output.filename](/config/rsbuild/output#outputfilename)while using the preserve runtime:
89
+
To emit `.jsx` files, you can configure the JS filename template through [output.filename](/config/rsbuild/output#outputfilename)option:
0 commit comments