fix(core): allow preserve jsx in bundleless mode to coexist with bundle mode#1523
Merged
Timeless0911 merged 1 commit intomainfrom Mar 9, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where the rslib:bundle plugin incorrectly prevented bundleless mode (with jsx: 'preserve') from coexisting alongside bundle mode in the same rslib build process. The root cause was that the plugin used the onBeforeBuild hook, which inspected all bundler configs globally, rather than only the config for the current environment.
Changes:
- Switched the
BundlePluginfrom usingonBeforeBuild(which checks allbundlerConfigs) toonBeforeEnvironmentCompile(which checks only the current environment'sbundlerConfig), so the JSX preservation check is scoped to the bundle-mode environment only. - Added a new integration test fixture (
preserve-jsx-with-environment) and test case to verify thatbundle: falsewith JSX preservation can coexist alongsidebundle: truewithout errors.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
packages/core/src/config.ts |
Replaced onBeforeBuild with onBeforeEnvironmentCompile in BundlePlugin to scope the JSX check to the current environment. |
tests/integration/preserve-jsx/index.test.ts |
Added test verifying bundleless JSX preservation coexists with bundle mode without errors. |
tests/integration/preserve-jsx/preserve-jsx-with-environment/rslib.config.ts |
New fixture config with two lib entries: one bundle: true, one bundle: false with JSX preserve. |
tests/integration/preserve-jsx/preserve-jsx-with-environment/src/index.tsx |
Minimal source file for the new test fixture. |
tests/integration/preserve-jsx/preserve-jsx-with-environment/tsconfig.json |
TypeScript config for the new test fixture. |
tests/integration/preserve-jsx/preserve-jsx-with-environment/package.json |
Package metadata for the new test fixture. |
pnpm-lock.yaml |
Registered the new test fixture as a workspace entry. |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
fi3ework
approved these changes
Mar 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Previously, the
rslib:bundleplugin checked allbundlerConfigsinside theonBeforeBuildhook to see if any of them hadjsx: true, throwing an error if they did. This prevented bundleless mode (which can preserve JSX) from being used in the same process alongside bundle mode (which does not support preserving JSX), even if bundle mode wasn't the environment preserving JSX.This change updates the plugin to use
onBeforeEnvironmentCompile, inspecting only thebundlerConfigof the current environment. This allowsbundle: falseandbundle: trueconfigurations to coexist even whenjsx: 'preserve'is set in the bundleless configuration.Related Links
Checklist