@docusaurus/core 3.7.0-canary-6235 → 3.7.0-canary-6237

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,7 +18,7 @@ async function removePath(entry) {
18
18
  }
19
19
  try {
20
20
  await fs_extra_1.default.remove(entry.path);
21
- logger_1.default.success `Removed the ${entry.description} at path=${entry.path}.`;
21
+ logger_1.default.success `Removed the ${entry.description} at path=${path_1.default.relative(process.cwd(), entry.path)}.`;
22
22
  }
23
23
  catch (err) {
24
24
  logger_1.default.error `Could not remove the ${entry.description} at path=${entry.path}.`;
@@ -38,7 +38,7 @@ async function clear(siteDirParam = '.') {
38
38
  // In Yarn PnP, cache is stored in `.yarn/.cache` because n_m doesn't exist
39
39
  const cacheFolders = ['node_modules', '.yarn'].map((p) => ({
40
40
  path: path_1.default.join(siteDir, p, '.cache'),
41
- description: 'Webpack persistent cache folder',
41
+ description: 'bundler persistent cache folder',
42
42
  }));
43
43
  await Promise.all([generatedFolder, buildFolder, ...cacheFolders].map(removePath));
44
44
  }
@@ -31,6 +31,7 @@ exports.DEFAULT_FASTER_CONFIG = {
31
31
  lightningCssMinimizer: false,
32
32
  mdxCrossCompilerCache: false,
33
33
  rspackBundler: false,
34
+ rspackPersistentCache: false,
34
35
  ssgWorkerThreads: false,
35
36
  };
36
37
  // When using the "faster: true" shortcut
@@ -41,6 +42,7 @@ exports.DEFAULT_FASTER_CONFIG_TRUE = {
41
42
  lightningCssMinimizer: true,
42
43
  mdxCrossCompilerCache: true,
43
44
  rspackBundler: true,
45
+ rspackPersistentCache: true,
44
46
  ssgWorkerThreads: true,
45
47
  };
46
48
  exports.DEFAULT_FUTURE_V4_CONFIG = {
@@ -167,6 +169,7 @@ const FASTER_CONFIG_SCHEMA = utils_validation_1.Joi.alternatives()
167
169
  lightningCssMinimizer: utils_validation_1.Joi.boolean().default(exports.DEFAULT_FASTER_CONFIG.lightningCssMinimizer),
168
170
  mdxCrossCompilerCache: utils_validation_1.Joi.boolean().default(exports.DEFAULT_FASTER_CONFIG.mdxCrossCompilerCache),
169
171
  rspackBundler: utils_validation_1.Joi.boolean().default(exports.DEFAULT_FASTER_CONFIG.rspackBundler),
172
+ rspackPersistentCache: utils_validation_1.Joi.boolean().default(exports.DEFAULT_FASTER_CONFIG.rspackPersistentCache),
170
173
  ssgWorkerThreads: utils_validation_1.Joi.boolean().default(exports.DEFAULT_FASTER_CONFIG.ssgWorkerThreads),
171
174
  }), utils_validation_1.Joi.boolean()
172
175
  .required()
@@ -336,7 +339,12 @@ function ensureDocusaurusConfigConsistency(config) {
336
339
  if (config.future.experimental_faster.ssgWorkerThreads &&
337
340
  !config.future.v4.removeLegacyPostBuildHeadAttribute) {
338
341
  throw new Error(`Docusaurus config ${logger_1.default.code('future.experimental_faster.ssgWorkerThreads')} requires the future flag ${logger_1.default.code('future.v4.removeLegacyPostBuildHeadAttribute')} to be turned on.
339
- If you use Docusaurus Faster, we recommend that you also activate Docusaurus v4 future flags: ${logger_1.default.code('{future: {v4: true}}')}`);
342
+ If you use Docusaurus Faster, we recommend that you also activate Docusaurus v4 future flags: ${logger_1.default.code('{future: {v4: true}}')}
343
+ All the v4 future flags are documented here: https://docusaurus.io/docs/api/docusaurus-config#future`);
344
+ }
345
+ if (config.future.experimental_faster.rspackPersistentCache &&
346
+ !config.future.experimental_faster.rspackBundler) {
347
+ throw new Error(`Docusaurus config flag ${logger_1.default.code('future.experimental_faster.rspackPersistentCache')} requires the flag ${logger_1.default.code('future.experimental_faster.rspackBundler')} to be turned on.`);
340
348
  }
341
349
  }
