Skip to content

Commit fd4b31d

Browse files
committed
test: persistent cache
1 parent 2824c1b commit fd4b31d

File tree

3 files changed

+45
-2
lines changed

3 files changed

+45
-2
lines changed

packages/core/src/config.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,11 @@ export async function createConstantRsbuildConfig(): Promise<EnvironmentConfig>
520520
moduleIds: 'named',
521521
nodeEnv: false,
522522
},
523+
cache: true,
523524
experiments: {
525+
cache: {
526+
type: 'persistent',
527+
},
524528
rspackFuture: {
525529
bundlerInfo: {
526530
force: false,
@@ -1768,7 +1772,20 @@ export async function composeRsbuildEnvironments(
17681772

17691773
for (const { format, id, config } of rsbuildConfigWithLibInfo) {
17701774
const libId = typeof id === 'string' ? id : composeDefaultId(format);
1771-
environments[libId] = config;
1775+
environments[libId] = mergeRsbuildConfig(config, {
1776+
tools: {
1777+
rspack: {
1778+
experiments: {
1779+
cache: {
1780+
version:
1781+
libId +
1782+
config.source?.entry?.index +
1783+
config.output?.distPath?.root,
1784+
},
1785+
},
1786+
},
1787+
},
1788+
} as EnvironmentConfig);
17721789
environmentWithInfos.push({ id: libId, format, config });
17731790
}
17741791

packages/core/tests/__snapshots__/config.test.ts.snap

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,11 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
137137
"htmlPlugin": false,
138138
"rspack": [
139139
{
140+
"cache": true,
140141
"experiments": {
142+
"cache": {
143+
"type": "persistent",
144+
},
141145
"rspackFuture": {
142146
"bundlerInfo": {
143147
"force": false,
@@ -405,7 +409,11 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
405409
"htmlPlugin": false,
406410
"rspack": [
407411
{
412+
"cache": true,
408413
"experiments": {
414+
"cache": {
415+
"type": "persistent",
416+
},
409417
"rspackFuture": {
410418
"bundlerInfo": {
411419
"force": false,
@@ -640,7 +648,11 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
640648
"htmlPlugin": false,
641649
"rspack": [
642650
{
651+
"cache": true,
643652
"experiments": {
653+
"cache": {
654+
"type": "persistent",
655+
},
644656
"rspackFuture": {
645657
"bundlerInfo": {
646658
"force": false,
@@ -1056,7 +1068,11 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
10561068
"htmlPlugin": false,
10571069
"rspack": [
10581070
{
1071+
"cache": true,
10591072
"experiments": {
1073+
"cache": {
1074+
"type": "persistent",
1075+
},
10601076
"rspackFuture": {
10611077
"bundlerInfo": {
10621078
"force": false,

website/rspress.config.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,17 @@ export default defineConfig({
141141
dev: {
142142
lazyCompilation: true,
143143
},
144-
resolve: {
144+
tools: {
145+
rspack: {
146+
cache: true,
147+
experiments: {
148+
cache: {
149+
type: 'persistent',
150+
},
151+
},
152+
},
153+
},
154+
source: {
145155
alias: {
146156
'@components': path.join(__dirname, '@components'),
147157
'@en': path.join(__dirname, 'docs/en'),

0 commit comments

Comments
 (0)