Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions packages/rstack/src/rsbuildConfig.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { mergeRsbuildConfig, type RsbuildConfigDefinition, type ConfigParams } from '@rsbuild/core';
import type { ConfigParams, RsbuildConfigDefinition, WatchFiles } from '@rsbuild/core';
import { loadRstackConfig, type Configs } from './config.js';

const resolveRsbuildConfig = async (configs: Configs, params: ConfigParams) => {
Expand All @@ -20,14 +20,22 @@ const loadRsbuildConfig: RsbuildConfigDefinition = async (params) => {
return config;
}

return mergeRsbuildConfig(config, {
const watchFiles = config.dev?.watchFiles;
const watchConfig: WatchFiles = {
paths: [filePath, ...dependencies],
type: 'reload-server',
};

return {
...config,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Deep-copy nested user config before returning

This top-level spread only protects dev; nested objects such as source and performance are still the same objects from a reusable define.app config. In the rs dev flow, when .env files are loaded and the shared config already contains those nested objects, Rsbuild mutates the config object returned by this loader (for example applyEnvsToConfig writes source.define and performance.buildCache), so an imported shared config can keep old PUBLIC_ defines or accumulate buildDependencies across config/env restarts; the previous mergeRsbuildConfig path cloned those nested plain objects before Rsbuild saw them.

Useful? React with 👍 / 👎.

dev: {
watchFiles: {
paths: [filePath, ...dependencies],
type: 'reload-server',
},
...config.dev,
watchFiles: [
...(watchFiles ? (Array.isArray(watchFiles) ? watchFiles : [watchFiles]) : []),
watchConfig,
],
},
});
};
};

export default loadRsbuildConfig;