Skip to content

Conversation

fi3ework
Copy link
Member

@fi3ework fi3ework commented Sep 15, 2025

Summary

support JSX preserve for Rslib.

limitation:

  1. should not be used in bundle mode, although is may work, but never seen such a practice.

how Rslib will integrate with this JSX preserve:

  • rspack: this PR, Add parserOptions for JSX
  • rsbuild-plugin-react: when swcReactOptions.runtime is set to preserve, add jsx: true to the parser
  • Rslib: no action needed, but a restriction can be added: when swcReactOptions.runtime is preserve, bundling should be prohibited (swc now supports minify JSX)

this PR is the first step.

Related links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copy link

netlify bot commented Sep 15, 2025

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit ffedb67
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/68d2ce27a0921c000854f905

@github-actions github-actions bot added release: feature release: feature related release(mr only) team The issue/pr is created by the member of Rspack. labels Sep 15, 2025
Copy link
Contributor

github-actions bot commented Sep 15, 2025

📦 Binary Size-limit

Comparing ffedb67 to fix: correct infrastructureLog type and add documentation (#11742) by neverland

❌ Size increased by 2.63KB from 47.43MB to 47.44MB (⬆️0.01%)

Copy link

codspeed-hq bot commented Sep 15, 2025

CodSpeed Performance Report

Merging #11664 will not alter performance

Comparing jsx-preserve (ffedb67) with main (786ffea)

🎉 Hooray! codspeed-rust just leveled up to 2.7.2!

A heads-up, this is a breaking change and it might affect your current performance baseline a bit. But here's the exciting part - it's packed with new, cool features and promises improved result stability 🥳!
Curious about what's new? Visit our releases page to delve into all the awesome details about this new version.

Summary

✅ 17 untouched

@fi3ework fi3ework force-pushed the jsx-preserve branch 5 times, most recently from 7247cda to e740e6e Compare September 17, 2025 07:49
@fi3ework fi3ework force-pushed the jsx-preserve branch 6 times, most recently from c9e8e5b to f6d2f3d Compare September 17, 2025 16:49
@fi3ework fi3ework force-pushed the jsx-preserve branch 6 times, most recently from 4e6ee03 to 363b710 Compare September 22, 2025 11:00
@fi3ework fi3ework marked this pull request as ready for review September 22, 2025 11:44
@Copilot Copilot AI review requested due to automatic review settings September 22, 2025 11:44
@fi3ework fi3ework requested a review from JSerFeng September 22, 2025 11:44
Copy link
Contributor

@Copilot Copilot AI left a 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.

Copy link
Contributor

@ahabhgk ahabhgk left a 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

@fi3ework fi3ework enabled auto-merge (squash) September 23, 2025 17:00
@fi3ework fi3ework merged commit 228ec1b into main Sep 23, 2025
44 checks passed
@fi3ework fi3ework deleted the jsx-preserve branch September 23, 2025 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release: feature release: feature related release(mr only) team The issue/pr is created by the member of Rspack.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants