Skip to content
Merged
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
2 changes: 1 addition & 1 deletion packages/docusaurus-faster/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"license": "MIT",
"dependencies": {
"@docusaurus/types": "3.10.1",
"@rspack/core": "^1.7.10",
"@rspack/core": "^2.0.8",
"@swc/core": "^1.15.40",
"@swc/html": "^1.15.40",
"browserslist": "^4.28.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import React, {useMemo, type ReactNode, useContext} from 'react';
import {ReactContextError} from '@docusaurus/theme-common/internal';
import {ReactContextError} from '@docusaurus/theme-common';
import useRouteContext from '@docusaurus/useRouteContext';

import type {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import React, {useMemo, type ReactNode, useContext} from 'react';
import {ReactContextError} from '@docusaurus/theme-common/internal';
import {ReactContextError} from '@docusaurus/theme-common';
import type {PropDocContent} from '@docusaurus/plugin-content-docs';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import React, {type ReactNode, useMemo, useState, useContext} from 'react';
import {ReactContextError} from '@docusaurus/theme-common/internal';
import {ReactContextError} from '@docusaurus/theme-common';

type ContextValue = {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ import {
} from '@docusaurus/plugin-content-docs/client';
import {DEFAULT_PLUGIN_ID} from '@docusaurus/constants';
import {useThemeConfig, type ThemeConfig} from '@docusaurus/theme-common';
import {
ReactContextError,
createStorageSlot,
} from '@docusaurus/theme-common/internal';
import {ReactContextError, createStorageSlot} from '@docusaurus/theme-common';

type DocsVersionPersistence = ThemeConfig['docs']['versionPersistence'];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import React, {useMemo, useContext, type ReactNode} from 'react';
import {ReactContextError} from '@docusaurus/theme-common/internal';
import {ReactContextError} from '@docusaurus/theme-common';
import type {PropSidebar} from '@docusaurus/plugin-content-docs';

// Using a Symbol because null is a valid context value (a doc with no sidebar)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import React, {type ReactNode, useContext} from 'react';
import {ReactContextError} from '@docusaurus/theme-common/internal';
import {ReactContextError} from '@docusaurus/theme-common';
import type {PropVersionMetadata} from '@docusaurus/plugin-content-docs';

const Context = React.createContext<PropVersionMetadata | null>(null);
Expand Down
33 changes: 8 additions & 25 deletions packages/docusaurus/src/webpack/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,14 @@ export async function createBaseConfig({
}
if (props.currentBundler.name === 'rspack') {
if (props.siteConfig.future.faster.rspackPersistentCache) {
// Use cache: true + experiments.cache.type: "persistent"
// See https://rspack.dev/config/experiments#persistent-cache
return true;
return {
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(),
} as unknown as Configuration['cache'];
} else {
return disabledPersistentCacheValue;
}
Expand All @@ -149,32 +154,10 @@ export async function createBaseConfig({
};
}

function getExperiments(): Configuration['experiments'] {
if (props.currentBundler.name === 'rspack') {
// TODO find a way to type this
const experiments: any = {};

if (!process.env.DOCUSAURUS_NO_PERSISTENT_CACHE) {
experiments.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(),
};
}

return experiments;
}
return undefined;
}

return {
mode,
name,
cache: getCache(),
experiments: getExperiments(),
output: {
pathinfo: false,
path: outDir,
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus/src/webpack/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default async function createServerConfig({
output: {
path: outputDir,
filename: outputFilename,
libraryTarget: 'commonjs2',
library: {type: 'commonjs2'},
},
plugins: [
new ProgressBarPlugin({
Expand Down
Loading
Loading