From 54b8f002a01e42a50a94d99b743e20f7083fbaeb Mon Sep 17 00:00:00 2001 From: Timeless0911 <1604889533@qq.com> Date: Wed, 5 Nov 2025 21:09:34 +0800 Subject: [PATCH] feat: runtime chunk name default to `rslib-runtime` --- packages/core/src/config.ts | 6 +++++- packages/core/tests/__snapshots__/config.test.ts.snap | 4 +++- tests/integration/resolve/index.test.ts | 2 +- tests/integration/style/css-modules-named/index.test.ts | 2 +- tests/integration/vue/index.test.ts | 4 ++-- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/core/src/config.ts b/packages/core/src/config.ts index 27c63e8d8..e31740d38 100644 --- a/packages/core/src/config.ts +++ b/packages/core/src/config.ts @@ -664,7 +664,11 @@ const composeFormatConfig = ({ // experimentalEsmOutput don't need concatenateModules concatenateModules: !experimentalEsmOutput, sideEffects: experimentalEsmOutput ? true : 'flag', - runtimeChunk: experimentalEsmOutput ? 'single' : undefined, + runtimeChunk: experimentalEsmOutput + ? { + name: 'rslib-runtime', + } + : undefined, avoidEntryIife: true, splitChunks: { // Splitted "sync" chunks will make entry modules can't be inlined. diff --git a/packages/core/tests/__snapshots__/config.test.ts.snap b/packages/core/tests/__snapshots__/config.test.ts.snap index e5a02ce4d..07c7a9aa8 100644 --- a/packages/core/tests/__snapshots__/config.test.ts.snap +++ b/packages/core/tests/__snapshots__/config.test.ts.snap @@ -658,7 +658,9 @@ exports[`Should compose create Rsbuild config correctly > Enable experiment.adva nodeEnv: false, concatenateModules: false, sideEffects: true, - runtimeChunk: 'single', + runtimeChunk: { + name: 'rslib-runtime' + }, avoidEntryIife: true }, plugins: [ diff --git a/tests/integration/resolve/index.test.ts b/tests/integration/resolve/index.test.ts index ace166c62..5f7f5ff58 100644 --- a/tests/integration/resolve/index.test.ts +++ b/tests/integration/resolve/index.test.ts @@ -21,7 +21,7 @@ test('resolve false', async () => { expect(isSuccess).toBeTruthy(); if (process.env.ADVANCED_ESM) { expect(entries.esm).toMatchInlineSnapshot(` - "import { __webpack_require__ } from "./runtime.js"; + "import { __webpack_require__ } from "./rslib-runtime.js"; __webpack_require__.add({ "?b5d4": function() {} }); diff --git a/tests/integration/style/css-modules-named/index.test.ts b/tests/integration/style/css-modules-named/index.test.ts index e8819a0d8..cd2393ac4 100644 --- a/tests/integration/style/css-modules-named/index.test.ts +++ b/tests/integration/style/css-modules-named/index.test.ts @@ -20,7 +20,7 @@ test('should extract css-modules named export successfully in bundle', async () `); if (process.env.ADVANCED_ESM) { expect(js.entries.esm).toMatchInlineSnapshot(` - "import "./runtime.js"; + "import "./rslib-runtime.js"; var _1 = "content-wrapper-iNtwbA"; const src_button = _1; export { src_button as button }; diff --git a/tests/integration/vue/index.test.ts b/tests/integration/vue/index.test.ts index ecdc5d9b2..b38932222 100644 --- a/tests/integration/vue/index.test.ts +++ b/tests/integration/vue/index.test.ts @@ -14,7 +14,7 @@ describe.runIf(platform() !== 'win32')('ESM', async () => { if (process.env.ADVANCED_ESM) { expect(js.contents.esm1).toMatchInlineSnapshot(` { - "/tests/integration/vue/dist/bundle/index.js": "import "./runtime.js"; + "/tests/integration/vue/dist/bundle/index.js": "import "./rslib-runtime.js"; import { createElementBlock, openBlock, ref, toDisplayString } from "vue"; const _00_2Fplugin_vue_2Fexport_helper = (sfc, props)=>{ const target = sfc.__vccOpts || sfc; @@ -87,7 +87,7 @@ describe.runIf(platform() !== 'win32')('ESM', async () => { ]); export { Button, Card }; ", - "/tests/integration/vue/dist/bundle/runtime.js": "var __webpack_modules__ = {}; + "/tests/integration/vue/dist/bundle/rslib-runtime.js": "var __webpack_modules__ = {}; var __webpack_module_cache__ = {}; function __webpack_require__(moduleId) { var cachedModule = __webpack_module_cache__[moduleId];