@docusaurus/core 3.4.0 → 3.5.0
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/bin/docusaurus.mjs +13 -12
- package/lib/babel/preset.js +1 -1
- package/lib/client/App.d.ts +0 -2
- package/lib/client/BaseUrlIssueBanner/index.d.ts +0 -1
- package/lib/client/BrokenLinksContext.d.ts +0 -1
- package/lib/client/SiteMetadataDefaults.d.ts +0 -1
- package/lib/client/exports/BrowserOnly.d.ts +0 -2
- package/lib/client/exports/ErrorBoundary.d.ts +0 -1
- package/lib/client/exports/Head.d.ts +0 -2
- package/lib/client/exports/Interpolate.d.ts +0 -1
- package/lib/client/exports/Link.d.ts +0 -1
- package/lib/client/exports/Link.js +15 -4
- package/lib/client/exports/Translate.d.ts +0 -2
- package/lib/client/exports/useBaseUrl.d.ts +0 -1
- package/lib/client/exports/useBrokenLinks.d.ts +0 -1
- package/lib/client/hasHydratedDataAttribute.d.ts +0 -1
- package/lib/client/theme-fallback/Error/index.d.ts +0 -2
- package/lib/client/theme-fallback/Layout/index.d.ts +0 -2
- package/lib/client/theme-fallback/Loading/index.d.ts +0 -1
- package/lib/client/theme-fallback/NotFound/index.d.ts +0 -1
- package/lib/client/theme-fallback/Root/index.d.ts +0 -2
- package/lib/client/theme-fallback/SiteMetadata/index.d.ts +0 -1
- package/lib/commands/build.js +1 -2
- package/lib/commands/clear.js +1 -2
- package/lib/commands/deploy.js +1 -2
- package/lib/commands/external.js +1 -2
- package/lib/commands/serve.js +2 -3
- package/lib/commands/start/start.js +1 -2
- package/lib/commands/start/utils.js +2 -3
- package/lib/commands/start/watcher.js +5 -6
- package/lib/commands/start/webpack.js +1 -2
- package/lib/commands/swizzle/actions.js +4 -4
- package/lib/commands/swizzle/common.js +7 -7
- package/lib/commands/swizzle/components.js +5 -6
- package/lib/commands/swizzle/config.js +2 -3
- package/lib/commands/swizzle/context.js +19 -8
- package/lib/commands/swizzle/index.js +1 -2
- package/lib/commands/swizzle/prompts.js +4 -5
- package/lib/commands/swizzle/tables.js +2 -3
- package/lib/commands/swizzle/themes.js +5 -6
- package/lib/commands/writeHeadingIds.js +1 -2
- package/lib/commands/writeTranslations.js +1 -2
- package/lib/server/brokenLinks.js +1 -2
- package/lib/server/clientModules.js +1 -2
- package/lib/server/codegen/codegen.js +1 -2
- package/lib/server/codegen/codegenRoutes.js +4 -5
- package/lib/server/config.js +1 -2
- package/lib/server/configValidation.js +2 -2
- package/lib/server/getHostPort.js +1 -2
- package/lib/server/htmlTags.js +1 -2
- package/lib/server/i18n.js +2 -3
- package/lib/server/plugins/actions.js +1 -2
- package/lib/server/plugins/configs.js +1 -2
- package/lib/server/plugins/init.d.ts +11 -0
- package/lib/server/plugins/init.js +42 -7
- package/lib/server/plugins/moduleShorthand.d.ts +0 -1
- package/lib/server/plugins/moduleShorthand.js +2 -3
- package/lib/server/plugins/pluginIds.js +1 -2
- package/lib/server/plugins/plugins.js +2 -3
- package/lib/server/plugins/pluginsUtils.js +7 -8
- package/lib/server/plugins/presets.js +1 -2
- package/lib/server/plugins/routeConfig.js +2 -3
- package/lib/server/plugins/synthetic.js +2 -3
- package/lib/server/routes.js +2 -3
- package/lib/server/site.js +4 -5
- package/lib/server/siteMetadata.js +3 -4
- package/lib/server/storage.js +1 -2
- package/lib/server/translations/translations.js +9 -10
- package/lib/server/translations/translationsExtractor.js +4 -5
- package/lib/server/utils.js +1 -2
- package/lib/ssg.d.ts +0 -1
- package/lib/ssg.js +3 -4
- package/lib/templates/templates.js +3 -4
- package/lib/webpack/aliases/index.js +4 -5
- package/lib/webpack/base.js +3 -3
- package/lib/webpack/client.js +3 -4
- package/lib/webpack/configure.js +3 -4
- package/lib/webpack/minification.js +1 -2
- package/lib/webpack/plugins/StaticDirectoriesCopyPlugin.js +1 -2
- package/lib/webpack/server.js +1 -1
- package/lib/webpack/utils.d.ts +1 -2
- package/lib/webpack/utils.js +8 -8
- package/package.json +10 -10
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.applyRouteTrailingSlash = applyRouteTrailingSlash;
|
|
10
|
+
exports.sortRoutes = sortRoutes;
|
|
10
11
|
const utils_common_1 = require("@docusaurus/utils-common");
|
|
11
12
|
/** Recursively applies trailing slash config to all nested routes. */
|
|
12
13
|
function applyRouteTrailingSlash(route, params) {
|
|
@@ -18,7 +19,6 @@ function applyRouteTrailingSlash(route, params) {
|
|
|
18
19
|
}),
|
|
19
20
|
};
|
|
20
21
|
}
|
|
21
|
-
exports.applyRouteTrailingSlash = applyRouteTrailingSlash;
|
|
22
22
|
function sortRoutes(routesToSort, baseUrl) {
|
|
23
23
|
const routeConfigs = [...routesToSort];
|
|
24
24
|
// Sort the route config. This ensures that route with nested
|
|
@@ -71,4 +71,3 @@ function sortRoutes(routesToSort, baseUrl) {
|
|
|
71
71
|
});
|
|
72
72
|
return routeConfigs;
|
|
73
73
|
}
|
|
74
|
-
exports.sortRoutes = sortRoutes;
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.createBootstrapPlugin = createBootstrapPlugin;
|
|
10
|
+
exports.createMDXFallbackPlugin = createMDXFallbackPlugin;
|
|
10
11
|
const tslib_1 = require("tslib");
|
|
11
12
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
12
13
|
/**
|
|
@@ -50,7 +51,6 @@ function createBootstrapPlugin({ siteDir, siteConfig, }) {
|
|
|
50
51
|
},
|
|
51
52
|
};
|
|
52
53
|
}
|
|
53
|
-
exports.createBootstrapPlugin = createBootstrapPlugin;
|
|
54
54
|
/**
|
|
55
55
|
* Configure Webpack fallback mdx loader for md/mdx files out of content-plugin
|
|
56
56
|
* folders. Adds a "fallback" mdx loader for mdx files that are not processed by
|
|
@@ -106,4 +106,3 @@ function createMDXFallbackPlugin({ siteDir, siteConfig, }) {
|
|
|
106
106
|
},
|
|
107
107
|
};
|
|
108
108
|
}
|
|
109
|
-
exports.createMDXFallbackPlugin = createMDXFallbackPlugin;
|
package/lib/server/routes.js
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.handleDuplicateRoutes = handleDuplicateRoutes;
|
|
10
|
+
exports.getRoutesPaths = getRoutesPaths;
|
|
10
11
|
const tslib_1 = require("tslib");
|
|
11
12
|
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
12
13
|
const utils_1 = require("@docusaurus/utils");
|
|
@@ -28,7 +29,6 @@ function handleDuplicateRoutes(routes, onDuplicateRoutes) {
|
|
|
28
29
|
This could lead to non-deterministic routing behavior.`;
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
|
-
exports.handleDuplicateRoutes = handleDuplicateRoutes;
|
|
32
32
|
/**
|
|
33
33
|
* Old stuff
|
|
34
34
|
* As far as I understand, this is what permits to SSG the 404.html file
|
|
@@ -50,4 +50,3 @@ function getRoutesPaths(routeConfigs, baseUrl) {
|
|
|
50
50
|
...(0, utils_1.flattenRoutes)(routeConfigs).map((r) => r.path),
|
|
51
51
|
];
|
|
52
52
|
}
|
|
53
|
-
exports.getRoutesPaths = getRoutesPaths;
|
package/lib/server/site.js
CHANGED
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.loadContext = loadContext;
|
|
10
|
+
exports.loadSite = loadSite;
|
|
11
|
+
exports.reloadSite = reloadSite;
|
|
12
|
+
exports.reloadSitePlugin = reloadSitePlugin;
|
|
10
13
|
const tslib_1 = require("tslib");
|
|
11
14
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
12
15
|
const utils_1 = require("@docusaurus/utils");
|
|
@@ -69,7 +72,6 @@ async function loadContext(params) {
|
|
|
69
72
|
codeTranslations,
|
|
70
73
|
};
|
|
71
74
|
}
|
|
72
|
-
exports.loadContext = loadContext;
|
|
73
75
|
function createSiteProps(params) {
|
|
74
76
|
const { plugins, routes, context } = params;
|
|
75
77
|
const { generatedFilesDir, siteDir, siteVersion, siteConfig, siteConfigPath, siteStorage, outDir, baseUrl, i18n, localizationDir, codeTranslations: siteCodeTranslations, } = context;
|
|
@@ -141,14 +143,12 @@ async function loadSite(params) {
|
|
|
141
143
|
});
|
|
142
144
|
return site;
|
|
143
145
|
}
|
|
144
|
-
exports.loadSite = loadSite;
|
|
145
146
|
async function reloadSite(site) {
|
|
146
147
|
// TODO this can be optimized, for example:
|
|
147
148
|
// - plugins loading same data as before should not recreate routes/bundles
|
|
148
149
|
// - codegen does not need to re-run if nothing changed
|
|
149
150
|
return loadSite(site.params);
|
|
150
151
|
}
|
|
151
|
-
exports.reloadSite = reloadSite;
|
|
152
152
|
async function reloadSitePlugin(site, pluginIdentifier) {
|
|
153
153
|
const { plugins, routes, globalData } = await (0, plugins_1.reloadPlugin)({
|
|
154
154
|
pluginIdentifier,
|
|
@@ -169,4 +169,3 @@ async function reloadSitePlugin(site, pluginIdentifier) {
|
|
|
169
169
|
await createSiteFiles({ site: newSite, globalData });
|
|
170
170
|
return newSite;
|
|
171
171
|
}
|
|
172
|
-
exports.reloadSitePlugin = reloadSitePlugin;
|
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.loadSiteVersion = loadSiteVersion;
|
|
10
|
+
exports.loadPluginVersion = loadPluginVersion;
|
|
11
|
+
exports.createSiteMetadata = createSiteMetadata;
|
|
10
12
|
const tslib_1 = require("tslib");
|
|
11
13
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
12
14
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
@@ -25,7 +27,6 @@ async function loadPackageJsonName(packageJsonPath) {
|
|
|
25
27
|
async function loadSiteVersion(siteDir) {
|
|
26
28
|
return loadPackageJsonVersion(path_1.default.join(siteDir, 'package.json'));
|
|
27
29
|
}
|
|
28
|
-
exports.loadSiteVersion = loadSiteVersion;
|
|
29
30
|
async function loadPluginVersion(pluginPath, siteDir) {
|
|
30
31
|
let potentialPluginPackageJsonDirectory = path_1.default.dirname(pluginPath);
|
|
31
32
|
while (potentialPluginPackageJsonDirectory !== '/') {
|
|
@@ -50,7 +51,6 @@ async function loadPluginVersion(pluginPath, siteDir) {
|
|
|
50
51
|
// script in the parent directory of the site.
|
|
51
52
|
return { type: 'local' };
|
|
52
53
|
}
|
|
53
|
-
exports.loadPluginVersion = loadPluginVersion;
|
|
54
54
|
/**
|
|
55
55
|
* We want all `@docusaurus/*` packages to have the exact same version!
|
|
56
56
|
* @see https://github.com/facebook/docusaurus/issues/3371
|
|
@@ -80,4 +80,3 @@ function createSiteMetadata({ siteVersion, plugins, }) {
|
|
|
80
80
|
checkDocusaurusPackagesVersion(siteMetadata);
|
|
81
81
|
return siteMetadata;
|
|
82
82
|
}
|
|
83
|
-
exports.createSiteMetadata = createSiteMetadata;
|
package/lib/server/storage.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.createSiteStorage =
|
|
9
|
+
exports.createSiteStorage = createSiteStorage;
|
|
10
10
|
const utils_1 = require("@docusaurus/utils");
|
|
11
11
|
const utils_common_1 = require("@docusaurus/utils-common");
|
|
12
12
|
function automaticNamespace(config) {
|
|
@@ -33,4 +33,3 @@ function createSiteStorage(config) {
|
|
|
33
33
|
namespace,
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
-
exports.createSiteStorage = createSiteStorage;
|
|
@@ -6,7 +6,15 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.readCodeTranslationFileContent = readCodeTranslationFileContent;
|
|
10
|
+
exports.writeCodeTranslations = writeCodeTranslations;
|
|
11
|
+
exports.writePluginTranslations = writePluginTranslations;
|
|
12
|
+
exports.localizePluginTranslationFile = localizePluginTranslationFile;
|
|
13
|
+
exports.mergeCodeTranslations = mergeCodeTranslations;
|
|
14
|
+
exports.loadPluginsDefaultCodeTranslationMessages = loadPluginsDefaultCodeTranslationMessages;
|
|
15
|
+
exports.getPluginsDefaultCodeTranslations = getPluginsDefaultCodeTranslations;
|
|
16
|
+
exports.applyDefaultCodeTranslations = applyDefaultCodeTranslations;
|
|
17
|
+
exports.loadSiteCodeTranslations = loadSiteCodeTranslations;
|
|
10
18
|
const tslib_1 = require("tslib");
|
|
11
19
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
12
20
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
@@ -85,7 +93,6 @@ function getCodeTranslationsFilePath(context) {
|
|
|
85
93
|
async function readCodeTranslationFileContent(context) {
|
|
86
94
|
return readTranslationFileContent(getCodeTranslationsFilePath(context));
|
|
87
95
|
}
|
|
88
|
-
exports.readCodeTranslationFileContent = readCodeTranslationFileContent;
|
|
89
96
|
async function writeCodeTranslations(context, content, options) {
|
|
90
97
|
return writeTranslationFileContent({
|
|
91
98
|
filePath: getCodeTranslationsFilePath(context),
|
|
@@ -93,7 +100,6 @@ async function writeCodeTranslations(context, content, options) {
|
|
|
93
100
|
options,
|
|
94
101
|
});
|
|
95
102
|
}
|
|
96
|
-
exports.writeCodeTranslations = writeCodeTranslations;
|
|
97
103
|
// We ask users to not provide any extension on purpose:
|
|
98
104
|
// maybe some day we'll want to support multiple FS formats?
|
|
99
105
|
// (json/yaml/toml/xml...)
|
|
@@ -124,7 +130,6 @@ async function writePluginTranslations({ localizationDir, plugin, translationFil
|
|
|
124
130
|
options,
|
|
125
131
|
});
|
|
126
132
|
}
|
|
127
|
-
exports.writePluginTranslations = writePluginTranslations;
|
|
128
133
|
async function localizePluginTranslationFile({ localizationDir, plugin, translationFile, }) {
|
|
129
134
|
const filePath = getPluginTranslationFilePath({
|
|
130
135
|
plugin,
|
|
@@ -144,23 +149,19 @@ async function localizePluginTranslationFile({ localizationDir, plugin, translat
|
|
|
144
149
|
}
|
|
145
150
|
return translationFile;
|
|
146
151
|
}
|
|
147
|
-
exports.localizePluginTranslationFile = localizePluginTranslationFile;
|
|
148
152
|
function mergeCodeTranslations(codeTranslations) {
|
|
149
153
|
return codeTranslations.reduce((allCodeTranslations, current) => ({
|
|
150
154
|
...allCodeTranslations,
|
|
151
155
|
...current,
|
|
152
156
|
}), {});
|
|
153
157
|
}
|
|
154
|
-
exports.mergeCodeTranslations = mergeCodeTranslations;
|
|
155
158
|
async function loadPluginsDefaultCodeTranslationMessages(plugins) {
|
|
156
159
|
const pluginsMessages = await Promise.all(plugins.map((plugin) => plugin.getDefaultCodeTranslationMessages?.() ?? {}));
|
|
157
160
|
return mergeCodeTranslations(pluginsMessages);
|
|
158
161
|
}
|
|
159
|
-
exports.loadPluginsDefaultCodeTranslationMessages = loadPluginsDefaultCodeTranslationMessages;
|
|
160
162
|
function getPluginsDefaultCodeTranslations({ plugins, }) {
|
|
161
163
|
return mergeCodeTranslations(plugins.map((p) => p.defaultCodeTranslations));
|
|
162
164
|
}
|
|
163
|
-
exports.getPluginsDefaultCodeTranslations = getPluginsDefaultCodeTranslations;
|
|
164
165
|
function applyDefaultCodeTranslations({ extractedCodeTranslations, defaultCodeMessages, }) {
|
|
165
166
|
const unusedDefaultCodeMessages = lodash_1.default.difference(Object.keys(defaultCodeMessages), Object.keys(extractedCodeTranslations));
|
|
166
167
|
if (unusedDefaultCodeMessages.length > 0) {
|
|
@@ -172,10 +173,8 @@ Please report this Docusaurus issue. name=${unusedDefaultCodeMessages}`;
|
|
|
172
173
|
message: defaultCodeMessages[messageId] ?? messageTranslation.message,
|
|
173
174
|
}));
|
|
174
175
|
}
|
|
175
|
-
exports.applyDefaultCodeTranslations = applyDefaultCodeTranslations;
|
|
176
176
|
async function loadSiteCodeTranslations({ localizationDir, }) {
|
|
177
177
|
const codeTranslationFileContent = (await readCodeTranslationFileContent({ localizationDir })) ?? {};
|
|
178
178
|
// We only need key->message for code translations
|
|
179
179
|
return lodash_1.default.mapValues(codeTranslationFileContent, (value) => value.message);
|
|
180
180
|
}
|
|
181
|
-
exports.loadSiteCodeTranslations = loadSiteCodeTranslations;
|
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.globSourceCodeFilePaths = globSourceCodeFilePaths;
|
|
10
|
+
exports.extractSiteSourceCodeTranslations = extractSiteSourceCodeTranslations;
|
|
11
|
+
exports.extractAllSourceCodeFileTranslations = extractAllSourceCodeFileTranslations;
|
|
12
|
+
exports.extractSourceCodeFileTranslations = extractSourceCodeFileTranslations;
|
|
10
13
|
const tslib_1 = require("tslib");
|
|
11
14
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
12
15
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
@@ -50,7 +53,6 @@ async function globSourceCodeFilePaths(dirPaths) {
|
|
|
50
53
|
const filePaths = await (0, utils_2.safeGlobby)(dirPaths);
|
|
51
54
|
return filePaths.filter(isTranslatableSourceCodePath);
|
|
52
55
|
}
|
|
53
|
-
exports.globSourceCodeFilePaths = globSourceCodeFilePaths;
|
|
54
56
|
async function getSourceCodeFilePaths(siteDir, plugins) {
|
|
55
57
|
const sitePaths = getSiteSourceCodeFilePaths(siteDir);
|
|
56
58
|
// The getPathsToWatch() generally returns the js/jsx/ts/tsx/md/mdx file paths
|
|
@@ -76,7 +78,6 @@ async function extractSiteSourceCodeTranslations(siteDir, plugins, babelOptions,
|
|
|
76
78
|
logSourceCodeFileTranslationsWarnings(sourceCodeFilesTranslations);
|
|
77
79
|
return toTranslationFileContent(sourceCodeFilesTranslations);
|
|
78
80
|
}
|
|
79
|
-
exports.extractSiteSourceCodeTranslations = extractSiteSourceCodeTranslations;
|
|
80
81
|
function logSourceCodeFileTranslationsWarnings(sourceCodeFilesTranslations) {
|
|
81
82
|
sourceCodeFilesTranslations.forEach(({ sourceCodeFilePath, warnings }) => {
|
|
82
83
|
if (warnings.length > 0) {
|
|
@@ -87,7 +88,6 @@ function logSourceCodeFileTranslationsWarnings(sourceCodeFilesTranslations) {
|
|
|
87
88
|
async function extractAllSourceCodeFileTranslations(sourceCodeFilePaths, babelOptions) {
|
|
88
89
|
return Promise.all(sourceCodeFilePaths.flatMap((sourceFilePath) => extractSourceCodeFileTranslations(sourceFilePath, babelOptions)));
|
|
89
90
|
}
|
|
90
|
-
exports.extractAllSourceCodeFileTranslations = extractAllSourceCodeFileTranslations;
|
|
91
91
|
async function extractSourceCodeFileTranslations(sourceCodeFilePath, babelOptions) {
|
|
92
92
|
try {
|
|
93
93
|
const code = await fs_extra_1.default.readFile(sourceCodeFilePath, 'utf8');
|
|
@@ -107,7 +107,6 @@ async function extractSourceCodeFileTranslations(sourceCodeFilePath, babelOption
|
|
|
107
107
|
throw err;
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
-
exports.extractSourceCodeFileTranslations = extractSourceCodeFileTranslations;
|
|
111
110
|
/*
|
|
112
111
|
Need help understanding this?
|
|
113
112
|
|
package/lib/server/utils.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.safeGlobby =
|
|
9
|
+
exports.safeGlobby = safeGlobby;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
12
12
|
const utils_1 = require("@docusaurus/utils");
|
|
@@ -18,4 +18,3 @@ async function safeGlobby(patterns, options) {
|
|
|
18
18
|
const globPaths = patterns.map((dirPath) => (0, utils_1.posixPath)(path_1.default.relative(process.cwd(), dirPath)));
|
|
19
19
|
return (0, utils_1.Globby)(globPaths, options);
|
|
20
20
|
}
|
|
21
|
-
exports.safeGlobby = safeGlobby;
|
package/lib/ssg.d.ts
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
/// <reference path="../src/deps.d.ts" />
|
|
8
7
|
import type { AppRenderer, SiteCollectedData } from './common';
|
|
9
8
|
import type { Manifest } from 'react-loadable-ssr-addon-v5-slorber';
|
|
10
9
|
import type { SSRTemplateCompiled } from './templates/templates';
|
package/lib/ssg.js
CHANGED
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.loadAppRenderer = loadAppRenderer;
|
|
10
|
+
exports.generateStaticFiles = generateStaticFiles;
|
|
11
|
+
exports.generateHashRouterEntrypoint = generateHashRouterEntrypoint;
|
|
10
12
|
const tslib_1 = require("tslib");
|
|
11
13
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
12
14
|
const module_1 = require("module");
|
|
@@ -49,7 +51,6 @@ async function loadAppRenderer({ serverBundlePath, }) {
|
|
|
49
51
|
}
|
|
50
52
|
return serverEntry.default;
|
|
51
53
|
}
|
|
52
|
-
exports.loadAppRenderer = loadAppRenderer;
|
|
53
54
|
function pathnameToFilename({ pathname, trailingSlash, }) {
|
|
54
55
|
const outputFileName = pathname.replace(/^[/\\]/, ''); // Remove leading slashes for webpack-dev-server
|
|
55
56
|
// Paths ending with .html are left untouched
|
|
@@ -92,7 +93,6 @@ async function generateStaticFiles({ pathnames, renderer, params, }) {
|
|
|
92
93
|
.value();
|
|
93
94
|
return { collectedData };
|
|
94
95
|
}
|
|
95
|
-
exports.generateStaticFiles = generateStaticFiles;
|
|
96
96
|
async function generateStaticFile({ pathname, renderer, params, }) {
|
|
97
97
|
try {
|
|
98
98
|
// This only renders the app HTML
|
|
@@ -140,7 +140,6 @@ async function generateHashRouterEntrypoint({ content, params, }) {
|
|
|
140
140
|
params,
|
|
141
141
|
});
|
|
142
142
|
}
|
|
143
|
-
exports.generateHashRouterEntrypoint = generateHashRouterEntrypoint;
|
|
144
143
|
async function writeStaticFile({ content, pathname, params, }) {
|
|
145
144
|
function removeBaseUrl(p, baseUrl) {
|
|
146
145
|
return baseUrl === '/' ? p : p.replace(new RegExp(`^${baseUrl}`), '/');
|
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.compileSSRTemplate = compileSSRTemplate;
|
|
10
|
+
exports.renderSSRTemplate = renderSSRTemplate;
|
|
11
|
+
exports.renderHashRouterTemplate = renderHashRouterTemplate;
|
|
10
12
|
const tslib_1 = require("tslib");
|
|
11
13
|
const eta = tslib_1.__importStar(require("eta"));
|
|
12
14
|
const react_loadable_ssr_addon_v5_slorber_1 = require("react-loadable-ssr-addon-v5-slorber");
|
|
@@ -16,7 +18,6 @@ async function compileSSRTemplate(template) {
|
|
|
16
18
|
});
|
|
17
19
|
return (data) => compiledTemplate(data, eta.defaultConfig);
|
|
18
20
|
}
|
|
19
|
-
exports.compileSSRTemplate = compileSSRTemplate;
|
|
20
21
|
/**
|
|
21
22
|
* Given a list of modules that were SSR an d
|
|
22
23
|
* @param modules
|
|
@@ -60,7 +61,6 @@ function renderSSRTemplate({ params, result, }) {
|
|
|
60
61
|
};
|
|
61
62
|
return ssrTemplate(data);
|
|
62
63
|
}
|
|
63
|
-
exports.renderSSRTemplate = renderSSRTemplate;
|
|
64
64
|
function renderHashRouterTemplate({ params, }) {
|
|
65
65
|
const {
|
|
66
66
|
// baseUrl,
|
|
@@ -85,4 +85,3 @@ function renderHashRouterTemplate({ params, }) {
|
|
|
85
85
|
};
|
|
86
86
|
return ssrTemplate(data);
|
|
87
87
|
}
|
|
88
|
-
exports.renderHashRouterTemplate = renderHashRouterTemplate;
|
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.sortAliases = sortAliases;
|
|
10
|
+
exports.createAliasesForTheme = createAliasesForTheme;
|
|
11
|
+
exports.loadThemeAliases = loadThemeAliases;
|
|
12
|
+
exports.loadDocusaurusAliases = loadDocusaurusAliases;
|
|
10
13
|
const tslib_1 = require("tslib");
|
|
11
14
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
12
15
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
@@ -30,7 +33,6 @@ function sortAliases(aliases) {
|
|
|
30
33
|
alias1.includes(`${alias2}/`) ? -1 : alias2.includes(`${alias1}/`) ? 1 : 0);
|
|
31
34
|
return Object.fromEntries(entries);
|
|
32
35
|
}
|
|
33
|
-
exports.sortAliases = sortAliases;
|
|
34
36
|
async function createAliasesForTheme(themePath, addOriginalAlias) {
|
|
35
37
|
if (!(await fs_extra_1.default.pathExists(themePath))) {
|
|
36
38
|
return {};
|
|
@@ -52,7 +54,6 @@ async function createAliasesForTheme(themePath, addOriginalAlias) {
|
|
|
52
54
|
});
|
|
53
55
|
return sortAliases(aliases);
|
|
54
56
|
}
|
|
55
|
-
exports.createAliasesForTheme = createAliasesForTheme;
|
|
56
57
|
async function createThemeAliases(themePaths, userThemePaths) {
|
|
57
58
|
const aliases = {};
|
|
58
59
|
for (const themePath of themePaths) {
|
|
@@ -84,7 +85,6 @@ function loadThemeAliases({ siteDir, plugins, }) {
|
|
|
84
85
|
const userTheme = path_1.default.resolve(siteDir, utils_1.THEME_PATH);
|
|
85
86
|
return createThemeAliases([ThemeFallbackDir, ...pluginThemes], [userTheme]);
|
|
86
87
|
}
|
|
87
|
-
exports.loadThemeAliases = loadThemeAliases;
|
|
88
88
|
/**
|
|
89
89
|
* Note: a `@docusaurus` alias would also catch `@docusaurus/theme-common`, so
|
|
90
90
|
* instead of naively aliasing this to `client/exports`, we use fine-grained
|
|
@@ -103,4 +103,3 @@ async function loadDocusaurusAliases() {
|
|
|
103
103
|
});
|
|
104
104
|
return aliases;
|
|
105
105
|
}
|
|
106
|
-
exports.loadDocusaurusAliases = loadDocusaurusAliases;
|
package/lib/webpack/base.js
CHANGED
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.clientDir = void 0;
|
|
10
|
+
exports.excludeJS = excludeJS;
|
|
11
|
+
exports.createBaseConfig = createBaseConfig;
|
|
10
12
|
const tslib_1 = require("tslib");
|
|
11
13
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
12
14
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
@@ -32,7 +34,6 @@ function excludeJS(modulePath) {
|
|
|
32
34
|
!/docusaurus(?:(?!node_modules).)*\.jsx?$/.test(modulePath) &&
|
|
33
35
|
!LibrariesToTranspileRegex.test(modulePath));
|
|
34
36
|
}
|
|
35
|
-
exports.excludeJS = excludeJS;
|
|
36
37
|
async function createBaseConfig({ props, isServer, minify, }) {
|
|
37
38
|
const { outDir, siteDir, siteConfig, siteConfigPath, baseUrl, generatedFilesDir, routesPaths, siteMetadata, plugins, } = props;
|
|
38
39
|
const totalPages = routesPaths.length;
|
|
@@ -212,4 +213,3 @@ async function createBaseConfig({ props, isServer, minify, }) {
|
|
|
212
213
|
],
|
|
213
214
|
};
|
|
214
215
|
}
|
|
215
|
-
exports.createBaseConfig = createBaseConfig;
|
package/lib/webpack/client.js
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.createStartClientConfig = createStartClientConfig;
|
|
10
|
+
exports.createBuildClientConfig = createBuildClientConfig;
|
|
10
11
|
const tslib_1 = require("tslib");
|
|
11
12
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
12
13
|
const webpack_merge_1 = tslib_1.__importDefault(require("webpack-merge"));
|
|
@@ -42,7 +43,7 @@ async function createBaseClientConfig({ props, hydrate, minify, }) {
|
|
|
42
43
|
name: 'Client',
|
|
43
44
|
}),
|
|
44
45
|
await (0, StaticDirectoriesCopyPlugin_1.createStaticDirectoriesCopyPlugin)({ props }),
|
|
45
|
-
],
|
|
46
|
+
].filter(Boolean),
|
|
46
47
|
});
|
|
47
48
|
}
|
|
48
49
|
// client config when running "docusaurus start"
|
|
@@ -77,7 +78,6 @@ async function createStartClientConfig({ props, minify, poll, }) {
|
|
|
77
78
|
});
|
|
78
79
|
return { clientConfig };
|
|
79
80
|
}
|
|
80
|
-
exports.createStartClientConfig = createStartClientConfig;
|
|
81
81
|
// client config when running "docusaurus build"
|
|
82
82
|
async function createBuildClientConfig({ props, minify, bundleAnalyzer, }) {
|
|
83
83
|
// Apply user webpack config.
|
|
@@ -103,4 +103,3 @@ async function createBuildClientConfig({ props, minify, bundleAnalyzer, }) {
|
|
|
103
103
|
});
|
|
104
104
|
return { config, clientManifestPath };
|
|
105
105
|
}
|
|
106
|
-
exports.createBuildClientConfig = createBuildClientConfig;
|
package/lib/webpack/configure.js
CHANGED
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.applyConfigureWebpack = applyConfigureWebpack;
|
|
10
|
+
exports.applyConfigurePostCss = applyConfigurePostCss;
|
|
11
|
+
exports.executePluginsConfigureWebpack = executePluginsConfigureWebpack;
|
|
10
12
|
const webpack_merge_1 = require("webpack-merge");
|
|
11
13
|
const utils_1 = require("./utils");
|
|
12
14
|
/**
|
|
@@ -34,7 +36,6 @@ function applyConfigureWebpack(configureWebpack, config, isServer, jsLoader, con
|
|
|
34
36
|
}
|
|
35
37
|
return config;
|
|
36
38
|
}
|
|
37
|
-
exports.applyConfigureWebpack = applyConfigureWebpack;
|
|
38
39
|
function applyConfigurePostCss(configurePostCss, config) {
|
|
39
40
|
// Not ideal heuristic but good enough for our use-case?
|
|
40
41
|
function isPostCssLoader(loader) {
|
|
@@ -61,7 +62,6 @@ function applyConfigurePostCss(configurePostCss, config) {
|
|
|
61
62
|
config.module?.rules?.forEach((rule) => overridePostCssOptions(rule));
|
|
62
63
|
return config;
|
|
63
64
|
}
|
|
64
|
-
exports.applyConfigurePostCss = applyConfigurePostCss;
|
|
65
65
|
// Plugin Lifecycle - configurePostCss()
|
|
66
66
|
function executePluginsConfigurePostCss({ plugins, config, }) {
|
|
67
67
|
let resultConfig = config;
|
|
@@ -97,4 +97,3 @@ function executePluginsConfigureWebpack({ plugins, config, isServer, jsLoader, }
|
|
|
97
97
|
}
|
|
98
98
|
return resultConfig;
|
|
99
99
|
}
|
|
100
|
-
exports.executePluginsConfigureWebpack = executePluginsConfigureWebpack;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.getMinimizer =
|
|
9
|
+
exports.getMinimizer = getMinimizer;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const terser_webpack_plugin_1 = tslib_1.__importDefault(require("terser-webpack-plugin"));
|
|
12
12
|
const css_minimizer_webpack_plugin_1 = tslib_1.__importDefault(require("css-minimizer-webpack-plugin"));
|
|
@@ -94,4 +94,3 @@ function getMinimizer() {
|
|
|
94
94
|
}
|
|
95
95
|
return minimizer;
|
|
96
96
|
}
|
|
97
|
-
exports.getMinimizer = getMinimizer;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.createStaticDirectoriesCopyPlugin =
|
|
9
|
+
exports.createStaticDirectoriesCopyPlugin = createStaticDirectoriesCopyPlugin;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
12
12
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
@@ -36,4 +36,3 @@ async function createStaticDirectoriesCopyPlugin({ props, }) {
|
|
|
36
36
|
})),
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
|
-
exports.createStaticDirectoriesCopyPlugin = createStaticDirectoriesCopyPlugin;
|
package/lib/webpack/server.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.default = createServerConfig;
|
|
9
10
|
const tslib_1 = require("tslib");
|
|
10
11
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
11
12
|
const webpack_merge_1 = tslib_1.__importDefault(require("webpack-merge"));
|
|
@@ -43,4 +44,3 @@ async function createServerConfig(params) {
|
|
|
43
44
|
});
|
|
44
45
|
return { config, serverBundlePath };
|
|
45
46
|
}
|
|
46
|
-
exports.default = createServerConfig;
|
package/lib/webpack/utils.d.ts
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
/// <reference types="node" />
|
|
8
7
|
import webpack, { type Configuration, type RuleSetRule } from 'webpack';
|
|
9
8
|
import type { TransformOptions } from '@babel/core';
|
|
10
9
|
export declare function formatStatsErrorMessage(statsJson: ReturnType<webpack.Stats['toJson']> | undefined): string | undefined;
|
|
@@ -17,7 +16,7 @@ export declare function getBabelOptions({ isServer, babelOptions, }?: {
|
|
|
17
16
|
isServer?: boolean;
|
|
18
17
|
babelOptions?: TransformOptions | string;
|
|
19
18
|
}): TransformOptions;
|
|
20
|
-
export declare const getCustomizableJSLoader: (jsLoader?:
|
|
19
|
+
export declare const getCustomizableJSLoader: (jsLoader?: "babel" | ((isServer: boolean) => RuleSetRule)) => ({ isServer, babelOptions, }: {
|
|
21
20
|
isServer: boolean;
|
|
22
21
|
babelOptions?: TransformOptions | string;
|
|
23
22
|
}) => RuleSetRule;
|
package/lib/webpack/utils.js
CHANGED
|
@@ -6,7 +6,14 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.getCustomizableJSLoader = void 0;
|
|
10
|
+
exports.formatStatsErrorMessage = formatStatsErrorMessage;
|
|
11
|
+
exports.printStatsWarnings = printStatsWarnings;
|
|
12
|
+
exports.getStyleLoaders = getStyleLoaders;
|
|
13
|
+
exports.getCustomBabelConfigFilePath = getCustomBabelConfigFilePath;
|
|
14
|
+
exports.getBabelOptions = getBabelOptions;
|
|
15
|
+
exports.compile = compile;
|
|
16
|
+
exports.getHttpsConfig = getHttpsConfig;
|
|
10
17
|
const tslib_1 = require("tslib");
|
|
11
18
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
12
19
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
@@ -28,7 +35,6 @@ function formatStatsErrorMessage(statsJson) {
|
|
|
28
35
|
}
|
|
29
36
|
return undefined;
|
|
30
37
|
}
|
|
31
|
-
exports.formatStatsErrorMessage = formatStatsErrorMessage;
|
|
32
38
|
function printStatsWarnings(statsJson) {
|
|
33
39
|
if (statsJson?.warnings?.length) {
|
|
34
40
|
statsJson.warnings?.forEach((warning) => {
|
|
@@ -36,7 +42,6 @@ function printStatsWarnings(statsJson) {
|
|
|
36
42
|
});
|
|
37
43
|
}
|
|
38
44
|
}
|
|
39
|
-
exports.printStatsWarnings = printStatsWarnings;
|
|
40
45
|
// Utility method to get style loaders
|
|
41
46
|
function getStyleLoaders(isServer, cssOptionsArg = {}) {
|
|
42
47
|
const cssOptions = {
|
|
@@ -97,14 +102,12 @@ function getStyleLoaders(isServer, cssOptionsArg = {}) {
|
|
|
97
102
|
},
|
|
98
103
|
];
|
|
99
104
|
}
|
|
100
|
-
exports.getStyleLoaders = getStyleLoaders;
|
|
101
105
|
async function getCustomBabelConfigFilePath(siteDir) {
|
|
102
106
|
const customBabelConfigurationPath = path_1.default.join(siteDir, utils_1.BABEL_CONFIG_FILE_NAME);
|
|
103
107
|
return (await fs_extra_1.default.pathExists(customBabelConfigurationPath))
|
|
104
108
|
? customBabelConfigurationPath
|
|
105
109
|
: undefined;
|
|
106
110
|
}
|
|
107
|
-
exports.getCustomBabelConfigFilePath = getCustomBabelConfigFilePath;
|
|
108
111
|
function getBabelOptions({ isServer, babelOptions, } = {}) {
|
|
109
112
|
if (typeof babelOptions === 'string') {
|
|
110
113
|
return {
|
|
@@ -120,7 +123,6 @@ function getBabelOptions({ isServer, babelOptions, } = {}) {
|
|
|
120
123
|
caller: { name: isServer ? 'server' : 'client' },
|
|
121
124
|
};
|
|
122
125
|
}
|
|
123
|
-
exports.getBabelOptions = getBabelOptions;
|
|
124
126
|
// Name is generic on purpose
|
|
125
127
|
// we want to support multiple js loader implementations (babel + esbuild)
|
|
126
128
|
function getDefaultBabelLoader({ isServer, babelOptions, }) {
|
|
@@ -165,7 +167,6 @@ function compile(config) {
|
|
|
165
167
|
});
|
|
166
168
|
});
|
|
167
169
|
}
|
|
168
|
-
exports.compile = compile;
|
|
169
170
|
// Ensure the certificate and key provided are valid and if not
|
|
170
171
|
// throw an easy to debug error
|
|
171
172
|
function validateKeyAndCerts({ cert, key, keyFile, crtFile, }) {
|
|
@@ -212,4 +213,3 @@ async function getHttpsConfig() {
|
|
|
212
213
|
}
|
|
213
214
|
return isHttps;
|
|
214
215
|
}
|
|
215
|
-
exports.getHttpsConfig = getHttpsConfig;
|