Skip to content

Commit 73547af

Browse files
committed
fix: drop usage of appendPlugins to avoid plugins missing
1 parent 18f06a2 commit 73547af

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

packages/builder-rsbuild/src/preview/iframe-rsbuild.config.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,7 @@ export default async (
261261
})),
262262
].filter(Boolean),
263263
tools: {
264-
rspack: (config, { addRules, appendPlugins, rspack, mergeConfig }) => {
265-
// TODO: Rspack doesn't support `unknownContextCritical` yet
266-
// config.module.unknownContextCritical = false
264+
rspack: (config, { addRules, rspack, mergeConfig }) => {
267265
addRules({
268266
test: /\.stories\.([tj])sx?$|(stories|story)\.mdx$/,
269267
exclude: /node_modules/,
@@ -335,8 +333,9 @@ export default async (
335333
)
336334
}
337335

338-
appendPlugins(
339-
[
336+
config.plugins ??= []
337+
config.plugins.push(
338+
...[
340339
Object.keys(virtualModuleMapping).length > 0
341340
? new rspack.experiments.VirtualModulesPlugin(
342341
virtualModuleMapping,

sandboxes/react-16/rsbuild.config.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,14 @@ export default defineConfig({
1010
},
1111
},
1212
plugins: [pluginReact()],
13+
tools: {
14+
rspack: (config) => {
15+
const newConfig = {
16+
...config,
17+
module: { ...config.module }, // works fine
18+
plugins: [...config.plugins], // should also works fine, to test packages/builder-rsbuild/src/preview/iframe-rsbuild.config.ts:265
19+
}
20+
return newConfig
21+
},
22+
},
1323
})

0 commit comments

Comments
 (0)