Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: enable persistent cache #630

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
19 changes: 18 additions & 1 deletion packages/core/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,11 @@ export async function createConstantRsbuildConfig(): Promise<EnvironmentConfig>
moduleIds: 'named',
nodeEnv: false,
},
cache: true,
experiments: {
cache: {
type: 'persistent',
},
rspackFuture: {
bundlerInfo: {
force: false,
Expand Down Expand Up @@ -1616,7 +1620,20 @@ 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:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

invalidate:

  • config.name
  • config file hash

libId +
config.source?.entry?.index +
config.output?.distPath?.root,
},
},
},
},
} as EnvironmentConfig);
environmentWithInfos.push({ id: libId, format, config });
}

Expand Down
16 changes: 16 additions & 0 deletions packages/core/tests/__snapshots__/config.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,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,
Expand Down Expand Up @@ -395,7 +399,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,
Expand Down Expand Up @@ -621,7 +629,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,
Expand Down Expand Up @@ -794,7 +806,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,
Expand Down
10 changes: 10 additions & 0 deletions website/rspress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ export default defineConfig({
dev: {
lazyCompilation: true,
},
tools: {
rspack: {
cache: true,
experiments: {
cache: {
type: 'persistent',
},
},
},
},
source: {
alias: {
'@components': path.join(__dirname, '@components'),
Expand Down
Loading