Skip to content

feat!: upgrade Rsbuild to v2 and deprecate experiments.advancedEsm#1513

Merged
fi3ework merged 5 commits intomainfrom
rsbuild-v2
Mar 4, 2026
Merged

feat!: upgrade Rsbuild to v2 and deprecate experiments.advancedEsm#1513
fi3ework merged 5 commits intomainfrom
rsbuild-v2

Conversation

@Timeless0911
Copy link
Copy Markdown
Contributor

@Timeless0911 Timeless0911 commented Mar 4, 2026

Summary

This PR upgrades Rslib to @rsbuild/core@2.0.0-beta.7 and @rspack/core@2.0.0-beta.5 and aligns @rslib/core with Rsbuild/Rspack 2.0 behavior.

Key updates

  1. Align CSS extract constants and related loader logic with Rspack v2.
  2. Adapt CSS and JS rule handling to Rsbuild v2 chain structure.
  3. Remove entryModuleLoaderRsbuildPlugin and entryModuleLoader, since this workaround is no longer needed in Rspack v2.
  4. Rename type StartServerResult to StartDevServerResult.
  5. Align with Rsbuild/Rspack v2 defaults, including explicitly setting output.module = false for CJS/UMD/IIFE formats.
  6. Change IIFE library type from modern-module to module.

Test/CI adjustments

  • Removed the dedicated integration-advanced-esm CI/test lane because experiments.advancedEsm is now deprecated/no-op and advanced ESM behavior is the default.
  • Removed ADVANCED_ESM-gated branching from integration tests and kept a single baseline expectation.

TODO

Temporarily skip Vue-related coverage during migration since rsbuild-plugin-unplugin-vue does not compatible with Rsbuild v2 now. Vue coverage will be re-enabled in follow-up work.

  • tests/integration/vue ESM suite is explicitly skipped.
  • build:examples excludes @examples/vue-component-*.

Related Links

close: #1497
close: #1453
close: #591

Checklist

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

Breaking changes 🚨

Drop Node.js 18 support

Rslib v0.20 requires Node.js 20.19+ or 22.12+, Node.js 18 is no longer supported.

Rsbuild / Rspack v2

Rslib v0.20 now depends on beta version of @rsbuild/core v2 and @rspack/core v2. If you use custom Rsbuild / Rspack configurations or plugins, you may need to make corresponding adjustments.

See the Rsbuild v2 upgrade guide for all breaking changes.

Deprecate experiments.advancedEsm

experiments.advancedEsm is now deprecated and effectively ignored. Advanced ESM behavior is the default in both bundle and bundleless mode.

What you need to do:

  • Remove experiments.advancedEsm from your config.
  • Verify the output behaviour.

Rename type StartServerResult

The exported type StartServerResult has been renamed to StartDevServerResult.

Copilot AI review requested due to automatic review settings March 4, 2026 11:08
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Mar 4, 2026

Deploying rslib with  Cloudflare Pages  Cloudflare Pages

Latest commit: a1fbb85
Status: ✅  Deploy successful!
Preview URL: https://3401eab6.rslib.pages.dev
Branch Preview URL: https://rsbuild-v2.rslib.pages.dev

View logs

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 upgrades the repo to Rsbuild v2 (@rsbuild/core@2.0.0-beta.7), aligns @rslib/core behavior with Rsbuild 2 defaults (notably ESM output + CSS pipeline), and deprecates lib.experiments.advancedEsm as a no-op.

Changes:

  • Upgrade @rsbuild/core to 2.0.0-beta.7 across packages, examples, and test fixtures; adjust test expectations for new output behavior.
  • Deprecate/remove experiments.advancedEsm usage in config composition, docs, CI lanes, and integration tests.
  • Update library build internals (format composition, entry chunk handling, CSS extract integration) to match Rsbuild/Rspack v2 behavior.

Reviewed changes

