@docusaurus/plugin-content-docs 3.7.0-canary-6228 → 3.7.0-canary-6231
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.
- package/lib/index.js +23 -0
- package/package.json +11 -11
- package/src/index.ts +33 -0
- package/src/plugin-content-docs.d.ts +9 -1
package/lib/index.js
CHANGED
|
@@ -10,6 +10,7 @@ exports.validateOptions = void 0;
|
|
|
10
10
|
exports.default = pluginContentDocs;
|
|
11
11
|
const tslib_1 = require("tslib");
|
|
12
12
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
13
|
+
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
13
14
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
14
15
|
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
15
16
|
const utils_1 = require("@docusaurus/utils");
|
|
@@ -26,6 +27,21 @@ const translations_1 = require("./translations");
|
|
|
26
27
|
const routes_1 = require("./routes");
|
|
27
28
|
const utils_2 = require("./sidebars/utils");
|
|
28
29
|
const contentHelpers_1 = require("./contentHelpers");
|
|
30
|
+
// MDX loader is not 100% deterministic, leading to cache invalidation issue
|
|
31
|
+
// This permits to invalidate the MDX loader cache entries when content changes
|
|
32
|
+
// Problem documented here: https://github.com/facebook/docusaurus/pull/10934
|
|
33
|
+
// TODO this is not a perfect solution, find better?
|
|
34
|
+
async function createMdxLoaderDependencyFile({ dataDir, options, versionsMetadata, }) {
|
|
35
|
+
const filePath = path_1.default.join(dataDir, '__mdx-loader-dependency.json');
|
|
36
|
+
// the cache is invalidated whenever this file content changes
|
|
37
|
+
const fileContent = {
|
|
38
|
+
options,
|
|
39
|
+
versionsMetadata,
|
|
40
|
+
};
|
|
41
|
+
await fs_extra_1.default.ensureDir(dataDir);
|
|
42
|
+
await fs_extra_1.default.writeFile(filePath, JSON.stringify(fileContent));
|
|
43
|
+
return filePath;
|
|
44
|
+
}
|
|
29
45
|
async function pluginContentDocs(context, options) {
|
|
30
46
|
const { siteDir, generatedFilesDir, baseUrl, siteConfig } = context;
|
|
31
47
|
// Mutate options to resolve sidebar path according to siteDir
|
|
@@ -50,6 +66,13 @@ async function pluginContentDocs(context, options) {
|
|
|
50
66
|
return (0, mdx_loader_1.createMDXLoaderRule)({
|
|
51
67
|
include: contentDirs,
|
|
52
68
|
options: {
|
|
69
|
+
dependencies: [
|
|
70
|
+
await createMdxLoaderDependencyFile({
|
|
71
|
+
dataDir,
|
|
72
|
+
options,
|
|
73
|
+
versionsMetadata,
|
|
74
|
+
}),
|
|
75
|
+
],
|
|
53
76
|
useCrossCompilerCache: siteConfig.future.experimental_faster.mdxCrossCompilerCache,
|
|
54
77
|
admonitions: options.admonitions,
|
|
55
78
|
remarkPlugins,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/plugin-content-docs",
|
|
3
|
-
"version": "3.7.0-canary-
|
|
3
|
+
"version": "3.7.0-canary-6231",
|
|
4
4
|
"description": "Docs plugin for Docusaurus.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -35,15 +35,15 @@
|
|
|
35
35
|
},
|
|
36
36
|
"license": "MIT",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@docusaurus/core": "3.7.0-canary-
|
|
39
|
-
"@docusaurus/logger": "3.7.0-canary-
|
|
40
|
-
"@docusaurus/mdx-loader": "3.7.0-canary-
|
|
41
|
-
"@docusaurus/module-type-aliases": "3.7.0-canary-
|
|
42
|
-
"@docusaurus/theme-common": "3.7.0-canary-
|
|
43
|
-
"@docusaurus/types": "3.7.0-canary-
|
|
44
|
-
"@docusaurus/utils": "3.7.0-canary-
|
|
45
|
-
"@docusaurus/utils-common": "3.7.0-canary-
|
|
46
|
-
"@docusaurus/utils-validation": "3.7.0-canary-
|
|
38
|
+
"@docusaurus/core": "3.7.0-canary-6231",
|
|
39
|
+
"@docusaurus/logger": "3.7.0-canary-6231",
|
|
40
|
+
"@docusaurus/mdx-loader": "3.7.0-canary-6231",
|
|
41
|
+
"@docusaurus/module-type-aliases": "3.7.0-canary-6231",
|
|
42
|
+
"@docusaurus/theme-common": "3.7.0-canary-6231",
|
|
43
|
+
"@docusaurus/types": "3.7.0-canary-6231",
|
|
44
|
+
"@docusaurus/utils": "3.7.0-canary-6231",
|
|
45
|
+
"@docusaurus/utils-common": "3.7.0-canary-6231",
|
|
46
|
+
"@docusaurus/utils-validation": "3.7.0-canary-6231",
|
|
47
47
|
"@types/react-router-config": "^5.0.7",
|
|
48
48
|
"combine-promises": "^1.1.0",
|
|
49
49
|
"fs-extra": "^11.1.1",
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"engines": {
|
|
69
69
|
"node": ">=18.0"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "6a28543acaedb9fd6b7d7a6731dc9d89f45f5437"
|
|
72
72
|
}
|
package/src/index.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import path from 'path';
|
|
9
|
+
import fs from 'fs-extra';
|
|
9
10
|
import _ from 'lodash';
|
|
10
11
|
import logger from '@docusaurus/logger';
|
|
11
12
|
import {
|
|
@@ -63,6 +64,30 @@ import type {LoadContext, Plugin} from '@docusaurus/types';
|
|
|
63
64
|
import type {DocFile, FullVersion} from './types';
|
|
64
65
|
import type {RuleSetRule} from 'webpack';
|
|
65
66
|
|
|
67
|
+
// MDX loader is not 100% deterministic, leading to cache invalidation issue
|
|
68
|
+
// This permits to invalidate the MDX loader cache entries when content changes
|
|
69
|
+
// Problem documented here: https://github.com/facebook/docusaurus/pull/10934
|
|
70
|
+
// TODO this is not a perfect solution, find better?
|
|
71
|
+
async function createMdxLoaderDependencyFile({
|
|
72
|
+
dataDir,
|
|
73
|
+
options,
|
|
74
|
+
versionsMetadata,
|
|
75
|
+
}: {
|
|
76
|
+
dataDir: string;
|
|
77
|
+
options: PluginOptions;
|
|
78
|
+
versionsMetadata: VersionMetadata[];
|
|
79
|
+
}) {
|
|
80
|
+
const filePath = path.join(dataDir, '__mdx-loader-dependency.json');
|
|
81
|
+
// the cache is invalidated whenever this file content changes
|
|
82
|
+
const fileContent = {
|
|
83
|
+
options,
|
|
84
|
+
versionsMetadata,
|
|
85
|
+
};
|
|
86
|
+
await fs.ensureDir(dataDir);
|
|
87
|
+
await fs.writeFile(filePath, JSON.stringify(fileContent));
|
|
88
|
+
return filePath;
|
|
89
|
+
}
|
|
90
|
+
|
|
66
91
|
export default async function pluginContentDocs(
|
|
67
92
|
context: LoadContext,
|
|
68
93
|
options: PluginOptions,
|
|
@@ -107,6 +132,14 @@ export default async function pluginContentDocs(
|
|
|
107
132
|
return createMDXLoaderRule({
|
|
108
133
|
include: contentDirs,
|
|
109
134
|
options: {
|
|
135
|
+
dependencies: [
|
|
136
|
+
await createMdxLoaderDependencyFile({
|
|
137
|
+
dataDir,
|
|
138
|
+
options,
|
|
139
|
+
versionsMetadata,
|
|
140
|
+
}),
|
|
141
|
+
],
|
|
142
|
+
|
|
110
143
|
useCrossCompilerCache:
|
|
111
144
|
siteConfig.future.experimental_faster.mdxCrossCompilerCache,
|
|
112
145
|
admonitions: options.admonitions,
|
|
@@ -20,7 +20,11 @@ declare module '@docusaurus/plugin-content-docs' {
|
|
|
20
20
|
TagMetadata,
|
|
21
21
|
TagsPluginOptions,
|
|
22
22
|
} from '@docusaurus/utils';
|
|
23
|
-
import type {
|
|
23
|
+
import type {
|
|
24
|
+
Plugin,
|
|
25
|
+
LoadContext,
|
|
26
|
+
OptionValidationContext,
|
|
27
|
+
} from '@docusaurus/types';
|
|
24
28
|
import type {Overwrite, Required} from 'utility-types';
|
|
25
29
|
|
|
26
30
|
export type Assets = {
|
|
@@ -559,6 +563,10 @@ declare module '@docusaurus/plugin-content-docs' {
|
|
|
559
563
|
context: LoadContext,
|
|
560
564
|
options: PluginOptions,
|
|
561
565
|
): Promise<Plugin<LoadedContent>>;
|
|
566
|
+
|
|
567
|
+
export function validateOptions(
|
|
568
|
+
args: OptionValidationContext<Options | undefined, PluginOptions>,
|
|
569
|
+
): PluginOptions;
|
|
562
570
|
}
|
|
563
571
|
|
|
564
572
|
declare module '@theme/DocItem' {
|