Skip to content

Commit 744442a

Browse files
committed
test: persistent cache
1 parent 88b41b1 commit 744442a

File tree

5 files changed

+128
-214
lines changed

5 files changed

+128
-214
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
"simple-git-hooks"
7575
],
7676
"overrides": {
77+
"@rspack/core": "1.2.0-alpha.0",
7778
"zx>@types/node": "-"
7879
}
7980
}

packages/core/src/config.ts

+18-1
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,11 @@ export async function createConstantRsbuildConfig(): Promise<EnvironmentConfig>
473473
moduleIds: 'named',
474474
nodeEnv: false,
475475
},
476+
cache: true,
476477
experiments: {
478+
cache: {
479+
type: 'persistent',
480+
},
477481
rspackFuture: {
478482
bundlerInfo: {
479483
force: false,
@@ -1616,7 +1620,20 @@ export async function composeRsbuildEnvironments(
16161620

16171621
for (const { format, id, config } of rsbuildConfigWithLibInfo) {
16181622
const libId = typeof id === 'string' ? id : composeDefaultId(format);
1619-
environments[libId] = config;
1623+
environments[libId] = mergeRsbuildConfig(config, {
1624+
tools: {
1625+
rspack: {
1626+
experiments: {
1627+
cache: {
1628+
version:
1629+
libId +
1630+
config.source?.entry?.index +
1631+
config.output?.distPath?.root,
1632+
},
1633+
},
1634+
},
1635+
},
1636+
} as EnvironmentConfig);
16201637
environmentWithInfos.push({ id: libId, format, config });
16211638
}
16221639

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

+16
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,11 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
140140
"htmlPlugin": false,
141141
"rspack": [
142142
{
143+
"cache": true,
143144
"experiments": {
145+
"cache": {
146+
"type": "persistent",
147+
},
144148
"rspackFuture": {
145149
"bundlerInfo": {
146150
"force": false,
@@ -395,7 +399,11 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
395399
"htmlPlugin": false,
396400
"rspack": [
397401
{
402+
"cache": true,
398403
"experiments": {
404+
"cache": {
405+
"type": "persistent",
406+
},
399407
"rspackFuture": {
400408
"bundlerInfo": {
401409
"force": false,
@@ -621,7 +629,11 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
621629
"htmlPlugin": false,
622630
"rspack": [
623631
{
632+
"cache": true,
624633
"experiments": {
634+
"cache": {
635+
"type": "persistent",
636+
},
625637
"rspackFuture": {
626638
"bundlerInfo": {
627639
"force": false,
@@ -794,7 +806,11 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
794806
"htmlPlugin": false,
795807
"rspack": [
796808
{
809+
"cache": true,
797810
"experiments": {
811+
"cache": {
812+
"type": "persistent",
813+
},
798814
"rspackFuture": {
799815
"bundlerInfo": {
800816
"force": false,

0 commit comments

Comments
 (0)