Skip to content

Commit 056432d

Browse files
authored
feat: enable buildCache by default (#1334)
1 parent faf1711 commit 056432d

File tree

9 files changed

+131
-10
lines changed

9 files changed

+131
-10
lines changed

packages/core/src/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,7 @@ export async function createConstantRsbuildConfig(): Promise<EnvironmentConfig>
561561
chunkSplit: {
562562
strategy: 'custom',
563563
},
564+
buildCache: true,
564565
},
565566
tools: {
566567
htmlPlugin: false,

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

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,23 @@ exports[`Should compose create Rsbuild config correctly > Enable experiment.adva
2525
force: false
2626
}
2727
},
28+
cache: {
29+
type: 'persistent',
30+
version: 'esm-development',
31+
storage: {
32+
type: 'filesystem',
33+
directory: '<WORKSPACE>/node_modules/.cache/rspack'
34+
},
35+
buildDependencies: [
36+
'<WORKSPACE>/package.json',
37+
'<WORKSPACE>/tsconfig.json'
38+
]
39+
},
2840
asyncWebAssembly: true,
2941
outputModule: true
3042
},
3143
devtool: false,
44+
cache: true,
3245
externals: [
3346
function () { /* omitted long function */ },
3447
/^@rsbuild\\/core($|\\/|\\\\)/,
@@ -1064,10 +1077,23 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
10641077
force: false
10651078
}
10661079
},
1080+
cache: {
1081+
type: 'persistent',
1082+
version: 'esm-development',
1083+
storage: {
1084+
type: 'filesystem',
1085+
directory: '<WORKSPACE>/node_modules/.cache/rspack'
1086+
},
1087+
buildDependencies: [
1088+
'<WORKSPACE>/package.json',
1089+
'<WORKSPACE>/tsconfig.json'
1090+
]
1091+
},
10671092
asyncWebAssembly: true,
10681093
outputModule: true
10691094
},
10701095
devtool: false,
1096+
cache: true,
10711097
externals: [
10721098
function () { /* omitted long function */ },
10731099
/^@rsbuild\\/core($|\\/|\\\\)/,
@@ -1800,9 +1826,22 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
18001826
force: false
18011827
}
18021828
},
1829+
cache: {
1830+
type: 'persistent',
1831+
version: 'cjs-development',
1832+
storage: {
1833+
type: 'filesystem',
1834+
directory: '<WORKSPACE>/node_modules/.cache/rspack'
1835+
},
1836+
buildDependencies: [
1837+
'<WORKSPACE>/package.json',
1838+
'<WORKSPACE>/tsconfig.json'
1839+
]
1840+
},
18031841
asyncWebAssembly: true
18041842
},
18051843
devtool: false,
1844+
cache: true,
18061845
externals: [
18071846
/^@rsbuild\\/core($|\\/|\\\\)/,
18081847
/^rsbuild-plugin-dts($|\\/|\\\\)/,
@@ -2529,9 +2568,22 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
25292568
force: false
25302569
}
25312570
},
2571+
cache: {
2572+
type: 'persistent',
2573+
version: 'umd-development',
2574+
storage: {
2575+
type: 'filesystem',
2576+
directory: '<WORKSPACE>/node_modules/.cache/rspack'
2577+
},
2578+
buildDependencies: [
2579+
'<WORKSPACE>/package.json',
2580+
'<WORKSPACE>/tsconfig.json'
2581+
]
2582+
},
25322583
asyncWebAssembly: true
25332584
},
25342585
devtool: false,
2586+
cache: true,
25352587
externals: [
25362588
'assert',
25372589
'assert/strict',
@@ -3163,9 +3215,22 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
31633215
force: false
31643216
}
31653217
},
3218+
cache: {
3219+
type: 'persistent',
3220+
version: 'iife-development',
3221+
storage: {
3222+
type: 'filesystem',
3223+
directory: '<WORKSPACE>/node_modules/.cache/rspack'
3224+
},
3225+
buildDependencies: [
3226+
'<WORKSPACE>/package.json',
3227+
'<WORKSPACE>/tsconfig.json'
3228+
]
3229+
},
31663230
asyncWebAssembly: true
31673231
},
31683232
devtool: false,
3233+
cache: true,
31693234
externals: [
31703235
'assert',
31713236
'assert/strict',
@@ -3798,9 +3863,22 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
37983863
force: false
37993864
}
38003865
},
3866+
cache: {
3867+
type: 'persistent',
3868+
version: 'mf-development',
3869+
storage: {
3870+
type: 'filesystem',
3871+
directory: '<WORKSPACE>/node_modules/.cache/rspack'
3872+
},
3873+
buildDependencies: [
3874+
'<WORKSPACE>/package.json',
3875+
'<WORKSPACE>/tsconfig.json'
3876+
]
3877+
},
38013878
asyncWebAssembly: true
38023879
},
38033880
devtool: false,
3881+
cache: true,
38043882
output: {
38053883
devtoolModuleFilenameTemplate: '[absolute-resource-path]',
38063884
path: '<WORKSPACE>/dist',
@@ -4465,6 +4543,7 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
44654543
"target": "node",
44664544
},
44674545
"performance": {
4546+
"buildCache": true,
44684547
"chunkSplit": {
44694548
"strategy": "custom",
44704549
},
@@ -4757,6 +4836,7 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
47574836
"target": "node",
47584837
},
47594838
"performance": {
4839+
"buildCache": true,
47604840
"chunkSplit": {
47614841
"strategy": "custom",
47624842
},
@@ -5036,6 +5116,7 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
50365116
"target": "node",
50375117
},
50385118
"performance": {
5119+
"buildCache": true,
50395120
"chunkSplit": {
50405121
"strategy": "custom",
50415122
},
@@ -5287,6 +5368,7 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
52875368
"target": "node",
52885369
},
52895370
"performance": {
5371+
"buildCache": true,
52905372
"chunkSplit": {
52915373
"strategy": "custom",
52925374
},
@@ -5485,6 +5567,7 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
54855567
"target": "web",
54865568
},
54875569
"performance": {
5570+
"buildCache": true,
54885571
"chunkSplit": {
54895572
"strategy": "custom",
54905573
},

tests/scripts/shared.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,11 @@ const updateConfigForTest =
282282
(logLevel?: LogLevel) => (rslibConfig: RslibConfig) => {
283283
Object.assign(rslibConfig, {
284284
performance: {
285+
...rslibConfig.performance,
285286
// Do not print file size in tests
286287
printFileSize: false,
288+
// Do not use build cache in tests
289+
buildCache: false,
287290
},
288291
logLevel,
289292
});

website/docs/en/config/rsbuild/_meta.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
"source",
99
"output",
1010
"tools",
11-
{
12-
"type": "file",
13-
"name": "plugins",
14-
"label": "plugins"
15-
}
11+
"performance",
12+
"plugins"
1613
]

website/docs/en/config/rsbuild/index.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ To learn more about Rslib configurations, check out [Configure Rslib](/guide/bas
1515
- [source](/config/rsbuild/source): Options for input source code.
1616
- [output](/config/rsbuild/output): Options for build outputs.
1717
- [tools](/config/rsbuild/tools): Options for low-level tools.
18+
- [performance](/config/rsbuild/performance): Options for performance.
1819
- [plugins](/config/rsbuild/plugins): Configure Rsbuild plugins.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { RsbuildDocBadge } from '@components/RsbuildDocBadge';
2+
3+
# performance
4+
5+
Options for performance.
6+
7+
## performance.buildCache <RsbuildDocBadge path="/config/performance/build-cache" text="performance.buildCache" />
8+
9+
To enable or configure persistent build cache.
10+
11+
Rslib enable persistent build cache by default in v0.17.3.
12+
13+
## performance.printFileSize <RsbuildDocBadge path="/config/performance/print-file-size" text="performance.printFileSize" />
14+
15+
Whether to print the file sizes after build.
16+
17+
## performance.removeConsole <RsbuildDocBadge path="/config/performance/remove-console" text="performance.removeConsole" />
18+
19+
Whether to remove `console.[methodName]` in build.

website/docs/zh/config/rsbuild/_meta.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
"source",
99
"output",
1010
"tools",
11-
{
12-
"type": "file",
13-
"name": "plugins",
14-
"label": "plugins"
15-
}
11+
"performance",
12+
"plugins"
1613
]

website/docs/zh/config/rsbuild/index.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ Rslib 继承了 Rsbuild 的配置,所以你也可以配置 <RsbuildDocBadge pa
1515
- [source](/config/rsbuild/source): 与输入的源代码相关的选项。
1616
- [output](/config/rsbuild/output): 与构建产物相关的选项。
1717
- [tools](/config/rsbuild/tools): 与底层工具相关的选项。
18+
- [performance](/config/rsbuild/performance): 与性能相关的选项。
1819
- [plugins](/config/rsbuild/plugins): 配置 Rsbuild 插件。
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { RsbuildDocBadge } from '@components/RsbuildDocBadge';
2+
3+
# performance
4+
5+
与性能相关的选项。
6+
7+
## performance.buildCache <RsbuildDocBadge path="/config/performance/build-cache" text="performance.buildCache" />
8+
9+
用于启用或配置持久化构建缓存。
10+
11+
Rslib 在 v0.17.3 版本中默认启用了持久化构建缓存。
12+
13+
## performance.printFileSize <RsbuildDocBadge path="/config/performance/print-file-size" text="performance.printFileSize" />
14+
15+
是否在构建后输出所有静态资源文件的体积。
16+
17+
## performance.removeConsole <RsbuildDocBadge path="/config/performance/remove-console" text="performance.removeConsole" />
18+
19+
是否自动移除代码中的 `console.[methodName]`

0 commit comments

Comments
 (0)