diff --git a/packages/core/src/config.ts b/packages/core/src/config.ts index 8ae913792..e279cbb7a 100644 --- a/packages/core/src/config.ts +++ b/packages/core/src/config.ts @@ -520,7 +520,11 @@ export async function createConstantRsbuildConfig(): Promise moduleIds: 'named', nodeEnv: false, }, + cache: true, experiments: { + cache: { + type: 'persistent', + }, rspackFuture: { bundlerInfo: { force: false, @@ -1768,7 +1772,17 @@ export async function composeRsbuildEnvironments( for (const { format, id, config } of rsbuildConfigWithLibInfo) { const libId = typeof id === 'string' ? id : composeDefaultId(format); - environments[libId] = config; + environments[libId] = mergeRsbuildConfig(config, { + tools: { + rspack: { + experiments: { + cache: { + version: libId, + }, + }, + }, + }, + } as EnvironmentConfig); environmentWithInfos.push({ id: libId, format, config }); } diff --git a/packages/core/tests/__snapshots__/config.test.ts.snap b/packages/core/tests/__snapshots__/config.test.ts.snap index 39e693a73..fb2ae5557 100644 --- a/packages/core/tests/__snapshots__/config.test.ts.snap +++ b/packages/core/tests/__snapshots__/config.test.ts.snap @@ -137,7 +137,11 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i "htmlPlugin": false, "rspack": [ { + "cache": true, "experiments": { + "cache": { + "type": "persistent", + }, "rspackFuture": { "bundlerInfo": { "force": false, @@ -405,7 +409,11 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i "htmlPlugin": false, "rspack": [ { + "cache": true, "experiments": { + "cache": { + "type": "persistent", + }, "rspackFuture": { "bundlerInfo": { "force": false, @@ -640,7 +648,11 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i "htmlPlugin": false, "rspack": [ { + "cache": true, "experiments": { + "cache": { + "type": "persistent", + }, "rspackFuture": { "bundlerInfo": { "force": false, @@ -869,7 +881,11 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i "htmlPlugin": false, "rspack": [ { + "cache": true, "experiments": { + "cache": { + "type": "persistent", + }, "rspackFuture": { "bundlerInfo": { "force": false, @@ -1056,7 +1072,11 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i "htmlPlugin": false, "rspack": [ { + "cache": true, "experiments": { + "cache": { + "type": "persistent", + }, "rspackFuture": { "bundlerInfo": { "force": false, diff --git a/tests/integration/bundle-false/basic/.gitignore b/tests/integration/bundle-false/basic/.gitignore index 9bfb325f1..4ae55a0ab 100644 --- a/tests/integration/bundle-false/basic/.gitignore +++ b/tests/integration/bundle-false/basic/.gitignore @@ -1 +1,2 @@ -!node_modules/ \ No newline at end of file +!node_modules/ +.cache \ No newline at end of file diff --git a/tests/integration/redirect/style/.gitignore b/tests/integration/redirect/style/.gitignore index 9bfb325f1..4ae55a0ab 100644 --- a/tests/integration/redirect/style/.gitignore +++ b/tests/integration/redirect/style/.gitignore @@ -1 +1,2 @@ -!node_modules/ \ No newline at end of file +!node_modules/ +.cache \ No newline at end of file diff --git a/website/rspress.config.ts b/website/rspress.config.ts index 093c38794..fcf130c34 100644 --- a/website/rspress.config.ts +++ b/website/rspress.config.ts @@ -141,7 +141,17 @@ export default defineConfig({ dev: { lazyCompilation: true, }, - resolve: { + tools: { + rspack: { + cache: true, + experiments: { + cache: { + type: 'persistent', + }, + }, + }, + }, + source: { alias: { '@components': path.join(__dirname, '@components'), '@en': path.join(__dirname, 'docs/en'),