Repository: facebook/docusaurus
File: packages/docusaurus/src/webpack/base.ts (TypeScript)

Code before:
      type: 'filesystem',
      name: getCacheName(),
      // When version string changes, cache is evicted
      version: [
        siteMetadata.docusaurusVersion,
        // Webpack does not evict the cache correctly on alias/swizzle change,
        // so we force eviction.
        // See https://github.com/webpack/webpack/issues/13627
        md5Hash(JSON.stringify(themeAliases)),
      ].join('-'),
      // When one of those modules/dependencies change (including transitive
      // deps), cache is invalidated
      buildDependencies: {
        config: getCacheBuildDependencies(),
      },
    };
  }

  function getExperiments(): Configuration['experiments'] {
    if (props.currentBundler.name === 'rspack') {
      const PersistentCacheAttributes = Env.noPersistentCache
        ? {}
        : {
            cache: {
              type: 'persistent',
              version: getCacheName(),
              buildDependencies: getCacheBuildDependencies(),
            },
          };

      // TODO find a way to type this
      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: !Env.isProd && !Env.noRspackIncremental,

        ...PersistentCacheAttributes,
      };
    }
    return undefined;
  }

  return {
    mode,
    name,

Review comment (performance):
I think we should concatenate the version property of the original Webpack attribute and getCacheName(). Do you have any reason to intentionally omit the version vale in Webpack?

https://rspack.dev/config/experiments#migrating-from-webpack-config

Code after:
      }
    }

    return {
      type: 'filesystem',
      name: getCacheName(),
      version: getCacheVersion(),
      buildDependencies: {
        config: getCacheBuildDependencies(),
      },
    };
  }

  function getExperiments(): Configuration['experiments'] {
    if (props.currentBundler.name === 'rspack') {
      const PersistentCacheAttributes = process.env
        .DOCUSAURUS_NO_PERSISTENT_CACHE
        ? {}
        : {
            cache: {
              type: 'persistent',
              // Rspack doesn't have "cache.name" like Webpack
              // This is not ideal but work around is to merge name/version
              // See https://github.com/web-infra-dev/rspack/pull/8920#issuecomment-2658938695
              version: `${getCacheName()}-${getCacheVersion()}`,
              buildDependencies: getCacheBuildDependencies(),
            },
          };

      // TODO find a way to type this
      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,

        ...PersistentCacheAttributes,
      };
    }
    return undefined;
  }

  return {
    mode,
    name,
    cache: getCache(),