Skip to content

fix(core): allow preserve jsx in bundleless mode to coexist with bundle mode#1523

Merged
Timeless0911 merged 1 commit intomainfrom
fix/core-preserve-jsx-environment
Mar 9, 2026
Merged

fix(core): allow preserve jsx in bundleless mode to coexist with bundle mode#1523
Timeless0911 merged 1 commit intomainfrom
fix/core-preserve-jsx-environment

Conversation

@Timeless0911
Copy link
Copy Markdown
Contributor

Summary

Previously, the rslib:bundle plugin checked all bundlerConfigs inside the onBeforeBuild hook to see if any of them had jsx: 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 the bundlerConfig of the current environment. This allows bundle: false and bundle: true configurations to coexist even when jsx: 'preserve' is set in the bundleless configuration.

Related Links

Checklist

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

Copilot AI review requested due to automatic review settings March 9, 2026 08:17
Copy link
Copy Markdown
Contributor

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 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 BundlePlugin from using onBeforeBuild (which checks all bundlerConfigs) to onBeforeEnvironmentCompile (which checks only the current environment's bundlerConfig), 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 that bundle: false with JSX preservation can coexist alongside bundle: true without 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

@Timeless0911 Timeless0911 merged commit df3fada into main Mar 9, 2026
12 checks passed
@Timeless0911 Timeless0911 deleted the fix/core-preserve-jsx-environment branch March 9, 2026 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants