-
-
Notifications
You must be signed in to change notification settings - Fork 785
feat: parser support jsx #11664
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: parser support jsx #11664
Conversation
✅ Deploy Preview for rspack canceled.
|
📦 Binary Size-limit
❌ Size increased by 2.63KB from 47.43MB to 47.44MB (⬆️0.01%) |
CodSpeed Performance ReportMerging #11664 will not alter performanceComparing 🎉 Hooray!
|
7247cda
to
e740e6e
Compare
crates/rspack_plugin_javascript/src/parser_and_generator/mod.rs
Outdated
Show resolved
Hide resolved
c9e8e5b
to
f6d2f3d
Compare
4e6ee03
to
363b710
Compare
363b710
to
2e1f1a2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds JSX parsing support to Rspack by introducing a new jsx
parser option that enables JSX syntax parsing while preserving JSX in the output. This supports the JSX "preserve" mode where JSX syntax is parsed but not transformed.
Key changes:
- Added
jsx: boolean
option to JavaScript parser configuration - Implemented JSX AST walking functionality in the dependency parser
- Updated SWC loader schema to support "preserve" runtime option
Reviewed Changes
Copilot reviewed 18 out of 19 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
packages/rspack/src/config/types.ts | Added jsx boolean option to JavascriptParserOptions type |
packages/rspack/src/config/defaults.ts | Set jsx default value to false |
packages/rspack/src/schema/config.ts | Added jsx schema validation |
packages/rspack/src/schema/loaders.ts | Added "preserve" to SWC React runtime enum |
crates/rspack_plugin_javascript/src/visitors/dependency/parser/walk.rs | Implemented JSX AST walking methods |
crates/rspack_plugin_javascript/src/parser_and_generator/mod.rs | Enabled jsx in SWC parser syntax |
crates/rspack_core/src/concatenated_module.rs | Added jsx support for concatenated modules |
tests/rspack-test/configCases/parsing/jsx-enabled/ | Added comprehensive test cases for JSX parsing |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick, the rest looks good to me
Summary
support JSX
preserve
for Rslib.limitation:
how Rslib will integrate with this JSX preserve:
swcReactOptions.runtime
is set topreserve
, addjsx: true
to the parserswcReactOptions.runtime
is preserve, bundling should be prohibited (swc
now supports minify JSX)this PR is the first step.
Related links
Checklist