@docusaurus/core 3.7.0 → 3.8.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.
Files changed (47) hide show
  1. package/bin/beforeCli.mjs +3 -3
  2. package/lib/client/App.js +7 -4
  3. package/lib/client/serverEntry.js +10 -4
  4. package/lib/client/serverHelmetUtils.d.ts +11 -0
  5. package/lib/client/serverHelmetUtils.js +39 -0
  6. package/lib/client/theme-fallback/ThemeProvider/index.d.ts +9 -0
  7. package/lib/client/theme-fallback/ThemeProvider/index.js +17 -0
  8. package/lib/commands/build/buildLocale.js +33 -10
  9. package/lib/commands/clear.js +4 -3
  10. package/lib/commands/deploy.js +70 -28
  11. package/lib/commands/serve.js +2 -2
  12. package/lib/commands/start/start.js +7 -4
  13. package/lib/commands/start/utils.js +17 -3
  14. package/lib/commands/start/webpack.js +1 -1
  15. package/lib/commands/utils/clearPath.d.ts +10 -0
  16. package/lib/commands/utils/clearPath.js +21 -0
  17. package/lib/commands/utils/legacy/evalSourceMapMiddleware.d.ts +2 -0
  18. package/lib/commands/utils/legacy/evalSourceMapMiddleware.js +57 -0
  19. package/lib/commands/utils/openBrowser/openBrowser.d.ts +10 -0
  20. package/lib/commands/utils/openBrowser/openBrowser.js +124 -0
  21. package/lib/commands/utils/openBrowser/openChrome.applescript +94 -0
  22. package/lib/server/configValidation.d.ts +3 -1
  23. package/lib/server/configValidation.js +45 -4
  24. package/lib/ssg/ssgEnv.d.ts +10 -0
  25. package/lib/ssg/ssgEnv.js +38 -0
  26. package/lib/ssg/ssgExecutor.js +121 -8
  27. package/lib/ssg/ssgGlobalResult.d.ts +12 -0
  28. package/lib/ssg/ssgGlobalResult.js +74 -0
  29. package/lib/ssg/ssgParams.d.ts +1 -0
  30. package/lib/ssg/ssgParams.js +1 -0
  31. package/lib/ssg/ssgRenderer.d.ts +29 -0
  32. package/lib/ssg/{ssg.js → ssgRenderer.js} +55 -90
  33. package/lib/ssg/ssgTemplate.js +6 -7
  34. package/lib/ssg/ssgUtils.d.ts +0 -1
  35. package/lib/ssg/ssgUtils.js +0 -9
  36. package/lib/ssg/ssgWorkerInline.d.ts +12 -0
  37. package/lib/ssg/ssgWorkerInline.js +17 -0
  38. package/lib/ssg/ssgWorkerThread.d.ts +13 -0
  39. package/lib/ssg/ssgWorkerThread.js +36 -0
  40. package/lib/webpack/base.js +76 -28
  41. package/lib/webpack/client.js +0 -3
  42. package/lib/webpack/plugins/BundlerCPUProfilerPlugin.d.ts +12 -0
  43. package/lib/webpack/plugins/BundlerCPUProfilerPlugin.js +41 -0
  44. package/package.json +14 -14
  45. package/lib/ssg/ssg.d.ts +0 -21
  46. package/lib/webpack/plugins/CleanWebpackPlugin.d.ts +0 -59
  47. package/lib/webpack/plugins/CleanWebpackPlugin.js +0 -177
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",
4
+ "version": "3.8.0",
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",
37
- "@docusaurus/bundler": "3.7.0",
38
- "@docusaurus/logger": "3.7.0",
39
- "@docusaurus/mdx-loader": "3.7.0",
40
- "@docusaurus/utils": "3.7.0",
41
- "@docusaurus/utils-common": "3.7.0",
42
- "@docusaurus/utils-validation": "3.7.0",
36
+ "@docusaurus/babel": "3.8.0",
37
+ "@docusaurus/bundler": "3.8.0",
38
+ "@docusaurus/logger": "3.8.0",
39
+ "@docusaurus/mdx-loader": "3.8.0",
40
+ "@docusaurus/utils": "3.8.0",
41
+ "@docusaurus/utils-common": "3.8.0",
42
+ "@docusaurus/utils-validation": "3.8.0",
43
43
  "boxen": "^6.2.1",