Copilot reviewed 79 out of 92 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
website/package.json Pin website to Rsbuild v2 beta.
website/docs/zh/config/lib/format.mdx Remove advanced ESM note; update IIFE library type to module.
website/docs/zh/config/lib/experiments.mdx Document advancedEsm deprecation and version history.
website/docs/en/config/lib/format.mdx Remove advanced ESM note; update IIFE library type to module.
website/docs/en/config/lib/experiments.mdx Document advancedEsm deprecation and version history.
tests/scripts/shared.ts Remove ADVANCED_ESM branching; export BuildResult type.
tests/package.json Drop advanced ESM test script; bump Rsbuild v2 beta.
tests/integration/worker/package.json Set fixture package to ESM (type: module).
tests/integration/vue/index.test.ts Skip Vue ESM suite; refactor to beforeAll and shared results.
tests/integration/umd/rslibBundleFalse.config.mts Add MTS config fixture for UMD bundle=false case.
tests/integration/umd/rslib.config.mts Add MTS config fixture for UMD baseline.
tests/integration/umd/index.test.ts Point bundle=false test to .mts config.
tests/integration/umd-library-name/rslib.config.mts Add UMD name fixtures (string + array).
tests/integration/umd-globals/rslib.config.mts Add externals/globals fixture for UMD.
tests/integration/style/tailwindcss/bundle/package.json Set fixture package to ESM (type: module).
tests/integration/style/tailwindcss/bundle-false/package.json Set fixture package to ESM (type: module).
tests/integration/style/sass/bundle/package.json Set fixture package to ESM (type: module).
tests/integration/style/sass/bundle-false/package.json Set fixture package to ESM (type: module).
tests/integration/style/postcss/bundle/package.json Set fixture package to ESM (type: module).
tests/integration/style/postcss/bundle-false/package.json Set fixture package to ESM (type: module).
tests/integration/style/lightningcss/bundle/package.json Set fixture package to ESM (type: module).
tests/integration/style/lightningcss/bundle-false/package.json Set fixture package to ESM (type: module).
tests/integration/style/css-modules-named/index.test.ts Remove ADVANCED_ESM branching; unify snapshot.
tests/integration/shims/index.test.ts Update expected chunk naming in shims test.
tests/integration/resolve/index.test.ts Remove ADVANCED_ESM branching; unify snapshots.
tests/integration/redirect/jsNotResolved.test.ts Update default export style in snapshots.
tests/integration/redirect/js.test.ts Update export ordering and default export snapshots.
tests/integration/redirect/dts/rslib.config.mts Add DTS redirect integration fixture (multiple variants).
tests/integration/redirect/dts-tsgo/rslib.config.mts Add DTS+tsgo redirect integration fixture.
tests/integration/preserve-jsx/snapshots/index.test.ts.snap Update snapshots to export default.
tests/integration/parser-javascript/module/rslib.config.mts Add parser/javascript module fixture configs.
tests/integration/output/index.test.ts Update expected chunk naming patterns for Rsbuild v2.
tests/integration/node-polyfill/index.test.ts Update expectations for v2 output layout in node-polyfill tests.
tests/integration/node-polyfill/bundle/package.json Bump fixture Rsbuild to v2 beta.
tests/integration/node-polyfill/bundle-false/package.json Bump fixture Rsbuild to v2 beta.
tests/integration/minify/index.test.ts Update legal comment expectations and remove ADVANCED_ESM branching.
tests/integration/json/index.test.ts Unify snapshots to default ESM behavior.
tests/integration/iife/package.json Set fixture package to ESM (type: module).
tests/integration/iife/index.test.ts Update IIFE output snapshot (strict directive change).
tests/integration/format/index.test.ts Update hash length expectation; always run eval export test.
tests/integration/entry/index.test.ts Unify snapshots with new default ESM behavior.
tests/integration/dts/composite/process-files/package.json Set fixture package to ESM (type: module).
tests/integration/dts/composite/index.test.ts Update expected DTS output extensions (.d.ts).
tests/integration/dts/build/process-files/package.json Set fixture package to ESM (type: module).
tests/integration/dts/build/index.test.ts Update expected DTS output extension (.d.ts).
tests/integration/dts-tsgo/build/process-files/package.json Set fixture package to ESM (type: module).
tests/integration/dts-tsgo/build/index.test.ts Update expected DTS output extension (.d.ts).
tests/integration/bundle-false/index.test.ts Update bundleless export snapshots and default exports.
tests/integration/bundle-false/snapshots/index.test.ts.snap Update SVGR default export snapshot.
tests/integration/auto-external/with-externals/package.json Set fixture package to ESM (type: module).
tests/integration/auto-external/module-import-warn/package.json Set fixture package to ESM (type: module).
tests/integration/auto-external/false/package.json Set fixture package to ESM (type: module).
tests/integration/auto-external/external-sub-path/package.json Set fixture package to ESM (type: module).
tests/integration/auto-external/default/package.json Set fixture package to ESM (type: module).
tests/integration/auto-external/bundle-false/package.json Set fixture package to ESM (type: module).
tests/integration/auto-extension/type-commonjs/false/rslib.config.mts Add CJS-project autoExtension fixtures.
tests/integration/auto-extension/type-commonjs/false-bundleless/rslib.config.mts Add CJS-project bundleless autoExtension fixtures.
tests/integration/auto-extension/type-commonjs/default/rslib.config.mts Add CJS-project default autoExtension fixture.
tests/integration/auto-extension/type-commonjs/config-override/rslib.config.mts Add filename override fixtures for autoExtension.
tests/integration/auto-extension/index.test.ts Remove ADVANCED_ESM branches; update expected filenames.
tests/integration/asset/index.test.ts Unify snapshots and runtime expectations under new ESM defaults.
tests/integration/asset/snapshots/index.test.ts.snap Update asset/SVGR default export snapshots.
tests/e2e/react-component/package.json Mark e2e package as ESM (type: module).
tests/e2e/react-component/index.pw.test.ts Use import.meta.dirname as ESM-friendly cwd.
packages/plugin-dts/package.json Upgrade dev Rsbuild dependency to v2 beta.
packages/create-rslib/template-storybook/vue-ts/package.json Update template deps for Rsbuild v2 beta compat.
packages/create-rslib/template-storybook/vue-js/package.json Update template deps for Rsbuild v2 beta compat.
packages/create-rslib/template-storybook/react-ts/package.json Update template deps for Rsbuild v2 beta compat.
packages/create-rslib/template-storybook/react-js/package.json Update template deps for Rsbuild v2 beta compat.
packages/core/tests/fixtures/config/cjs/rslib.config.mts Add .mts fixture for CJS project config loading.
packages/core/tests/config.test.ts Load .mts config in CJS-project fixture; remove advancedEsm test.
packages/core/tests/snapshots/config.test.ts.snap Update inspected config snapshot to Rsbuild v2 structure.
packages/core/src/types/rslib.ts Rename exported server result type to StartDevServerResult.
packages/core/src/types/config.ts Mark advancedEsm as deprecated in TS types.
packages/core/src/plugins/entryModuleLoader.ts Remove no-op loader.
packages/core/src/plugins/EntryChunkPlugin.ts Remove entry-module loader plugin path; simplify entry chunk config.
packages/core/src/index.ts Re-export StartDevServerResult type.
packages/core/src/css/libCssExtractLoader.ts Update CSS extract warnings for v2 CSS pipeline.
packages/core/src/css/cssConfig.ts Update CSS extract integration to target new oneOf ids.
packages/core/src/css/const.ts Update CSS extract constants for Rspack v2 CSS extract plugin.
packages/core/src/createRslib.ts Rename MF dev server return type to StartDevServerResult.
packages/core/src/config.ts Remove advancedEsm branching; align format/CSS/shims composition with Rsbuild v2.
packages/core/rslib.config.ts Remove entryModuleLoader entry from build inputs.
packages/core/package.json Upgrade @rsbuild/core dependency to v2 beta.
package.json Remove advanced-esm CI/testing flows; exclude Vue examples from build temporarily.
examples/vue-component-bundleless/package.json Upgrade example to Rsbuild v2 beta.
examples/module-federation/mf-remote/package.json Upgrade example to Rsbuild v2 beta.
examples/module-federation/mf-react-component/package.json Upgrade example to Rsbuild v2 beta.
examples/module-federation/mf-host/package.json Upgrade example to Rsbuild v2 beta.
.github/workflows/test.yml Remove the advanced ESM integration job.
.github/workflows/reusable-test.yml Remove advanced ESM integration step.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

@Timeless0911 Timeless0911 changed the title feat!: upgrade Rsbuild to v2 and deprecate experiments.advancedEsm feat!: upgrade Rsbuild to v2 and deprecate experiments.advancedEsm Mar 4, 2026
@fi3ework fi3ework merged commit 74f4e5e into main Mar 4, 2026
15 of 17 checks passed
@fi3ework fi3ework deleted the rsbuild-v2 branch March 4, 2026 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

3 participants