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

Enable persistent cache in Faster + Rspack #10823

Open
1 of 2 tasks
tats-u opened this issue Jan 7, 2025 · 5 comments
Open
1 of 2 tasks

Enable persistent cache in Faster + Rspack #10823

tats-u opened this issue Jan 7, 2025 · 5 comments
Labels
proposal This issue is a proposal, usually non-trivial change

Comments

@tats-u
Copy link
Contributor

tats-u commented Jan 7, 2025

Have you read the Contributing Guidelines on issues?

Motivation

Rspack 1.2.0-alpha.0 used in Faster 3.7 now supports the experimental persistent cache.

https://github.com/web-infra-dev/rspack/releases/tag/v1.2.0-alpha.0
https://rspack.dev/config/experiments#persistent-cache

We need to modify the following parts:

     if (props.currentBundler.name === 'rspack') {
       // TODO Rspack only supports memory cache (as of Sept 2024)
       // TODO re-enable file persistent cache one Rspack supports it
       //  See also https://rspack.dev/config/cache#cache
-      return undefined;
+      return true;
     }

return {
// This is mostly useful in dev
// See https://rspack.dev/config/experiments#experimentsincremental
// Produces warnings in production builds
// See https://github.com/web-infra-dev/rspack/pull/8311#issuecomment-2476014664
// We use the same integration as Rspress, with ability to disable
// See https://github.com/web-infra-dev/rspress/pull/1631
// See https://github.com/facebook/docusaurus/issues/10646
// @ts-expect-error: Rspack-only, not available in Webpack typedefs
incremental: !isProd && !process.env.DISABLE_RSPACK_INCREMENTAL,
};

         // @ts-expect-error: Rspack-only, not available in Webpack typedefs
         incremental: !isProd && !process.env.DISABLE_RSPACK_INCREMENTAL,
+        cache: {
+          type: 'persistent',
+          // Some extra options
+       },
      };

Self-service

  • I'd be willing to do some initial work on this proposal myself.
@tats-u tats-u added proposal This issue is a proposal, usually non-trivial change status: needs triage This issue has not been triaged by maintainers labels Jan 7, 2025
@slorber
Copy link
Collaborator

slorber commented Jan 7, 2025

I tried already but it didn't work yet. It did rebuild faster but then the SSG failed. At best, we could expose this through env variables but I suspect it will fail on all sites. I'll ping the Rspack team about this when I have time to investigate a bit more (not this week, taking a break)

@slorber slorber removed the status: needs triage This issue has not been triaged by maintainers label Jan 7, 2025
@tats-u
Copy link
Contributor Author

tats-u commented Jan 7, 2025

You have already tried it, and it's bad news that it fails in SSG (I only tried it in preview with single locale by directly overwriting the JS file in node_modules).
The current API lacks name: `${name}-${mode}-${props.i18n.currentLocale}` (existing in Webpack), but is it fine?

@slorber
Copy link
Collaborator

slorber commented Jan 7, 2025

It's an initial version, afaik they plan to support the same options as Webpack.

This cache name feature is indeed useful to create one cache per env (client/server) and locale (for i18n sites)

See also my explanation here: web-infra-dev/rspack#5658 (comment)


BTW beta.0 is out right now: https://github.com/web-infra-dev/rspack/releases/tag/v1.2.0-beta.0

@tats-u
Copy link
Contributor Author

tats-u commented Jan 7, 2025

The design of the API has not been confirmed. I see.

The type of buildDependencies is different too. Webpack is object but Rspack is array. Looks like it's not critical now because we have only to extract .config.

I noticed the release of beta from the subscribed direct notification from Rspack.
I don't think its persistent cache is compatible with the current Docusaurus.

@jerrykingxyz
Copy link

The type of buildDependencies is different too. Webpack is object but Rspack is array.

Yes, the rspack configuration is designed differently than webpack and will not be compatible with webpack.

There are some reasons for this.

  1. The architecture of rspack cache is completely different from webpack, which makes some configurations meaningless on rspack, such as memoryCacheUnaffected.
  2. rspack cache needs to support more features in the future, such as remote cache.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal This issue is a proposal, usually non-trivial change
Projects
None yet
Development

No branches or pull requests

3 participants