Skip to content

Commit 873e2cd

Browse files
authored
docs: document parser jsx option (#11767)
docs: add parser jsx version badge
1 parent 1ceac70 commit 873e2cd

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

website/docs/en/config/module.mdx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,32 @@ Please refer to [inline const example](https://github.com/rspack-contrib/rstack-
713713
This is currently an experimental feature, so you also need to enable [experiments.inlineConst](/config/experiments#experimentstypereexportspresence).
714714
:::
715715
716+
### module.parser.javascript.jsx
717+
718+
<ApiMeta stability={Stability.Experimental} addedVersion="1.5.7" />
719+
720+
<PropertyType type="boolean" defaultValueList={[{ defaultValue: 'false' }]} />
721+
722+
Allow the JavaScript parser to understand JSX syntax so that parsing and minimization can operate on files that keep JSX in the final bundle.
723+
724+
Enable this option when you set the loader's JSX mode to "preserve" and want to defer the actual JSX transform to a later tool (for example, libraries that ship JSX output or rely on a custom JSX runtime).
725+
726+
```js title="rspack.config.mjs"
727+
export default {
728+
module: {
729+
parser: {
730+
javascript: {
731+
jsx: true,
732+
},
733+
},
734+
},
735+
};
736+
```
737+
738+
:::warning
739+
This option is experimental in Rspack and may change or be removed.
740+
:::
741+
716742
### module.parser["javascript/auto"]
717743
718744
Parser options for `javascript/auto` modules, same as the [`javascript` parser options](#moduleparserjavascript).

website/docs/zh/config/module.mdx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,32 @@ export default {
713713
目前仍为实验性功能,需要开启 [experiments.inlineConst](/config/experiments#experimentstypereexportspresence)。
714714
:::
715715
716+
### module.parser.javascript.jsx
717+
718+
<ApiMeta stability={Stability.Experimental} addedVersion="1.5.7" />
719+
720+
<PropertyType type="boolean" defaultValueList={[{ defaultValue: 'false' }]} />
721+
722+
让 JavaScript 解析器能够识别 JSX 语法,这样语法解析和压缩等流程就可以在保留 JSX 的情况下继续工作。
723+
724+
当你在 loader 中将 JSX 的模式设置为 "preserve",希望把 JSX 的转换留给后续工具(例如输出 JSX 的类库或依赖自定义 JSX runtime 的场景)时,可以开启该选项。
725+
726+
```js title="rspack.config.mjs"
727+
export default {
728+
module: {
729+
parser: {
730+
javascript: {
731+
jsx: true,
732+
},
733+
},
734+
},
735+
};
736+
```
737+
738+
:::warning
739+
该选项目前仅在 Rspack 中实验性提供,未来可能调整或移除。
740+
:::
741+
716742
### module.parser["javascript/auto"]
717743
718744
`javascript/auto` 模块的解析器选项,和 [`javascript` 的模块的解析器选项](#moduleparserjavascript)相同。

0 commit comments

Comments
 (0)