44
44
  "chalk": "^4.1.2",
45
45
  "chokidar": "^3.5.3",
@@ -47,19 +47,19 @@
47
47
  "combine-promises": "^1.1.0",
48
48
  "commander": "^5.1.0",
49
49
  "core-js": "^3.31.1",
50
- "del": "^6.1.1",
51
50
  "detect-port": "^1.5.1",
52
51
  "escape-html": "^1.0.3",
53
52
  "eta": "^2.2.0",
54
53
  "eval": "^0.1.8",
54
+ "execa": "5.1.1",
55
55
  "fs-extra": "^11.1.1",
56
56
  "html-tags": "^3.3.1",
57
57
  "html-webpack-plugin": "^5.6.0",
58
58
  "leven": "^3.1.0",
59
59
  "lodash": "^4.17.21",
60
+ "open": "^8.4.0",
60
61
  "p-map": "^4.0.0",
61
62
  "prompts": "^2.4.2",
62
- "react-dev-utils": "^12.0.1",
63
63
  "react-helmet-async": "npm:@slorber/react-helmet-async@1.3.0",
64
64
  "react-loadable": "npm:@docusaurus/react-loadable@6.0.0",
65
65
  "react-loadable-ssr-addon-v5-slorber": "^1.0.1",
@@ -68,7 +68,7 @@
68
68
  "react-router-dom": "^5.3.4",
69
69
  "semver": "^7.5.4",
70
70
  "serve-handler": "^6.1.6",
71
- "shelljs": "^0.8.5",
71
+ "tinypool": "^1.0.2",
72
72
  "tslib": "^2.6.0",
73
73
  "update-notifier": "^6.0.2",
74
74
  "webpack": "^5.95.0",
@@ -77,8 +77,8 @@
77
77
  "webpack-merge": "^6.0.1"
78
78
  },
79
79
  "devDependencies": {
80
- "@docusaurus/module-type-aliases": "3.7.0",
81
- "@docusaurus/types": "3.7.0",
80
+ "@docusaurus/module-type-aliases": "3.8.0",
81
+ "@docusaurus/types": "3.8.0",
82
82
  "@total-typescript/shoehorn": "^0.1.2",
83
83
  "@types/detect-port": "^1.3.3",
84
84
  "@types/react-dom": "^18.2.7",
@@ -98,5 +98,5 @@
98
98
  "engines": {
99
99
  "node": ">=18.0"
100
100
  },
101
- "gitHead": "dd59750c16fe6908a26f18806a54d4c3dbe6db43"
101
+ "gitHead": "948d63c42fad0ba24b7b531a9deb6167e64dc845"
102
102
  }
