@docusaurus/core 2.0.0-beta.ff31de0ff → 2.0.1
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/README.md +1 -0
- package/bin/beforeCli.mjs +140 -0
- package/bin/docusaurus.mjs +223 -0
- package/lib/babel/preset.d.ts +8 -3
- package/lib/babel/preset.js +10 -8
- package/lib/client/App.d.ts +2 -3
- package/lib/client/App.js +31 -28
- package/lib/client/BaseUrlIssueBanner/index.d.ts +27 -0
- package/lib/client/{baseUrlIssueBanner/BaseUrlIssueBanner.js → BaseUrlIssueBanner/index.js} +25 -14
- package/lib/client/{baseUrlIssueBanner → BaseUrlIssueBanner}/styles.module.css +0 -0
- package/lib/client/ClientLifecyclesDispatcher.d.ts +16 -0
- package/lib/client/ClientLifecyclesDispatcher.js +39 -0
- package/lib/client/LinksCollector.d.ts +3 -3
- package/lib/client/LinksCollector.js +8 -13
- package/lib/client/PendingNavigation.d.ts +17 -3
- package/lib/client/PendingNavigation.js +47 -72
- package/lib/client/{baseUrlIssueBanner/BaseUrlIssueBanner.d.ts → SiteMetadataDefaults.d.ts} +1 -2
- package/lib/client/SiteMetadataDefaults.js +21 -0
- package/lib/{choosePort.d.ts → client/browserContext.d.ts} +5 -5
- package/lib/client/browserContext.js +22 -0
- package/lib/client/clientEntry.js +14 -9
- package/lib/client/docusaurus.d.ts +12 -6
- package/lib/client/docusaurus.js +30 -43
- package/lib/client/docusaurusContext.d.ts +12 -0
- package/lib/client/docusaurusContext.js +25 -0
- package/lib/client/exports/BrowserOnly.d.ts +3 -5
- package/lib/client/exports/BrowserOnly.js +14 -7
- package/lib/client/exports/ComponentCreator.d.ts +6 -2
- package/lib/client/exports/ComponentCreator.js +75 -42
- package/lib/client/exports/ErrorBoundary.d.ts +18 -0
- package/lib/client/exports/ErrorBoundary.js +37 -0
- package/lib/client/exports/ExecutionEnvironment.js +7 -8
- package/lib/client/exports/Head.d.ts +2 -3
- package/lib/client/exports/Head.js +3 -4
- package/lib/client/exports/Interpolate.d.ts +2 -2
- package/lib/client/exports/Interpolate.js +20 -49
- package/lib/client/exports/Link.d.ts +4 -10
- package/lib/client/exports/Link.js +44 -38
- package/lib/client/exports/Translate.d.ts +1 -1
- package/lib/client/exports/Translate.js +14 -9
- package/lib/client/exports/constants.js +1 -11
- package/lib/client/exports/isInternalUrl.js +1 -1
- package/lib/client/exports/renderRoutes.d.ts +1 -2
- package/lib/client/exports/renderRoutes.js +1 -2
- package/lib/client/exports/router.d.ts +1 -1
- package/lib/client/exports/router.js +1 -1
- package/lib/client/exports/useBaseUrl.js +11 -14
- package/lib/client/exports/useDocusaurusContext.d.ts +2 -3
- package/lib/client/exports/useDocusaurusContext.js +3 -9
- package/lib/client/exports/useGlobalData.d.ts +4 -3
- package/lib/client/exports/useGlobalData.js +8 -15
- package/lib/{server/versions/__tests/index.test.d.ts → client/exports/useIsBrowser.d.ts} +1 -1
- package/lib/client/exports/useIsBrowser.js +11 -0
- package/lib/client/exports/useRouteContext.d.ts +8 -0
- package/lib/client/exports/useRouteContext.js +15 -0
- package/lib/client/flat.d.ts +12 -2
- package/lib/client/flat.js +19 -15
- package/lib/client/normalizeLocation.d.ts +2 -5
- package/lib/client/normalizeLocation.js +14 -10
- package/lib/client/prefetch.d.ts +1 -2
- package/lib/client/prefetch.js +12 -32
- package/lib/client/preload.d.ts +3 -4
- package/lib/client/preload.js +5 -12
- package/lib/client/routeContext.d.ts +13 -0
- package/lib/client/routeContext.js +31 -0
- package/lib/client/serverEntry.d.ts +10 -0
- package/lib/client/serverEntry.js +109 -136
- package/lib/client/theme-fallback/Error/index.d.ts +10 -0
- package/lib/client/theme-fallback/Error/index.js +45 -0
- package/lib/client/theme-fallback/Layout/index.d.ts +10 -0
- package/lib/client/theme-fallback/Layout/index.js +2 -26
- package/lib/client/theme-fallback/Loading/index.d.ts +9 -0
- package/lib/client/theme-fallback/Loading/index.js +50 -116
- package/lib/client/{exports/context.js → theme-fallback/NotFound/index.d.ts} +2 -2
- package/lib/client/theme-fallback/NotFound/index.js +19 -18
- package/lib/client/theme-fallback/Root/index.d.ts +10 -0
- package/lib/client/theme-fallback/Root/index.js +2 -6
- package/lib/{server/html-tags/htmlTags.d.ts → client/theme-fallback/SiteMetadata/index.d.ts} +2 -1
- package/lib/client/theme-fallback/SiteMetadata/index.js +10 -0
- package/lib/commands/build.d.ts +6 -2
- package/lib/commands/build.js +81 -64
- package/lib/commands/clear.d.ts +7 -1
- package/lib/commands/clear.js +34 -21
- package/lib/commands/deploy.d.ts +5 -2
- package/lib/commands/deploy.js +102 -81
- package/lib/commands/external.d.ts +2 -2
- package/lib/commands/external.js +9 -11
- package/lib/commands/serve.d.ts +8 -2
- package/lib/commands/serve.js +40 -20
- package/lib/commands/start.d.ts +9 -2
- package/lib/commands/start.js +111 -101
- package/lib/commands/swizzle/actions.d.ts +23 -0
- package/lib/commands/swizzle/actions.js +106 -0
- package/lib/commands/swizzle/common.d.ts +33 -0
- package/lib/commands/swizzle/common.js +56 -0
- package/lib/commands/swizzle/components.d.ts +29 -0
- package/lib/commands/swizzle/components.js +200 -0
- package/lib/commands/swizzle/config.d.ts +10 -0
- package/lib/commands/swizzle/config.js +84 -0
- package/lib/{server/client-modules/index.d.ts → commands/swizzle/context.d.ts} +2 -2
- package/lib/commands/swizzle/context.js +24 -0
- package/lib/commands/swizzle/index.d.ts +8 -0
- package/lib/commands/swizzle/index.js +119 -0
- package/lib/commands/swizzle/prompts.d.ts +12 -0
- package/lib/commands/swizzle/prompts.js +110 -0
- package/lib/{client/exports/context.d.ts → commands/swizzle/tables.d.ts} +3 -4
- package/lib/commands/swizzle/tables.js +113 -0
- package/lib/commands/swizzle/themes.d.ts +20 -0
- package/lib/commands/swizzle/themes.js +106 -0
- package/lib/commands/writeHeadingIds.d.ts +2 -6
- package/lib/commands/writeHeadingIds.js +22 -81
- package/lib/commands/writeTranslations.d.ts +4 -5
- package/lib/commands/writeTranslations.js +48 -28
- package/lib/index.d.ts +9 -9
- package/lib/index.js +14 -14
- package/lib/server/brokenLinks.d.ts +4 -17
- package/lib/server/brokenLinks.js +67 -56
- package/lib/server/clientModules.d.ts +12 -0
- package/lib/server/clientModules.js +20 -0
- package/lib/server/config.d.ts +5 -2
- package/lib/server/config.js +29 -6
- package/lib/server/configValidation.d.ts +5 -3
- package/lib/server/configValidation.js +105 -44
- package/lib/server/getHostPort.d.ts +14 -0
- package/lib/server/getHostPort.js +79 -0
- package/lib/server/htmlTags.d.ts +12 -0
- package/lib/server/htmlTags.js +62 -0
- package/lib/server/i18n.d.ts +3 -13
- package/lib/server/i18n.js +21 -55
- package/lib/server/index.d.ts +28 -6
- package/lib/server/index.js +86 -173
- package/lib/server/plugins/configs.d.ts +51 -0
- package/lib/server/plugins/configs.js +101 -0
- package/lib/server/plugins/index.d.ts +10 -10
- package/lib/server/plugins/index.js +76 -128
- package/lib/server/plugins/init.d.ts +6 -9
- package/lib/server/plugins/init.js +44 -109
- package/lib/server/plugins/moduleShorthand.d.ts +9 -0
- package/lib/server/plugins/moduleShorthand.js +46 -0
- package/lib/server/plugins/pluginIds.d.ts +6 -2
- package/lib/server/plugins/pluginIds.js +12 -7
- package/lib/server/plugins/presets.d.ts +12 -0
- package/lib/server/plugins/presets.js +49 -0
- package/lib/server/plugins/routeConfig.d.ts +11 -0
- package/lib/server/plugins/routeConfig.js +54 -0
- package/lib/server/plugins/synthetic.d.ts +20 -0
- package/lib/server/plugins/synthetic.js +111 -0
- package/lib/server/routes.d.ts +39 -7
- package/lib/server/routes.js +182 -95
- package/lib/server/siteMetadata.d.ts +12 -0
- package/lib/server/siteMetadata.js +81 -0
- package/lib/server/translations/translations.d.ts +16 -22
- package/lib/server/translations/translations.js +41 -73
- package/lib/server/translations/translationsExtractor.d.ts +10 -5
- package/lib/server/translations/translationsExtractor.js +158 -122
- package/lib/server/utils.d.ts +9 -3
- package/lib/server/utils.js +7 -9
- package/lib/webpack/aliases/index.d.ts +34 -0
- package/lib/webpack/aliases/index.js +106 -0
- package/lib/webpack/base.d.ts +3 -4
- package/lib/webpack/base.js +56 -58
- package/lib/webpack/client.d.ts +3 -3
- package/lib/webpack/client.js +12 -19
- package/lib/webpack/plugins/ChunkAssetPlugin.d.ts +13 -3
- package/lib/webpack/plugins/ChunkAssetPlugin.js +24 -17
- package/lib/webpack/plugins/CleanWebpackPlugin.d.ts +6 -25
- package/lib/webpack/plugins/CleanWebpackPlugin.js +34 -18
- package/lib/webpack/plugins/LogPlugin.d.ts +1 -1
- package/lib/webpack/plugins/LogPlugin.js +4 -5
- package/lib/webpack/plugins/WaitPlugin.d.ts +3 -3
- package/lib/webpack/plugins/WaitPlugin.js +1 -1
- package/lib/webpack/server.d.ts +5 -5
- package/lib/webpack/server.js +23 -8
- package/lib/{client → webpack}/templates/index.html.template.ejs +0 -0
- package/lib/webpack/templates/ssr.html.template.d.ts +8 -0
- package/lib/{client → webpack}/templates/ssr.html.template.js +5 -4
- package/lib/webpack/utils.d.ts +16 -31
- package/lib/webpack/utils.js +63 -183
- package/package.json +83 -77
- package/bin/docusaurus.js +0 -326
- package/lib/.tsbuildinfo +0 -5682
- package/lib/choosePort.js +0 -105
- package/lib/client/.eslintrc.js +0 -29
- package/lib/client/.tsbuildinfo +0 -4127
- package/lib/client/client-lifecycles-dispatcher.d.ts +0 -12
- package/lib/client/client-lifecycles-dispatcher.js +0 -27
- package/lib/client/nprogress.css +0 -36
- package/lib/commands/buildRemoteBranchUrl.d.ts +0 -7
- package/lib/commands/buildRemoteBranchUrl.js +0 -27
- package/lib/commands/commandUtils.d.ts +0 -3
- package/lib/commands/commandUtils.js +0 -21
- package/lib/commands/swizzle.d.ts +0 -9
- package/lib/commands/swizzle.js +0 -245
- package/lib/constants.d.ts +0 -18
- package/lib/constants.js +0 -23
- package/lib/server/client-modules/index.js +0 -14
- package/lib/server/duplicateRoutes.d.ts +0 -10
- package/lib/server/duplicateRoutes.js +0 -38
- package/lib/server/html-tags/htmlTags.js +0 -39
- package/lib/server/html-tags/index.d.ts +0 -9
- package/lib/server/html-tags/index.js +0 -43
- package/lib/server/loadSetup.d.ts +0 -9
- package/lib/server/loadSetup.js +0 -25
- package/lib/server/presets/index.d.ts +0 -11
- package/lib/server/presets/index.js +0 -48
- package/lib/server/themes/alias.d.ts +0 -8
- package/lib/server/themes/alias.js +0 -39
- package/lib/server/themes/index.d.ts +0 -8
- package/lib/server/themes/index.js +0 -35
- package/lib/server/versions/__fixtures__/dummy-plugin.js +0 -0
- package/lib/server/versions/__fixtures__/package.json +0 -3
- package/lib/server/versions/__tests/index.test.js +0 -25
- package/lib/server/versions/index.d.ts +0 -10
- package/lib/server/versions/index.js +0 -50
- package/lib/webpack/react-dev-utils-webpack5/README.md +0 -11
- package/lib/webpack/react-dev-utils-webpack5/evalSourceMapMiddleware.js +0 -57
- package/lib/webpack/react-dev-utils-webpack5/formatWebpackMessages.js +0 -138
- package/lib/webpack/react-dev-utils-webpack5/webpackHotDevClient.js +0 -285
- package/lib/webpack/sharedModuleAliases.d.ts +0 -10
- package/lib/webpack/sharedModuleAliases.js +0 -18
- package/tsconfig.client.json +0 -13
- package/tsconfig.json +0 -13
package/lib/webpack/utils.js
CHANGED
|
@@ -6,21 +6,25 @@
|
|
|
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 = exports.getHttpsConfig = exports.
|
|
9
|
+
exports.getMinimizer = exports.getHttpsConfig = exports.compile = exports.applyConfigurePostCss = exports.applyConfigureWebpack = exports.getCustomizableJSLoader = exports.getBabelOptions = exports.getCustomBabelConfigFilePath = exports.getStyleLoaders = void 0;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
|
+
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
12
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
13
|
+
const crypto_1 = tslib_1.__importDefault(require("crypto"));
|
|
14
|
+
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
15
|
+
const utils_1 = require("@docusaurus/utils");
|
|
11
16
|
const mini_css_extract_plugin_1 = tslib_1.__importDefault(require("mini-css-extract-plugin"));
|
|
12
17
|
const webpack_merge_1 = require("webpack-merge");
|
|
13
18
|
const webpack_1 = tslib_1.__importDefault(require("webpack"));
|
|
14
|
-
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
15
19
|
const terser_webpack_plugin_1 = tslib_1.__importDefault(require("terser-webpack-plugin"));
|
|
16
20
|
const css_minimizer_webpack_plugin_1 = tslib_1.__importDefault(require("css-minimizer-webpack-plugin"));
|
|
17
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
18
|
-
const crypto_1 = tslib_1.__importDefault(require("crypto"));
|
|
19
|
-
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
20
|
-
const constants_1 = require("../constants");
|
|
21
|
-
const lodash_1 = require("lodash");
|
|
22
21
|
// Utility method to get style loaders
|
|
23
|
-
function getStyleLoaders(isServer,
|
|
22
|
+
function getStyleLoaders(isServer, cssOptionsArg = {}) {
|
|
23
|
+
const cssOptions = {
|
|
24
|
+
// TODO turn esModule on later, see https://github.com/facebook/docusaurus/pull/6424
|
|
25
|
+
esModule: false,
|
|
26
|
+
...cssOptionsArg,
|
|
27
|
+
};
|
|
24
28
|
if (isServer) {
|
|
25
29
|
return cssOptions.modules
|
|
26
30
|
? [
|
|
@@ -66,7 +70,7 @@ function getStyleLoaders(isServer, cssOptions = {}) {
|
|
|
66
70
|
// https://github.com/facebook/create-react-app/issues/2677
|
|
67
71
|
ident: 'postcss',
|
|
68
72
|
plugins: [
|
|
69
|
-
// eslint-disable-next-line
|
|
73
|
+
// eslint-disable-next-line global-require
|
|
70
74
|
require('autoprefixer'),
|
|
71
75
|
],
|
|
72
76
|
},
|
|
@@ -75,9 +79,9 @@ function getStyleLoaders(isServer, cssOptions = {}) {
|
|
|
75
79
|
];
|
|
76
80
|
}
|
|
77
81
|
exports.getStyleLoaders = getStyleLoaders;
|
|
78
|
-
function getCustomBabelConfigFilePath(siteDir) {
|
|
79
|
-
const customBabelConfigurationPath = path_1.default.join(siteDir,
|
|
80
|
-
return fs_extra_1.default.
|
|
82
|
+
async function getCustomBabelConfigFilePath(siteDir) {
|
|
83
|
+
const customBabelConfigurationPath = path_1.default.join(siteDir, utils_1.BABEL_CONFIG_FILE_NAME);
|
|
84
|
+
return (await fs_extra_1.default.pathExists(customBabelConfigurationPath))
|
|
81
85
|
? customBabelConfigurationPath
|
|
82
86
|
: undefined;
|
|
83
87
|
}
|
|
@@ -90,13 +94,12 @@ function getBabelOptions({ isServer, babelOptions, } = {}) {
|
|
|
90
94
|
caller: { name: isServer ? 'server' : 'client' },
|
|
91
95
|
};
|
|
92
96
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
97
|
+
return {
|
|
98
|
+
...(babelOptions ?? { presets: [require.resolve('../babel/preset')] }),
|
|
99
|
+
babelrc: false,
|
|
100
|
+
configFile: false,
|
|
101
|
+
caller: { name: isServer ? 'server' : 'client' },
|
|
102
|
+
};
|
|
100
103
|
}
|
|
101
104
|
exports.getBabelOptions = getBabelOptions;
|
|
102
105
|
// Name is generic on purpose
|
|
@@ -111,58 +114,36 @@ const getCustomizableJSLoader = (jsLoader = 'babel') => ({ isServer, babelOption
|
|
|
111
114
|
? getDefaultBabelLoader({ isServer, babelOptions })
|
|
112
115
|
: jsLoader(isServer);
|
|
113
116
|
exports.getCustomizableJSLoader = getCustomizableJSLoader;
|
|
114
|
-
// TODO remove this before end of 2021?
|
|
115
|
-
const warnBabelLoaderOnce = lodash_1.memoize(function () {
|
|
116
|
-
console.warn(chalk_1.default.yellow('Docusaurus plans to support multiple JS loader strategies (Babel, esbuild...): getBabelLoader(isServer) is now deprecated in favor of getJSLoader({isServer})'));
|
|
117
|
-
});
|
|
118
|
-
const getBabelLoaderDeprecated = function getBabelLoaderDeprecated(isServer, babelOptions) {
|
|
119
|
-
warnBabelLoaderOnce();
|
|
120
|
-
return getDefaultBabelLoader({ isServer, babelOptions });
|
|
121
|
-
};
|
|
122
|
-
// TODO remove this before end of 2021 ?
|
|
123
|
-
const warnCacheLoaderOnce = lodash_1.memoize(function () {
|
|
124
|
-
console.warn(chalk_1.default.yellow('Docusaurus uses Webpack 5 and getCacheLoader() usage is now deprecated'));
|
|
125
|
-
});
|
|
126
|
-
function getCacheLoaderDeprecated() {
|
|
127
|
-
warnCacheLoaderOnce();
|
|
128
|
-
return null;
|
|
129
|
-
}
|
|
130
117
|
/**
|
|
131
118
|
* Helper function to modify webpack config
|
|
132
119
|
* @param configureWebpack a webpack config or a function to modify config
|
|
133
120
|
* @param config initial webpack config
|
|
134
121
|
* @param isServer indicates if this is a server webpack configuration
|
|
135
122
|
* @param jsLoader custom js loader config
|
|
123
|
+
* @param content content loaded by the plugin
|
|
136
124
|
* @returns final/ modified webpack config
|
|
137
125
|
*/
|
|
138
|
-
function applyConfigureWebpack(configureWebpack, config, isServer, jsLoader) {
|
|
126
|
+
function applyConfigureWebpack(configureWebpack, config, isServer, jsLoader, content) {
|
|
139
127
|
// Export some utility functions
|
|
140
128
|
const utils = {
|
|
141
129
|
getStyleLoaders,
|
|
142
|
-
getJSLoader: exports.getCustomizableJSLoader(jsLoader),
|
|
143
|
-
getBabelLoader: getBabelLoaderDeprecated,
|
|
144
|
-
getCacheLoader: getCacheLoaderDeprecated,
|
|
130
|
+
getJSLoader: (0, exports.getCustomizableJSLoader)(jsLoader),
|
|
145
131
|
};
|
|
146
132
|
if (typeof configureWebpack === 'function') {
|
|
147
|
-
const { mergeStrategy, ...res } = configureWebpack(config, isServer, utils);
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
customizeObject: webpack_merge_1.customizeObject(customizeRules),
|
|
154
|
-
})(config, res);
|
|
155
|
-
}
|
|
133
|
+
const { mergeStrategy, ...res } = configureWebpack(config, isServer, utils, content) ?? {};
|
|
134
|
+
const customizeRules = mergeStrategy ?? {};
|
|
135
|
+
return (0, webpack_merge_1.mergeWithCustomize)({
|
|
136
|
+
customizeArray: (0, webpack_merge_1.customizeArray)(customizeRules),
|
|
137
|
+
customizeObject: (0, webpack_merge_1.customizeObject)(customizeRules),
|
|
138
|
+
})(config, res);
|
|
156
139
|
}
|
|
157
140
|
return config;
|
|
158
141
|
}
|
|
159
142
|
exports.applyConfigureWebpack = applyConfigureWebpack;
|
|
160
143
|
function applyConfigurePostCss(configurePostCss, config) {
|
|
161
|
-
|
|
162
|
-
// TODO not ideal heuristic but good enough for our usecase?
|
|
144
|
+
// Not ideal heuristic but good enough for our use-case?
|
|
163
145
|
function isPostCssLoader(loader) {
|
|
164
|
-
|
|
165
|
-
return !!((_b = (_a = loader) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.postcssOptions);
|
|
146
|
+
return !!loader?.options?.postcssOptions;
|
|
166
147
|
}
|
|
167
148
|
// Does not handle all edge cases, but good enough for now
|
|
168
149
|
function overridePostCssOptions(entry) {
|
|
@@ -175,42 +156,39 @@ function applyConfigurePostCss(configurePostCss, config) {
|
|
|
175
156
|
else if (Array.isArray(entry.use)) {
|
|
176
157
|
entry.use
|
|
177
158
|
.filter((u) => typeof u === 'object')
|
|
178
|
-
.forEach(overridePostCssOptions);
|
|
159
|
+
.forEach((rule) => overridePostCssOptions(rule));
|
|
179
160
|
}
|
|
180
161
|
}
|
|
181
|
-
|
|
162
|
+
config.module?.rules?.forEach((rule) => overridePostCssOptions(rule));
|
|
182
163
|
return config;
|
|
183
164
|
}
|
|
184
165
|
exports.applyConfigurePostCss = applyConfigurePostCss;
|
|
185
166
|
function compile(config) {
|
|
186
167
|
return new Promise((resolve, reject) => {
|
|
187
|
-
const compiler = webpack_1.default(config);
|
|
168
|
+
const compiler = (0, webpack_1.default)(config);
|
|
188
169
|
compiler.run((err, stats) => {
|
|
189
|
-
var _a;
|
|
190
170
|
if (err) {
|
|
191
|
-
|
|
192
|
-
// @ts-expect-error: see https://webpack.js.org/api/node/#error-handling
|
|
171
|
+
logger_1.default.error(err.stack ?? err);
|
|
193
172
|
if (err.details) {
|
|
194
|
-
|
|
195
|
-
console.error(err.details);
|
|
173
|
+
logger_1.default.error(err.details);
|
|
196
174
|
}
|
|
197
175
|
reject(err);
|
|
198
176
|
}
|
|
199
|
-
//
|
|
200
|
-
const errorsWarnings = stats
|
|
201
|
-
if (stats
|
|
177
|
+
// Let plugins consume all the stats
|
|
178
|
+
const errorsWarnings = stats?.toJson('errors-warnings');
|
|
179
|
+
if (stats?.hasErrors()) {
|
|
202
180
|
reject(new Error('Failed to compile with errors.'));
|
|
203
181
|
}
|
|
204
|
-
if (errorsWarnings &&
|
|
205
|
-
|
|
206
|
-
|
|
182
|
+
if (errorsWarnings && stats?.hasWarnings()) {
|
|
183
|
+
errorsWarnings.warnings?.forEach((warning) => {
|
|
184
|
+
logger_1.default.warn(warning);
|
|
207
185
|
});
|
|
208
186
|
}
|
|
209
187
|
// Webpack 5 requires calling close() so that persistent caching works
|
|
210
188
|
// See https://github.com/webpack/webpack.js.org/pull/4775
|
|
211
189
|
compiler.close((errClose) => {
|
|
212
190
|
if (errClose) {
|
|
213
|
-
|
|
191
|
+
logger_1.default.error(`Error while closing Webpack compiler: ${errClose}`);
|
|
214
192
|
reject(errClose);
|
|
215
193
|
}
|
|
216
194
|
else {
|
|
@@ -221,145 +199,46 @@ function compile(config) {
|
|
|
221
199
|
});
|
|
222
200
|
}
|
|
223
201
|
exports.compile = compile;
|
|
224
|
-
// Inspired by https://github.com/gatsbyjs/gatsby/blob/8e6e021014da310b9cc7d02e58c9b3efe938c665/packages/gatsby/src/utils/webpack-utils.ts#L447
|
|
225
|
-
function getFileLoaderUtils() {
|
|
226
|
-
// files/images < 10kb will be inlined as base64 strings directly in the html
|
|
227
|
-
const urlLoaderLimit = 10000;
|
|
228
|
-
// defines the path/pattern of the assets handled by webpack
|
|
229
|
-
const fileLoaderFileName = (folder) => `${constants_1.OUTPUT_STATIC_ASSETS_DIR_NAME}/${folder}/[name]-[hash].[ext]`;
|
|
230
|
-
const loaders = {
|
|
231
|
-
file: (options) => {
|
|
232
|
-
return {
|
|
233
|
-
loader: require.resolve(`file-loader`),
|
|
234
|
-
options: {
|
|
235
|
-
name: fileLoaderFileName(options.folder),
|
|
236
|
-
},
|
|
237
|
-
};
|
|
238
|
-
},
|
|
239
|
-
url: (options) => {
|
|
240
|
-
return {
|
|
241
|
-
loader: require.resolve(`url-loader`),
|
|
242
|
-
options: {
|
|
243
|
-
limit: urlLoaderLimit,
|
|
244
|
-
name: fileLoaderFileName(options.folder),
|
|
245
|
-
fallback: require.resolve(`file-loader`),
|
|
246
|
-
},
|
|
247
|
-
};
|
|
248
|
-
},
|
|
249
|
-
// TODO find a better solution to avoid conflicts with the ideal-image plugin
|
|
250
|
-
// TODO this may require a little breaking change for ideal-image users?
|
|
251
|
-
// Maybe with the ideal image plugin, all md images should be "ideal"?
|
|
252
|
-
// This is used to force url-loader+file-loader on markdown images
|
|
253
|
-
// https://webpack.js.org/concepts/loaders/#inline
|
|
254
|
-
inlineMarkdownImageFileLoader: `!url-loader?limit=${urlLoaderLimit}&name=${fileLoaderFileName('images')}&fallback=file-loader!`,
|
|
255
|
-
inlineMarkdownLinkFileLoader: `!file-loader?name=${fileLoaderFileName('files')}!`,
|
|
256
|
-
};
|
|
257
|
-
const rules = {
|
|
258
|
-
/**
|
|
259
|
-
* Loads image assets, inlines images via a data URI if they are below
|
|
260
|
-
* the size threshold
|
|
261
|
-
*/
|
|
262
|
-
images: () => {
|
|
263
|
-
return {
|
|
264
|
-
use: [loaders.url({ folder: 'images' })],
|
|
265
|
-
test: /\.(ico|jpg|jpeg|png|gif|webp)(\?.*)?$/,
|
|
266
|
-
};
|
|
267
|
-
},
|
|
268
|
-
fonts: () => {
|
|
269
|
-
return {
|
|
270
|
-
use: [loaders.url({ folder: 'fonts' })],
|
|
271
|
-
test: /\.(woff|woff2|eot|ttf|otf)$/,
|
|
272
|
-
};
|
|
273
|
-
},
|
|
274
|
-
/**
|
|
275
|
-
* Loads audio and video and inlines them via a data URI if they are below
|
|
276
|
-
* the size threshold
|
|
277
|
-
*/
|
|
278
|
-
media: () => {
|
|
279
|
-
return {
|
|
280
|
-
use: [loaders.url({ folder: 'medias' })],
|
|
281
|
-
test: /\.(mp4|webm|ogv|wav|mp3|m4a|aac|oga|flac)$/,
|
|
282
|
-
};
|
|
283
|
-
},
|
|
284
|
-
svg: () => {
|
|
285
|
-
return {
|
|
286
|
-
test: /\.svg?$/,
|
|
287
|
-
oneOf: [
|
|
288
|
-
{
|
|
289
|
-
use: [
|
|
290
|
-
{
|
|
291
|
-
loader: '@svgr/webpack',
|
|
292
|
-
options: {
|
|
293
|
-
prettier: false,
|
|
294
|
-
svgo: true,
|
|
295
|
-
svgoConfig: {
|
|
296
|
-
plugins: [{ removeViewBox: false }],
|
|
297
|
-
},
|
|
298
|
-
titleProp: true,
|
|
299
|
-
ref: ![path_1.default],
|
|
300
|
-
},
|
|
301
|
-
},
|
|
302
|
-
],
|
|
303
|
-
// We don't want to use SVGR loader for non-React source code
|
|
304
|
-
// ie we don't want to use SVGR for CSS files...
|
|
305
|
-
issuer: {
|
|
306
|
-
and: [/\.(ts|tsx|js|jsx|md|mdx)$/],
|
|
307
|
-
},
|
|
308
|
-
},
|
|
309
|
-
{
|
|
310
|
-
use: [loaders.url({ folder: 'images' })],
|
|
311
|
-
},
|
|
312
|
-
],
|
|
313
|
-
};
|
|
314
|
-
},
|
|
315
|
-
otherAssets: () => {
|
|
316
|
-
return {
|
|
317
|
-
use: [loaders.file({ folder: 'files' })],
|
|
318
|
-
test: /\.(pdf|doc|docx|xls|xlsx|zip|rar)$/,
|
|
319
|
-
};
|
|
320
|
-
},
|
|
321
|
-
};
|
|
322
|
-
return { loaders, rules };
|
|
323
|
-
}
|
|
324
|
-
exports.getFileLoaderUtils = getFileLoaderUtils;
|
|
325
202
|
// Ensure the certificate and key provided are valid and if not
|
|
326
203
|
// throw an easy to debug error
|
|
327
|
-
function validateKeyAndCerts({ cert, key, keyFile, crtFile }) {
|
|
204
|
+
function validateKeyAndCerts({ cert, key, keyFile, crtFile, }) {
|
|
328
205
|
let encrypted;
|
|
329
206
|
try {
|
|
330
207
|
// publicEncrypt will throw an error with an invalid cert
|
|
331
208
|
encrypted = crypto_1.default.publicEncrypt(cert, Buffer.from('test'));
|
|
332
209
|
}
|
|
333
210
|
catch (err) {
|
|
334
|
-
|
|
211
|
+
logger_1.default.error `The certificate path=${crtFile} is invalid.`;
|
|
212
|
+
throw err;
|
|
335
213
|
}
|
|
336
214
|
try {
|
|
337
215
|
// privateDecrypt will throw an error with an invalid key
|
|
338
216
|
crypto_1.default.privateDecrypt(key, encrypted);
|
|
339
217
|
}
|
|
340
218
|
catch (err) {
|
|
341
|
-
|
|
219
|
+
logger_1.default.error `The certificate key path=${keyFile} is invalid.`;
|
|
220
|
+
throw err;
|
|
342
221
|
}
|
|
343
222
|
}
|
|
344
223
|
// Read file and throw an error if it doesn't exist
|
|
345
|
-
function readEnvFile(file, type) {
|
|
346
|
-
if (!fs_extra_1.default.
|
|
347
|
-
throw new Error(`You specified ${
|
|
224
|
+
async function readEnvFile(file, type) {
|
|
225
|
+
if (!(await fs_extra_1.default.pathExists(file))) {
|
|
226
|
+
throw new Error(`You specified ${type} in your env, but the file "${file}" can't be found.`);
|
|
348
227
|
}
|
|
349
|
-
return fs_extra_1.default.
|
|
228
|
+
return fs_extra_1.default.readFile(file);
|
|
350
229
|
}
|
|
351
|
-
const appDirectory = fs_extra_1.default.realpathSync(process.cwd());
|
|
352
230
|
// Get the https config
|
|
353
231
|
// Return cert files if provided in env, otherwise just true or false
|
|
354
|
-
function getHttpsConfig() {
|
|
232
|
+
async function getHttpsConfig() {
|
|
233
|
+
const appDirectory = await fs_extra_1.default.realpath(process.cwd());
|
|
355
234
|
const { SSL_CRT_FILE, SSL_KEY_FILE, HTTPS } = process.env;
|
|
356
235
|
const isHttps = HTTPS === 'true';
|
|
357
236
|
if (isHttps && SSL_CRT_FILE && SSL_KEY_FILE) {
|
|
358
237
|
const crtFile = path_1.default.resolve(appDirectory, SSL_CRT_FILE);
|
|
359
238
|
const keyFile = path_1.default.resolve(appDirectory, SSL_KEY_FILE);
|
|
360
239
|
const config = {
|
|
361
|
-
cert: readEnvFile(crtFile, 'SSL_CRT_FILE'),
|
|
362
|
-
key: readEnvFile(keyFile, 'SSL_KEY_FILE'),
|
|
240
|
+
cert: await readEnvFile(crtFile, 'SSL_CRT_FILE'),
|
|
241
|
+
key: await readEnvFile(keyFile, 'SSL_KEY_FILE'),
|
|
363
242
|
};
|
|
364
243
|
validateKeyAndCerts({ ...config, keyFile, crtFile });
|
|
365
244
|
return config;
|
|
@@ -385,12 +264,12 @@ function getMinimizer(useSimpleCssMinifier = false) {
|
|
|
385
264
|
parallel: getTerserParallel(),
|
|
386
265
|
terserOptions: {
|
|
387
266
|
parse: {
|
|
388
|
-
//
|
|
267
|
+
// We want uglify-js to parse ecma 8 code. However, we don't want it
|
|
389
268
|
// to apply any minification steps that turns valid ecma 5 code
|
|
390
269
|
// into invalid ecma 5 code. This is why the 'compress' and 'output'
|
|
391
270
|
// sections only apply transformations that are ecma 5 safe
|
|
392
271
|
// https://github.com/facebook/create-react-app/pull/4234
|
|
393
|
-
ecma:
|
|
272
|
+
ecma: 2020,
|
|
394
273
|
},
|
|
395
274
|
compress: {
|
|
396
275
|
ecma: 5,
|
|
@@ -402,8 +281,8 @@ function getMinimizer(useSimpleCssMinifier = false) {
|
|
|
402
281
|
output: {
|
|
403
282
|
ecma: 5,
|
|
404
283
|
comments: false,
|
|
405
|
-
// Turned on because emoji and regex is not minified properly using
|
|
406
|
-
// https://github.com/facebook/create-react-app/issues/2488
|
|
284
|
+
// Turned on because emoji and regex is not minified properly using
|
|
285
|
+
// default. See https://github.com/facebook/create-react-app/issues/2488
|
|
407
286
|
ascii_only: true,
|
|
408
287
|
},
|
|
409
288
|
},
|
|
@@ -428,6 +307,7 @@ function getMinimizer(useSimpleCssMinifier = false) {
|
|
|
428
307
|
level: {
|
|
429
308
|
1: {
|
|
430
309
|
all: false,
|
|
310
|
+
removeWhitespace: true,
|
|
431
311
|
},
|
|
432
312
|
2: {
|
|
433
313
|
all: true,
|
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": "2.0.
|
|
4
|
+
"version": "2.0.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -21,105 +21,111 @@
|
|
|
21
21
|
"directory": "packages/docusaurus"
|
|
22
22
|
},
|
|
23
23
|
"bin": {
|
|
24
|
-
"docusaurus": "bin/docusaurus.
|
|
24
|
+
"docusaurus": "bin/docusaurus.mjs"
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
|
-
"build": "tsc
|
|
28
|
-
"watch": "
|
|
27
|
+
"build": "tsc --build && node ../../admin/scripts/copyUntypedFiles.js",
|
|
28
|
+
"watch": "run-p -c copy:watch build:watch",
|
|
29
|
+
"build:watch": "tsc --build --watch",
|
|
30
|
+
"copy:watch": "node ../../admin/scripts/copyUntypedFiles.js --watch"
|
|
29
31
|
},
|
|
30
32
|
"bugs": {
|
|
31
33
|
"url": "https://github.com/facebook/docusaurus/issues"
|
|
32
34
|
},
|
|
33
|
-
"devDependencies": {
|
|
34
|
-
"@docusaurus/module-type-aliases": "2.0.0-beta.ff31de0ff",
|
|
35
|
-
"@types/detect-port": "^1.3.0",
|
|
36
|
-
"@types/nprogress": "^0.2.0",
|
|
37
|
-
"tmp-promise": "^3.0.2"
|
|
38
|
-
},
|
|
39
35
|
"dependencies": {
|
|
40
|
-
"@babel/core": "^7.
|
|
41
|
-
"@babel/generator": "^7.
|
|
36
|
+
"@babel/core": "^7.18.6",
|
|
37
|
+
"@babel/generator": "^7.18.7",
|
|
42
38
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
43
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
44
|
-
"@babel/preset-env": "^7.
|
|
45
|
-
"@babel/preset-react": "^7.
|
|
46
|
-
"@babel/preset-typescript": "^7.
|
|
47
|
-
"@babel/runtime": "^7.
|
|
48
|
-
"@babel/runtime-corejs3": "^7.
|
|
49
|
-
"@babel/traverse": "^7.
|
|
50
|
-
"@docusaurus/cssnano-preset": "2.0.
|
|
51
|
-
"@docusaurus/
|
|
52
|
-
"@docusaurus/
|
|
53
|
-
"@docusaurus/
|
|
54
|
-
"@docusaurus/utils
|
|
55
|
-
"@
|
|
56
|
-
"@
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
39
|
+
"@babel/plugin-transform-runtime": "^7.18.6",
|
|
40
|
+
"@babel/preset-env": "^7.18.6",
|
|
41
|
+
"@babel/preset-react": "^7.18.6",
|
|
42
|
+
"@babel/preset-typescript": "^7.18.6",
|
|
43
|
+
"@babel/runtime": "^7.18.6",
|
|
44
|
+
"@babel/runtime-corejs3": "^7.18.6",
|
|
45
|
+
"@babel/traverse": "^7.18.8",
|
|
46
|
+
"@docusaurus/cssnano-preset": "2.0.1",
|
|
47
|
+
"@docusaurus/logger": "2.0.1",
|
|
48
|
+
"@docusaurus/mdx-loader": "2.0.1",
|
|
49
|
+
"@docusaurus/react-loadable": "5.5.2",
|
|
50
|
+
"@docusaurus/utils": "2.0.1",
|
|
51
|
+
"@docusaurus/utils-common": "2.0.1",
|
|
52
|
+
"@docusaurus/utils-validation": "2.0.1",
|
|
53
|
+
"@slorber/static-site-generator-webpack-plugin": "^4.0.7",
|
|
54
|
+
"@svgr/webpack": "^6.2.1",
|
|
55
|
+
"autoprefixer": "^10.4.7",
|
|
56
|
+
"babel-loader": "^8.2.5",
|
|
57
|
+
"babel-plugin-dynamic-import-node": "^2.3.3",
|
|
58
|
+
"boxen": "^6.2.1",
|
|
59
|
+
"chalk": "^4.1.2",
|
|
60
|
+
"chokidar": "^3.5.3",
|
|
61
|
+
"clean-css": "^5.3.0",
|
|
62
|
+
"cli-table3": "^0.6.2",
|
|
63
|
+
"combine-promises": "^1.1.0",
|
|
64
64
|
"commander": "^5.1.0",
|
|
65
|
-
"copy-webpack-plugin": "^
|
|
66
|
-
"core-js": "^3.
|
|
67
|
-
"css-loader": "^
|
|
68
|
-
"css-minimizer-webpack-plugin": "^
|
|
69
|
-
"cssnano": "^5.
|
|
70
|
-
"del": "^6.
|
|
65
|
+
"copy-webpack-plugin": "^11.0.0",
|
|
66
|
+
"core-js": "^3.23.3",
|
|
67
|
+
"css-loader": "^6.7.1",
|
|
68
|
+
"css-minimizer-webpack-plugin": "^4.0.0",
|
|
69
|
+
"cssnano": "^5.1.12",
|
|
70
|
+
"del": "^6.1.1",
|
|
71
71
|
"detect-port": "^1.3.0",
|
|
72
|
-
"
|
|
73
|
-
"
|
|
72
|
+
"escape-html": "^1.0.3",
|
|
73
|
+
"eta": "^1.12.3",
|
|
74
74
|
"file-loader": "^6.2.0",
|
|
75
|
-
"fs-extra": "^10.
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"html-
|
|
79
|
-
"html-tags": "^3.1.0",
|
|
80
|
-
"html-webpack-plugin": "^5.3.1",
|
|
75
|
+
"fs-extra": "^10.1.0",
|
|
76
|
+
"html-minifier-terser": "^6.1.0",
|
|
77
|
+
"html-tags": "^3.2.0",
|
|
78
|
+
"html-webpack-plugin": "^5.5.0",
|
|
81
79
|
"import-fresh": "^3.3.0",
|
|
82
|
-
"is-root": "^2.1.0",
|
|
83
80
|
"leven": "^3.1.0",
|
|
84
|
-
"lodash": "^4.17.
|
|
85
|
-
"mini-css-extract-plugin": "^
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"react-
|
|
92
|
-
"react-error-overlay": "^6.0.9",
|
|
93
|
-
"react-helmet": "^6.1.0",
|
|
94
|
-
"react-loadable": "^5.5.0",
|
|
81
|
+
"lodash": "^4.17.21",
|
|
82
|
+
"mini-css-extract-plugin": "^2.6.1",
|
|
83
|
+
"postcss": "^8.4.14",
|
|
84
|
+
"postcss-loader": "^7.0.0",
|
|
85
|
+
"prompts": "^2.4.2",
|
|
86
|
+
"react-dev-utils": "^12.0.1",
|
|
87
|
+
"react-helmet-async": "^1.3.0",
|
|
88
|
+
"react-loadable": "npm:@docusaurus/react-loadable@5.5.2",
|
|
95
89
|
"react-loadable-ssr-addon-v5-slorber": "^1.0.1",
|
|
96
|
-
"react-router": "^5.
|
|
90
|
+
"react-router": "^5.3.3",
|
|
97
91
|
"react-router-config": "^5.1.1",
|
|
98
|
-
"react-router-dom": "^5.
|
|
99
|
-
"
|
|
100
|
-
"
|
|
101
|
-
"semver": "^7.3.4",
|
|
92
|
+
"react-router-dom": "^5.3.3",
|
|
93
|
+
"rtl-detect": "^1.0.4",
|
|
94
|
+
"semver": "^7.3.7",
|
|
102
95
|
"serve-handler": "^6.1.3",
|
|
103
|
-
"shelljs": "^0.8.
|
|
104
|
-
"
|
|
105
|
-
"
|
|
106
|
-
"terser-webpack-plugin": "^5.1.2",
|
|
107
|
-
"tslib": "^2.2.0",
|
|
96
|
+
"shelljs": "^0.8.5",
|
|
97
|
+
"terser-webpack-plugin": "^5.3.3",
|
|
98
|
+
"tslib": "^2.4.0",
|
|
108
99
|
"update-notifier": "^5.1.0",
|
|
109
100
|
"url-loader": "^4.1.1",
|
|
110
|
-
"wait-on": "^
|
|
111
|
-
"webpack": "^5.
|
|
112
|
-
"webpack-bundle-analyzer": "^4.
|
|
113
|
-
"webpack-dev-server": "^
|
|
114
|
-
"webpack-merge": "^5.
|
|
115
|
-
"webpackbar": "^5.0.
|
|
101
|
+
"wait-on": "^6.0.1",
|
|
102
|
+
"webpack": "^5.73.0",
|
|
103
|
+
"webpack-bundle-analyzer": "^4.5.0",
|
|
104
|
+
"webpack-dev-server": "^4.9.3",
|
|
105
|
+
"webpack-merge": "^5.8.0",
|
|
106
|
+
"webpackbar": "^5.0.2"
|
|
107
|
+
},
|
|
108
|
+
"devDependencies": {
|
|
109
|
+
"@docusaurus/module-type-aliases": "2.0.1",
|
|
110
|
+
"@docusaurus/types": "2.0.1",
|
|
111
|
+
"@types/detect-port": "^1.3.2",
|
|
112
|
+
"@types/react-dom": "^18.0.6",
|
|
113
|
+
"@types/react-router-config": "^5.0.6",
|
|
114
|
+
"@types/rtl-detect": "^1.0.0",
|
|
115
|
+
"@types/serve-handler": "^6.1.1",
|
|
116
|
+
"@types/update-notifier": "^5.1.0",
|
|
117
|
+
"@types/wait-on": "^5.3.1",
|
|
118
|
+
"@types/webpack-bundle-analyzer": "^4.4.1",
|
|
119
|
+
"react-test-renderer": "^17.0.2",
|
|
120
|
+
"tmp-promise": "^3.0.3",
|
|
121
|
+
"tree-node-cli": "^1.5.2"
|
|
116
122
|
},
|
|
117
123
|
"peerDependencies": {
|
|
118
124
|
"react": "^16.8.4 || ^17.0.0",
|
|
119
125
|
"react-dom": "^16.8.4 || ^17.0.0"
|
|
120
126
|
},
|
|
121
127
|
"engines": {
|
|
122
|
-
"node": ">=
|
|
128
|
+
"node": ">=16.14"
|
|
123
129
|
},
|
|
124
|
-
"gitHead": "
|
|
130
|
+
"gitHead": "1ddee1c29cabf9bb52e4d78af6ebfaaabb1bc1f9"
|
|
125
131
|
}
|