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: docs/configuration-options/index.md
+19-19Lines changed: 19 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -204,9 +204,9 @@ type JsxOptions =
204
204
};
205
205
```
206
206
207
-
Allows Rollup to process JSX syntax to either preserve or transform it depending on the [`jsx.mode`](#jsx-mode). If set to `false`, an error will be thrown if JSX syntax is encountered. You may also choose a preset that will set all options together:
-`"react"`: For transpiling JSX to`React.createElement`calls, where `React`is the default import from `"react"`. This is similar to setting `"jsx": "react"`in TypeScript compiler options.
@@ -215,7 +215,7 @@ Allows Rollup to process JSX syntax to either preserve or transform it depending
215
215
importSource:'react'
216
216
});
217
217
```
218
-
-`"react-jsx"`: This will use the new optimized React transformation introduced with React 17 and is similar to setting `"jsx": "react-jsx"` in TypeScript compiler options.
@@ -224,7 +224,7 @@ Allows Rollup to process JSX syntax to either preserve or transform it depending
224
224
jsxImportSource:'react/jsx-runtime'
225
225
});
226
226
```
227
-
-`"preserve"`: This will preserve JSX in the output. This will still tree-shake unused JSX code and may rename JSX identifiers if there are conflicts in the output.
@@ -251,10 +251,10 @@ Allows Rollup to process JSX syntax to either preserve or transform it depending
251
251
| CLI: |`--jsx.mode <mode>`|
252
252
| 默认: |`"classic"`|
253
253
254
-
This will determine how JSX is processed:
254
+
该选项将决定如何处理 JSX:
255
255
256
-
-`"preserve"`: Will keep JSX syntax in the output.
257
-
-`"classic"`: This will perform a JSX transformation as it is needed by older React versions or other frameworks like for instance [Preact](https://preactjs.com). As an example, here is how you would configure jsx for Preact:
-`"automatic"`: This will perform a JSX transformation using the [new JSX transform](https://legacy.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html)introduced with React 17. In this mode, Rollup will try to import helpers from [`jsx.jsxImportSource`](#jsx-jsximportsource)to transform JSX. As there are certain edge cases, this mode may still fall back to using the classic transformations when [using the `key`property together with spread attributes](https://github.com/facebook/react/issues/20031#issuecomment-710346866). To this end, you can still specify `jsx.importSource`, `jsx.factory`, and`jsx.fragment`to configure classic mode.
@@ -286,9 +286,9 @@ This will determine how JSX is processed:
286
286
| CLI: |`--jsx.factory <factory>`|
287
287
| 默认: |`"React.createElement"` or `null`|
288
288
289
-
The function Rollup uses to create JSX elements in `"classic"`mode or as a fallback in `"automatic"`mode. This is usually`React.createElement` for React or `h` for other frameworks. In `"preserve"`mode, this will ensure that the factory is in scope if [`jsx.importSource`](#jsx-importsource) is specified, or otherwise that a global variable of the same name would not be overridden by local variables. Only in `"preserve"`mode it is possible to set this value to `null`, in which case Rollup will not take care to keep any particular factory function in scope.
If the value contains a `"."` like `React.createElement` and an `jsx.importSource` is specified, Rollup will assume that the left part, e.g. `React`, refers to the default export of the `jsx.importSource`. Otherwise, Rollup assumes it is a named export.
@@ -298,9 +298,9 @@ If the value contains a `"."` like `React.createElement` and an `jsx.importSourc
298
298
| CLI: |`--jsx.fragment <fragment>`|
299
299
| 默认: |`"React.Fragment"` or `null`|
300
300
301
-
The element function Rollup uses to create JSX fragments. This is usually `React.Fragment` for React or `Fragment` for other frameworks. In `"preserve"`mode, this will ensure that the fragment is in scope if [`jsx.importSource`](#jsx-importsource) is specified, or otherwise that a global variable of the same name would not be overridden by local variables. Only in `"preserve"`mode it is possible to set this value to `null`, in which case Rollup will not take care to keep any particular fragment function in scope.
If the value contains a `"."` like `React.Fragment` and an `jsx.importSource` is specified, Rollup will assume that the left part, e.g. `React`, refers to the default export of the `jsx.importSource`. Otherwise, Rollup assumes it is a named export.
@@ -310,7 +310,7 @@ If the value contains a `"."` like `React.Fragment` and an `jsx.importSource` is
310
310
| CLI: |`--jsx.importSource <library>`|
311
311
| 默认: |`null`|
312
312
313
-
Where to import the element factory function and/or the fragment element from. If left to `null`, Rollup will assume that [`jsx.factory`](#jsx-factory)and[`jsx.fragment`](#jsx-fragment)refer to global variables and makes sure they are not shadowed by local variables.
@@ -320,7 +320,7 @@ Where to import the element factory function and/or the fragment element from. I
320
320
| CLI: |`--jsx.jsxImportSource <library>`|
321
321
| 默认: |`"react/jsx-runtime"`|
322
322
323
-
When using `"automatic"`mode, this will specify from where to import the `jsx`, `jsxs`and`Fragment`helpers needed for that transformation. It is not possible to get those from a global variable.
0 commit comments