package/lib/ssg/ssg.d.ts DELETED
@@ -1,21 +0,0 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
- import type { SSGParams } from './ssgParams';
8
- import type { AppRenderer, SiteCollectedData } from '../common';
9
- export declare function loadAppRenderer({ serverBundlePath, }: {
10
- serverBundlePath: string;
11
- }): Promise<AppRenderer>;
12
- export declare function printSSGWarnings(results: {
13
- pathname: string;
14
- warnings: string[];
15
- }[]): void;
16
- export declare function generateStaticFiles({ pathnames, params, }: {
17
- pathnames: string[];
18
- params: SSGParams;
19
- }): Promise<{
20
- collectedData: SiteCollectedData;
21
- }>;
@@ -1,59 +0,0 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
- import type { Compiler, Stats } from 'webpack';
8
- export type Options = {
9
- /**
10
- * Write Logs to Console
11
- * (Always enabled when dry is true)
12
- *
13
- * default: false
14
- */
15
- verbose?: boolean;
16
- /**
17
- * Automatically remove all unused webpack assets on rebuild
18
- *
19
- * default: true
20
- */
21
- cleanStaleWebpackAssets?: boolean;
22
- /**
23
- * Do not allow removal of current webpack assets
24
- *
25
- * default: true
26
- */
27
- protectWebpackAssets?: boolean;
28
- /**
29
- * Removes files once prior to Webpack compilation
30
- * Not included in rebuilds (watch mode)
31
- *
32
- * Use !negative patterns to exclude files
33
- *
34
- * default: ['**\/*']
35
- */
36
- cleanOnceBeforeBuildPatterns?: string[];
37
- };
38
- export default class CleanWebpackPlugin {
39
- private readonly verbose;
40
- private readonly cleanStaleWebpackAssets;
41
- private readonly protectWebpackAssets;
42
- private readonly cleanOnceBeforeBuildPatterns;
43
- private currentAssets;
44
- private initialClean;
45
- private outputPath;
46
- constructor(options?: Options);
47
- apply(compiler: Compiler): void;
48
- /**
49
- * Initially remove files from output directory prior to build.
50
- *
51
- * Only happens once.
52
- *
53
- * Warning: It is recommended to initially clean your build directory outside
54
- * of webpack to minimize unexpected behavior.
55
- */
56
- handleInitial(): void;
57
- handleDone(stats: Stats): void;
58
- removeFiles(patterns: string[]): void;
59
- }
@@ -1,177 +0,0 @@
1
- "use strict";
2
- /**
3
- * Copyright (c) Facebook, Inc. and its affiliates.
4
- *
5
- * This source code is licensed under the MIT license found in the
6
- * LICENSE file in the root directory of this source tree.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- const tslib_1 = require("tslib");
10
- /**
11
- * The MIT License (MIT)
12
- * Copyright (c) 2015 John Agan
13
- * Permission is hereby granted, free of charge, to any person obtaining a copy
14
- * of this software and associated documentation files (the "Software"), to deal
15
- * in the Software without restriction, including without limitation the rights
16
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
- * copies of the Software, and to permit persons to whom the Software is
18
- * furnished to do so, subject to the following conditions:
19
- * The above copyright notice and this permission notice shall be included in
20
- * all copies or substantial portions of the Software.
21
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
- * SOFTWARE.
28
- */
29
- // Forked from https://github.com/johnagan/clean-webpack-plugin
30
- // Modified to optimize performance for Docusaurus specific use case
31
- // More context: https://github.com/facebook/docusaurus/pull/1839
32
- const path_1 = tslib_1.__importDefault(require("path"));
33
- const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
34
- const del_1 = require("del");
35
- class CleanWebpackPlugin {
36
- constructor(options = {}) {
37
- this.verbose = options.verbose === true || false;
38
- this.cleanStaleWebpackAssets =
39
- options.cleanStaleWebpackAssets === true ||
40
- options.cleanStaleWebpackAssets === false
41
- ? options.cleanStaleWebpackAssets
42
- : true;
43
- this.protectWebpackAssets =
44
- options.protectWebpackAssets === true ||
45
- options.protectWebpackAssets === false
46
- ? options.protectWebpackAssets
47
- : true;
48
- this.cleanOnceBeforeBuildPatterns = Array.isArray(options.cleanOnceBeforeBuildPatterns)
49
- ? options.cleanOnceBeforeBuildPatterns
50
- : ['**/*'];
51
- /**
52
- * Store webpack build assets
53
- */
54
- this.currentAssets = [];
55
- /**
56
- * Only used with cleanOnceBeforeBuildPatterns
57
- */
58
- this.initialClean = false;
59
- this.outputPath = '';
60
- this.apply = this.apply.bind(this);
61
- this.handleInitial = this.handleInitial.bind(this);
62
- this.handleDone = this.handleDone.bind(this);
63
- this.removeFiles = this.removeFiles.bind(this);
64
- }
65
- apply(compiler) {
66
- if (!compiler.options.output.path) {
67
- console.warn('clean-webpack-plugin: options.output.path not defined. Plugin disabled...');
68
- return;
69
- }
70
- this.outputPath = compiler.options.output.path;
71
- const { hooks } = compiler;
72
- if (this.cleanOnceBeforeBuildPatterns.length !== 0) {
73
- hooks.compile.tap('clean-webpack-plugin', () => {
74
- this.handleInitial();
75
- });
76
- }
77
- hooks.done.tap('clean-webpack-plugin', (stats) => {
78
- this.handleDone(stats);
79
- });
80
- }
81
- /**
82
- * Initially remove files from output directory prior to build.
83
- *
84
- * Only happens once.
85
- *
86
- * Warning: It is recommended to initially clean your build directory outside
87
- * of webpack to minimize unexpected behavior.
88
- */
89
- handleInitial() {
90
- if (this.initialClean) {
91
- return;
92
- }
93
- if (
94
- // eslint-disable-next-line no-restricted-properties
95
- fs_extra_1.default.pathExistsSync(this.outputPath) &&
96
- // eslint-disable-next-line no-restricted-properties
97
- fs_extra_1.default.statSync(this.outputPath).isFile()) {
98
- throw new Error(`A file '${this.outputPath}' already exists. Docusaurus needs this directory to save the build output. Either remove/change the file or choose a different build directory via '--out-dir'.`);
99
- }
100
- this.initialClean = true;
101
- this.removeFiles(this.cleanOnceBeforeBuildPatterns);
102
- }
103
- handleDone(stats) {
104
- /**
105
- * Do nothing if there is a webpack error
106
- */
107
- if (stats.hasErrors()) {
108
- if (this.verbose) {
109
- console.warn('clean-webpack-plugin: pausing due to webpack errors');
110
- }
111
- return;
112
- }
113
- /**
114
- * Fetch Webpack's output asset files
115
- */
116
- const statsAssets = stats.toJson({
117
- all: false,
118
- assets: true,
119
- }).assets ?? [];
120
- const assets = statsAssets.map((asset) => asset.name);
121
- /**
122
- * Get all files that were in the previous build but not the current
123
- *
124
- * (relies on del's cwd: outputPath option)
125
- */
126
- const staleFiles = this.currentAssets.filter((previousAsset) => !assets.includes(previousAsset));
127
- /**
128
- * Save assets for next compilation
129
- */
130
- this.currentAssets = assets.sort();
131
- const removePatterns = [];
132
- /**
133
- * Remove unused webpack assets
134
- */
135
- if (this.cleanStaleWebpackAssets && staleFiles.length !== 0) {
136
- removePatterns.push(...staleFiles);
137
- }
138
- if (removePatterns.length !== 0) {
139
- this.removeFiles(removePatterns);
140
- }
141
- }
142
- removeFiles(patterns) {
143
- try {
144
- const deleted = (0, del_1.sync)(patterns, {
145
- force: false,
146
- // Change context to build directory
147
- cwd: this.outputPath,
148
- dryRun: false,
149
- dot: true,
150
- ignore: this.protectWebpackAssets ? this.currentAssets : [],
151
- });
152
- /**
153
- * Log if verbose is enabled
154
- */
155
- if (this.verbose) {
156
- deleted.forEach((file) => {
157
- const filename = path_1.default.relative(process.cwd(), file);
158
- /**
159
- * Use console.warn over .log
160
- * https://github.com/webpack/webpack/issues/1904
161
- * https://github.com/johnagan/clean-webpack-plugin/issues/11
162
- */
163
- console.warn(`clean-webpack-plugin: removed ${filename}`);
164
- });
165
- }
166
- }
167
- catch (err) {
168
- const needsForce = err.message.includes('Cannot delete files/folders outside the current working directory.');
169
- if (needsForce) {
170
- const message = 'clean-webpack-plugin: Cannot delete files/folders outside the current working directory. Can be overridden with the "dangerouslyAllowCleanPatternsOutsideProject" option.';
171
- throw new Error(message);
172
- }
173
- throw err;
174
- }
175
- }
176
- }
177
- exports.default = CleanWebpackPlugin;