342
350
  // TODO move to @docusaurus/utils-validation
@@ -39,7 +39,7 @@ async function loadAppRenderer({ serverBundlePath, }) {
39
39
  /* scope: */ globals,
40
40
  /* includeGlobals: */ true));
41
41
  if (!serverEntry?.default || typeof serverEntry.default !== 'function') {
42
- throw new Error(`Server bundle export from "${filename}" must be a function that renders the Docusaurus React app.`);
42
+ throw new Error(`Docusaurus Bug: server bundle export from "${filename}" must be a function that renders the Docusaurus React app, not ${typeof serverEntry?.default}`);
43
43
  }
44
44
  async function shutdown() {
45
45
  ssgRequire.cleanup();
@@ -58,43 +58,72 @@ async function createBaseConfig({ props, isServer, minify, faster, configureWebp
58
58
  const CSSExtractPlugin = await (0, bundler_1.getCSSExtractPlugin)({
59
59
  currentBundler: props.currentBundler,
60
60
  });
61
+ // Can we share the same cache across locales?
62
+ // Exploring that question at https://github.com/webpack/webpack/issues/13034
63
+ function getCacheName() {
64
+ return `${name}-${mode}-${props.i18n.currentLocale}`;
65
+ }
66
+ // When the version string changes, the cache is evicted
67
+ function getCacheVersion() {
68
+ // Because Webpack does not evict the cache on alias/swizzle changes,
69
+ // See https://github.com/webpack/webpack/issues/13627
70
+ const themeAliasesHash = (0, utils_1.md5Hash)(JSON.stringify(themeAliases));
71
+ return `${siteMetadata.docusaurusVersion}-${themeAliasesHash}`;
72
+ }
73
+ // When one of those modules/dependencies change (including transitive
74
+ // deps), cache is invalidated
75
+ function getCacheBuildDependencies() {
76
+ return [
77
+ __filename,
78
+ path_1.default.join(__dirname, isServer ? 'server.js' : 'client.js'),
79
+ // Docusaurus config changes can affect MDX/JSX compilation, so we'd
80
+ // rather evict the cache.
81
+ // See https://github.com/questdb/questdb.io/issues/493
82
+ siteConfigPath,
83
+ ];
84
+ }
61
85
  function getCache() {
86
+ // Use default: memory cache in dev, nothing in prod
87
+ // See https://rspack.dev/config/cache#cache
88
+ const disabledPersistentCacheValue = undefined;
89
+ if (process.env.DOCUSAURUS_NO_PERSISTENT_CACHE) {
90
+ return disabledPersistentCacheValue;
91
+ }
62
92
  if (props.currentBundler.name === 'rspack') {
63
- // TODO Rspack only supports memory cache (as of Sept 2024)
64
- // TODO re-enable file persistent cache one Rspack supports it
65
- // See also https://rspack.dev/config/cache#cache
66
- return undefined;
93
+ if (props.siteConfig.future.experimental_faster.rspackPersistentCache) {
94
+ // Use cache: true + experiments.cache.type: "persistent"
95
+ // See https://rspack.dev/config/experiments#persistent-cache
96
+ return true;
97
+ }
98
+ else {
99
+ return disabledPersistentCacheValue;
100
+ }
67
101
  }
68
102
  return {
69
103
  type: 'filesystem',
70
- // Can we share the same cache across locales?
71
- // Exploring that question at https://github.com/webpack/webpack/issues/13034
72
- // name: `${name}-${mode}`,
73
- name: `${name}-${mode}-${props.i18n.currentLocale}`,
74
- // When version string changes, cache is evicted
75
- version: [
76
- siteMetadata.docusaurusVersion,
77
- // Webpack does not evict the cache correctly on alias/swizzle change,
78
- // so we force eviction.
79
- // See https://github.com/webpack/webpack/issues/13627
80
- (0, utils_1.md5Hash)(JSON.stringify(themeAliases)),
81
- ].join('-'),
82
- // When one of those modules/dependencies change (including transitive
83
- // deps), cache is invalidated
104
+ name: getCacheName(),
105
+ version: getCacheVersion(),
84
106
  buildDependencies: {
85
- config: [
86
- __filename,
87
- path_1.default.join(__dirname, isServer ? 'server.js' : 'client.js'),
88
- // Docusaurus config changes can affect MDX/JSX compilation, so we'd
89
- // rather evict the cache.
90
- // See https://github.com/questdb/questdb.io/issues/493
91
- siteConfigPath,
92
- ],
107
+ config: getCacheBuildDependencies(),
93
108
  },
94
109
  };
95
110
  }
96
111
  function getExperiments() {
97
112
  if (props.currentBundler.name === 'rspack') {
113
+ const PersistentCacheAttributes = process.env
114
+ .DOCUSAURUS_NO_PERSISTENT_CACHE
115
+ ? {}
116
+ : {
117
+ cache: {
118
+ type: 'persistent',
119
+ // Rspack doesn't have "cache.name" like Webpack
120
+ // This is not ideal but work around is to merge name/version
121
+ // See https://github.com/web-infra-dev/rspack/pull/8920#issuecomment-2658938695
122
+ version: `${getCacheName()}-${getCacheVersion()}`,
123
+ buildDependencies: getCacheBuildDependencies(),
124
+ },
125
+ };
126
+ // TODO find a way to type this
98
127
  return {
99
128
  // This is mostly useful in dev
100
129
  // See https://rspack.dev/config/experiments#experimentsincremental
@@ -105,6 +134,7 @@ async function createBaseConfig({ props, isServer, minify, faster, configureWebp
105
134
  // See https://github.com/facebook/docusaurus/issues/10646
106
135
  // @ts-expect-error: Rspack-only, not available in Webpack typedefs
107
136
  incremental: !isProd && !process.env.DISABLE_RSPACK_INCREMENTAL,
137
+ ...PersistentCacheAttributes,
108
138
  };
109
139
  }
110
140
  return undefined;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@docusaurus/core",
3
3
  "description": "Easy to Maintain Open Source Documentation Websites",
4
- "version": "3.7.0-canary-6235",
4
+ "version": "3.7.0-canary-6237",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -33,13 +33,13 @@
33
33
  "url": "https://github.com/facebook/docusaurus/issues"
34
34
  },
35
35
  "dependencies": {
36
- "@docusaurus/babel": "3.7.0-canary-6235",
37
- "@docusaurus/bundler": "3.7.0-canary-6235",
38
- "@docusaurus/logger": "3.7.0-canary-6235",
39
- "@docusaurus/mdx-loader": "3.7.0-canary-6235",
40
- "@docusaurus/utils": "3.7.0-canary-6235",
41
- "@docusaurus/utils-common": "3.7.0-canary-6235",
42
- "@docusaurus/utils-validation": "3.7.0-canary-6235",
36
+ "@docusaurus/babel": "3.7.0-canary-6237",
37
+ "@docusaurus/bundler": "3.7.0-canary-6237",
38
+ "@docusaurus/logger": "3.7.0-canary-6237",
39
+ "@docusaurus/mdx-loader": "3.7.0-canary-6237",
40
+ "@docusaurus/utils": "3.7.0-canary-6237",
41
+ "@docusaurus/utils-common": "3.7.0-canary-6237",
42
+ "@docusaurus/utils-validation": "3.7.0-canary-6237",
43
43
  "boxen": "^6.2.1",
44
44
  "chalk": "^4.1.2",
45
45
  "chokidar": "^3.5.3",
@@ -78,8 +78,8 @@
78
78
  "webpack-merge": "^6.0.1"
79
79
  },
80
80
  "devDependencies": {
81
- "@docusaurus/module-type-aliases": "3.7.0-canary-6235",
82
- "@docusaurus/types": "3.7.0-canary-6235",
81
+ "@docusaurus/module-type-aliases": "3.7.0-canary-6237",
82
+ "@docusaurus/types": "3.7.0-canary-6237",
83
83
  "@total-typescript/shoehorn": "^0.1.2",
84
84
  "@types/detect-port": "^1.3.3",
85
85
  "@types/react-dom": "^18.2.7",
@@ -99,5 +99,5 @@
99
99
  "engines": {
100
100
  "node": ">=18.0"
101
101
  },
102
- "gitHead": "ec994a5adaf54a7fd730a73a0507ff24e321c34a"
102
+ "gitHead": "fda080b1f00817057cfed649f1542f5d71dd85a3"
103
103
  }