@docusaurus/core 2.0.0-beta.8e9b829d9 → 2.0.0-beta.9
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/beforeCli.js +29 -7
- package/bin/docusaurus.js +36 -40
- package/lib/.tsbuildinfo +1 -1
- package/lib/babel/preset.js +1 -1
- package/lib/choosePort.js +10 -11
- package/lib/client/.tsbuildinfo +1 -1
- package/lib/client/App.js +8 -22
- package/lib/client/PendingNavigation.d.ts +24 -1
- package/lib/client/PendingNavigation.js +1 -1
- package/lib/client/baseUrlIssueBanner/BaseUrlIssueBanner.js +1 -0
- package/lib/client/docusaurus.js +0 -1
- package/lib/client/exports/BrowserOnly.js +5 -3
- package/lib/client/exports/Link.js +9 -9
- package/lib/client/exports/Translate.d.ts +2 -2
- package/lib/client/exports/Translate.js +10 -10
- package/lib/client/exports/browserContext.d.ts +11 -0
- package/lib/client/exports/browserContext.js +21 -0
- package/lib/client/exports/constants.js +1 -11
- package/lib/client/exports/{context.d.ts → docusaurusContext.d.ts} +5 -3
- package/lib/client/exports/docusaurusContext.js +25 -0
- package/lib/client/exports/useBaseUrl.js +1 -1
- package/lib/client/exports/useDocusaurusContext.js +2 -7
- package/lib/client/exports/useGlobalData.js +1 -5
- package/lib/client/exports/{context.js → useIsBrowser.d.ts} +1 -2
- package/lib/client/exports/useIsBrowser.js +11 -0
- package/lib/client/normalizeLocation.d.ts +1 -3
- package/lib/client/prefetch.js +0 -1
- package/lib/client/serverEntry.js +11 -27
- package/lib/commands/build.js +24 -21
- package/lib/commands/clear.js +2 -2
- package/lib/commands/commandUtils.js +2 -2
- package/lib/commands/deploy.js +24 -14
- package/lib/commands/external.js +4 -4
- package/lib/commands/serve.js +13 -13
- package/lib/commands/start.js +69 -70
- package/lib/commands/swizzle.js +14 -14
- package/lib/commands/writeHeadingIds.d.ts +8 -5
- package/lib/commands/writeHeadingIds.js +32 -31
- package/lib/commands/writeTranslations.js +25 -11
- package/lib/constants.d.ts +1 -0
- package/lib/constants.js +4 -1
- package/lib/server/brokenLinks.js +13 -13
- package/lib/server/config.js +4 -4
- package/lib/server/configValidation.js +3 -2
- package/lib/server/duplicateRoutes.js +2 -2
- package/lib/server/html-tags/htmlTags.js +5 -5
- package/lib/server/html-tags/index.js +2 -2
- package/lib/server/i18n.js +4 -4
- package/lib/server/index.js +98 -49
- package/lib/server/loadSetup.js +3 -3
- package/lib/server/plugins/applyRouteTrailingSlash.js +1 -1
- package/lib/server/plugins/index.d.ts +1 -1
- package/lib/server/plugins/index.js +20 -13
- package/lib/server/plugins/init.js +7 -10
- package/lib/server/plugins/pluginIds.js +2 -2
- package/lib/server/presets/index.js +4 -7
- package/lib/server/routes.js +9 -11
- package/lib/server/themes/alias.d.ts +1 -0
- package/lib/server/themes/alias.js +22 -10
- package/lib/server/themes/index.js +5 -7
- package/lib/server/translations/translations.js +9 -9
- package/lib/server/translations/translationsExtractor.d.ts +1 -1
- package/lib/server/translations/translationsExtractor.js +58 -47
- package/lib/server/utils.d.ts +6 -0
- package/lib/server/utils.js +8 -9
- package/lib/server/versions/__fixtures__/dummy-plugin.d.ts +0 -0
- package/lib/server/versions/__tests/index.test.js +5 -5
- package/lib/server/versions/index.js +6 -6
- package/lib/webpack/base.js +12 -13
- package/lib/webpack/client.js +8 -17
- package/lib/webpack/plugins/CleanWebpackPlugin.js +2 -5
- package/lib/webpack/plugins/LogPlugin.js +3 -4
- package/lib/webpack/plugins/WaitPlugin.js +4 -4
- package/lib/webpack/react-dev-utils-webpack5/evalSourceMapMiddleware.d.ts +2 -0
- package/lib/webpack/react-dev-utils-webpack5/formatWebpackMessages.d.ts +5 -0
- package/lib/webpack/react-dev-utils-webpack5/formatWebpackMessages.js +1 -1
- package/lib/webpack/react-dev-utils-webpack5/webpackHotDevClient.d.ts +1 -0
- package/lib/webpack/server.js +7 -7
- package/lib/webpack/sharedModuleAliases.js +1 -1
- package/lib/webpack/utils.js +25 -23
- package/package.json +44 -38
- package/tsconfig.client.json +0 -1
- package/tsconfig.json +4 -3
package/lib/webpack/base.js
CHANGED
|
@@ -8,12 +8,11 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.createBaseConfig = exports.getDocusaurusAliases = exports.excludeJS = exports.clientDir = void 0;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
|
-
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
12
|
-
const mini_css_extract_plugin_1 = tslib_1.__importDefault(require("mini-css-extract-plugin"));
|
|
13
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
11
|
+
const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
|
|
12
|
+
const mini_css_extract_plugin_1 = (0, tslib_1.__importDefault)(require("mini-css-extract-plugin"));
|
|
13
|
+
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
14
14
|
const utils_1 = require("./utils");
|
|
15
15
|
const constants_1 = require("../constants");
|
|
16
|
-
const sharedModuleAliases_1 = tslib_1.__importDefault(require("./sharedModuleAliases"));
|
|
17
16
|
const themes_1 = require("../server/themes");
|
|
18
17
|
const utils_2 = require("@docusaurus/utils");
|
|
19
18
|
const CSS_REGEX = /\.css$/;
|
|
@@ -55,10 +54,10 @@ function createBaseConfig(props, isServer, minify = true) {
|
|
|
55
54
|
const isProd = process.env.NODE_ENV === 'production';
|
|
56
55
|
const minimizeEnabled = minify && isProd && !isServer;
|
|
57
56
|
const useSimpleCssMinifier = process.env.USE_SIMPLE_CSS_MINIFIER === 'true';
|
|
58
|
-
const fileLoaderUtils = utils_1.getFileLoaderUtils();
|
|
57
|
+
const fileLoaderUtils = (0, utils_1.getFileLoaderUtils)();
|
|
59
58
|
const name = isServer ? 'server' : 'client';
|
|
60
59
|
const mode = isProd ? 'production' : 'development';
|
|
61
|
-
const themeAliases = themes_1.loadPluginsThemeAliases({ siteDir, plugins });
|
|
60
|
+
const themeAliases = (0, themes_1.loadPluginsThemeAliases)({ siteDir, plugins });
|
|
62
61
|
return {
|
|
63
62
|
mode,
|
|
64
63
|
name,
|
|
@@ -73,7 +72,7 @@ function createBaseConfig(props, isServer, minify = true) {
|
|
|
73
72
|
siteMetadata.docusaurusVersion,
|
|
74
73
|
// Webpack does not evict the cache correctly on alias/swizzle change, so we force eviction.
|
|
75
74
|
// See https://github.com/webpack/webpack/issues/13627
|
|
76
|
-
utils_2.md5Hash(JSON.stringify(themeAliases)),
|
|
75
|
+
(0, utils_2.md5Hash)(JSON.stringify(themeAliases)),
|
|
77
76
|
].join('-'),
|
|
78
77
|
// When one of those modules/dependencies change (including transitive deps), cache is invalidated
|
|
79
78
|
buildDependencies: {
|
|
@@ -94,6 +93,7 @@ function createBaseConfig(props, isServer, minify = true) {
|
|
|
94
93
|
? 'assets/js/[name].[contenthash:8].js'
|
|
95
94
|
: '[name].js',
|
|
96
95
|
publicPath: baseUrl,
|
|
96
|
+
hashFunction: 'xxhash64',
|
|
97
97
|
},
|
|
98
98
|
// Don't throw warning when asset created is over 250kb
|
|
99
99
|
performance: {
|
|
@@ -113,7 +113,6 @@ function createBaseConfig(props, isServer, minify = true) {
|
|
|
113
113
|
process.cwd(),
|
|
114
114
|
],
|
|
115
115
|
alias: {
|
|
116
|
-
...sharedModuleAliases_1.default,
|
|
117
116
|
'@site': siteDir,
|
|
118
117
|
'@generated': generatedFilesDir,
|
|
119
118
|
// Note: a @docusaurus alias would also catch @docusaurus/theme-common,
|
|
@@ -140,7 +139,7 @@ function createBaseConfig(props, isServer, minify = true) {
|
|
|
140
139
|
// Only minimize client bundle in production because server bundle is only used for static site generation
|
|
141
140
|
minimize: minimizeEnabled,
|
|
142
141
|
minimizer: minimizeEnabled
|
|
143
|
-
? utils_1.getMinimizer(useSimpleCssMinifier)
|
|
142
|
+
? (0, utils_1.getMinimizer)(useSimpleCssMinifier)
|
|
144
143
|
: undefined,
|
|
145
144
|
splitChunks: isServer
|
|
146
145
|
? false
|
|
@@ -180,16 +179,16 @@ function createBaseConfig(props, isServer, minify = true) {
|
|
|
180
179
|
test: /\.(j|t)sx?$/,
|
|
181
180
|
exclude: excludeJS,
|
|
182
181
|
use: [
|
|
183
|
-
utils_1.getCustomizableJSLoader((_a = siteConfig.webpack) === null || _a === void 0 ? void 0 : _a.jsLoader)({
|
|
182
|
+
(0, utils_1.getCustomizableJSLoader)((_a = siteConfig.webpack) === null || _a === void 0 ? void 0 : _a.jsLoader)({
|
|
184
183
|
isServer,
|
|
185
|
-
babelOptions: utils_1.getCustomBabelConfigFilePath(siteDir),
|
|
184
|
+
babelOptions: (0, utils_1.getCustomBabelConfigFilePath)(siteDir),
|
|
186
185
|
}),
|
|
187
186
|
],
|
|
188
187
|
},
|
|
189
188
|
{
|
|
190
189
|
test: CSS_REGEX,
|
|
191
190
|
exclude: CSS_MODULE_REGEX,
|
|
192
|
-
use: utils_1.getStyleLoaders(isServer, {
|
|
191
|
+
use: (0, utils_1.getStyleLoaders)(isServer, {
|
|
193
192
|
importLoaders: 1,
|
|
194
193
|
sourceMap: !isProd,
|
|
195
194
|
}),
|
|
@@ -198,7 +197,7 @@ function createBaseConfig(props, isServer, minify = true) {
|
|
|
198
197
|
// using the extension .module.css
|
|
199
198
|
{
|
|
200
199
|
test: CSS_MODULE_REGEX,
|
|
201
|
-
use: utils_1.getStyleLoaders(isServer, {
|
|
200
|
+
use: (0, utils_1.getStyleLoaders)(isServer, {
|
|
202
201
|
modules: {
|
|
203
202
|
localIdentName: isProd
|
|
204
203
|
? `[local]_[contenthash:base64:4]`
|
package/lib/webpack/client.js
CHANGED
|
@@ -7,28 +7,19 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
const tslib_1 = require("tslib");
|
|
10
|
-
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
11
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
12
|
-
const webpack_merge_1 = tslib_1.__importDefault(require("webpack-merge"));
|
|
10
|
+
const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
|
|
11
|
+
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
12
|
+
const webpack_merge_1 = (0, tslib_1.__importDefault)(require("webpack-merge"));
|
|
13
13
|
const base_1 = require("./base");
|
|
14
|
-
const ChunkAssetPlugin_1 = tslib_1.__importDefault(require("./plugins/ChunkAssetPlugin"));
|
|
15
|
-
const LogPlugin_1 = tslib_1.__importDefault(require("./plugins/LogPlugin"));
|
|
14
|
+
const ChunkAssetPlugin_1 = (0, tslib_1.__importDefault)(require("./plugins/ChunkAssetPlugin"));
|
|
15
|
+
const LogPlugin_1 = (0, tslib_1.__importDefault)(require("./plugins/LogPlugin"));
|
|
16
16
|
function createClientConfig(props, minify = true) {
|
|
17
17
|
var _a;
|
|
18
|
-
const isProd = process.env.NODE_ENV === 'production';
|
|
19
18
|
const isBuilding = process.argv[2] === 'build';
|
|
20
|
-
const config = base_1.createBaseConfig(props, false, minify);
|
|
21
|
-
const clientConfig = webpack_merge_1.default(config, {
|
|
19
|
+
const config = (0, base_1.createBaseConfig)(props, false, minify);
|
|
20
|
+
const clientConfig = (0, webpack_merge_1.default)(config, {
|
|
22
21
|
// target: 'browserslist', // useless, disabled on purpose (errors on existing sites with no browserslist cfg)
|
|
23
|
-
entry:
|
|
24
|
-
// Instead of the default WebpackDevServer client, we use a custom one
|
|
25
|
-
// like CRA to bring better experience.
|
|
26
|
-
// note: the one in ./dev is modified to work with Docusaurus
|
|
27
|
-
// !isProd && require.resolve('react-dev-utils/hotDevServer.js'),
|
|
28
|
-
!isProd &&
|
|
29
|
-
require.resolve('./react-dev-utils-webpack5/webpackHotDevClient.js'),
|
|
30
|
-
path_1.default.resolve(__dirname, '../client/clientEntry.js'),
|
|
31
|
-
].filter(Boolean),
|
|
22
|
+
entry: path_1.default.resolve(__dirname, '../client/clientEntry.js'),
|
|
32
23
|
optimization: {
|
|
33
24
|
// Keep the runtime chunk separated to enable long term caching
|
|
34
25
|
// https://twitter.com/wSokra/status/969679223278505985
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
const tslib_1 = require("tslib");
|
|
10
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
10
|
+
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
11
11
|
const del_1 = require("del");
|
|
12
12
|
class CleanWebpackPlugin {
|
|
13
13
|
constructor(options = {}) {
|
|
@@ -41,7 +41,6 @@ class CleanWebpackPlugin {
|
|
|
41
41
|
}
|
|
42
42
|
apply(compiler) {
|
|
43
43
|
if (!compiler.options.output || !compiler.options.output.path) {
|
|
44
|
-
// eslint-disable-next-line no-console
|
|
45
44
|
console.warn('clean-webpack-plugin: options.output.path not defined. Plugin disabled...');
|
|
46
45
|
return;
|
|
47
46
|
}
|
|
@@ -76,7 +75,6 @@ class CleanWebpackPlugin {
|
|
|
76
75
|
*/
|
|
77
76
|
if (stats.hasErrors()) {
|
|
78
77
|
if (this.verbose) {
|
|
79
|
-
// eslint-disable-next-line no-console
|
|
80
78
|
console.warn('clean-webpack-plugin: pausing due to webpack errors');
|
|
81
79
|
}
|
|
82
80
|
return;
|
|
@@ -116,7 +114,7 @@ class CleanWebpackPlugin {
|
|
|
116
114
|
}
|
|
117
115
|
removeFiles(patterns) {
|
|
118
116
|
try {
|
|
119
|
-
const deleted = del_1.sync(patterns, {
|
|
117
|
+
const deleted = (0, del_1.sync)(patterns, {
|
|
120
118
|
force: false,
|
|
121
119
|
// Change context to build directory
|
|
122
120
|
cwd: this.outputPath,
|
|
@@ -135,7 +133,6 @@ class CleanWebpackPlugin {
|
|
|
135
133
|
* https://github.com/webpack/webpack/issues/1904
|
|
136
134
|
* https://github.com/johnagan/clean-webpack-plugin/issues/11
|
|
137
135
|
*/
|
|
138
|
-
// eslint-disable-next-line no-console
|
|
139
136
|
console.warn(`clean-webpack-plugin: removed ${filename}`);
|
|
140
137
|
});
|
|
141
138
|
}
|
|
@@ -7,9 +7,8 @@ const tslib_1 = require("tslib");
|
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
9
|
*/
|
|
10
|
-
const webpackbar_1 = tslib_1.__importDefault(require("webpackbar"));
|
|
11
|
-
|
|
12
|
-
const formatWebpackMessages_1 = tslib_1.__importDefault(require("../react-dev-utils-webpack5/formatWebpackMessages"));
|
|
10
|
+
const webpackbar_1 = (0, tslib_1.__importDefault)(require("webpackbar"));
|
|
11
|
+
const formatWebpackMessages_1 = (0, tslib_1.__importDefault)(require("react-dev-utils/formatWebpackMessages"));
|
|
13
12
|
function showError(arr) {
|
|
14
13
|
console.log(`\n\n${arr.join('\n')}`);
|
|
15
14
|
}
|
|
@@ -23,7 +22,7 @@ class LogPlugin extends webpackbar_1.default {
|
|
|
23
22
|
// TODO do we really want to keep this legacy logic?
|
|
24
23
|
// let's wait and see how the react-dev-utils support Webpack5
|
|
25
24
|
// we probably want to print the error stacktraces here
|
|
26
|
-
const messages = formatWebpackMessages_1.default(errorsWarnings);
|
|
25
|
+
const messages = (0, formatWebpackMessages_1.default)(errorsWarnings);
|
|
27
26
|
if (messages.errors.length) {
|
|
28
27
|
showError(messages.errors);
|
|
29
28
|
}
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
const tslib_1 = require("tslib");
|
|
10
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
11
|
-
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
12
|
-
const wait_on_1 = tslib_1.__importDefault(require("wait-on"));
|
|
10
|
+
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
11
|
+
const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
|
|
12
|
+
const wait_on_1 = (0, tslib_1.__importDefault)(require("wait-on"));
|
|
13
13
|
class WaitPlugin {
|
|
14
14
|
constructor(options) {
|
|
15
15
|
this.filepath = options.filepath;
|
|
@@ -20,7 +20,7 @@ class WaitPlugin {
|
|
|
20
20
|
// To prevent 'waitFile' error on waiting non-existing directory
|
|
21
21
|
fs_extra_1.default.ensureDir(path_1.default.dirname(this.filepath), {}, () => {
|
|
22
22
|
// Wait until file exist
|
|
23
|
-
wait_on_1.default({
|
|
23
|
+
(0, wait_on_1.default)({
|
|
24
24
|
resources: [this.filepath],
|
|
25
25
|
interval: 300,
|
|
26
26
|
})
|
|
@@ -38,7 +38,7 @@ function formatMessage(message) {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
// Strip webpack-added headers off errors/warnings
|
|
41
|
-
// https://github.com/webpack/webpack/blob/
|
|
41
|
+
// https://github.com/webpack/webpack/blob/main/lib/ModuleError.js
|
|
42
42
|
lines = lines.filter((line) => !/Module [A-z ]+\(from/.test(line));
|
|
43
43
|
|
|
44
44
|
// Transform parsing error into syntax error
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/webpack/server.js
CHANGED
|
@@ -7,17 +7,17 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
const tslib_1 = require("tslib");
|
|
10
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
11
|
-
const webpack_merge_1 = tslib_1.__importDefault(require("webpack-merge"));
|
|
10
|
+
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
11
|
+
const webpack_merge_1 = (0, tslib_1.__importDefault)(require("webpack-merge"));
|
|
12
12
|
const base_1 = require("./base");
|
|
13
|
-
const WaitPlugin_1 = tslib_1.__importDefault(require("./plugins/WaitPlugin"));
|
|
14
|
-
const LogPlugin_1 = tslib_1.__importDefault(require("./plugins/LogPlugin"));
|
|
13
|
+
const WaitPlugin_1 = (0, tslib_1.__importDefault)(require("./plugins/WaitPlugin"));
|
|
14
|
+
const LogPlugin_1 = (0, tslib_1.__importDefault)(require("./plugins/LogPlugin"));
|
|
15
15
|
const constants_1 = require("../constants");
|
|
16
16
|
// Forked for Docusaurus: https://github.com/slorber/static-site-generator-webpack-plugin
|
|
17
|
-
const static_site_generator_webpack_plugin_1 = tslib_1.__importDefault(require("@slorber/static-site-generator-webpack-plugin"));
|
|
17
|
+
const static_site_generator_webpack_plugin_1 = (0, tslib_1.__importDefault)(require("@slorber/static-site-generator-webpack-plugin"));
|
|
18
18
|
function createServerConfig({ props, onLinksCollected = () => { }, }) {
|
|
19
19
|
const { baseUrl, routesPaths, generatedFilesDir, headTags, preBodyTags, postBodyTags, ssrTemplate, siteConfig: { noIndex, trailingSlash }, } = props;
|
|
20
|
-
const config = base_1.createBaseConfig(props, true);
|
|
20
|
+
const config = (0, base_1.createBaseConfig)(props, true);
|
|
21
21
|
const routesLocation = {};
|
|
22
22
|
// Array of paths to be rendered. Relative to output directory
|
|
23
23
|
const ssgPaths = routesPaths.map((str) => {
|
|
@@ -25,7 +25,7 @@ function createServerConfig({ props, onLinksCollected = () => { }, }) {
|
|
|
25
25
|
routesLocation[ssgPath] = str;
|
|
26
26
|
return ssgPath;
|
|
27
27
|
});
|
|
28
|
-
const serverConfig = webpack_merge_1.default(config, {
|
|
28
|
+
const serverConfig = (0, webpack_merge_1.default)(config, {
|
|
29
29
|
target: `node${constants_1.NODE_MAJOR_VERSION}.${constants_1.NODE_MINOR_VERSION}`,
|
|
30
30
|
entry: {
|
|
31
31
|
main: path_1.default.resolve(__dirname, '../client/serverEntry.js'),
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
const tslib_1 = require("tslib");
|
|
10
|
-
const module_alias_1 = tslib_1.__importDefault(require("module-alias"));
|
|
10
|
+
const module_alias_1 = (0, tslib_1.__importDefault)(require("module-alias"));
|
|
11
11
|
// The shared module aliases are module aliases that need to work in both SSR/NodeJS + Webpack
|
|
12
12
|
const SharedModuleAliases = {
|
|
13
13
|
// Useful to fix the react-loadable warning
|
package/lib/webpack/utils.js
CHANGED
|
@@ -8,15 +8,15 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.getMinimizer = exports.getHttpsConfig = exports.getFileLoaderUtils = 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 mini_css_extract_plugin_1 = tslib_1.__importDefault(require("mini-css-extract-plugin"));
|
|
11
|
+
const mini_css_extract_plugin_1 = (0, tslib_1.__importDefault)(require("mini-css-extract-plugin"));
|
|
12
12
|
const webpack_merge_1 = require("webpack-merge");
|
|
13
|
-
const webpack_1 = tslib_1.__importDefault(require("webpack"));
|
|
14
|
-
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
15
|
-
const terser_webpack_plugin_1 = tslib_1.__importDefault(require("terser-webpack-plugin"));
|
|
16
|
-
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"));
|
|
13
|
+
const webpack_1 = (0, tslib_1.__importDefault)(require("webpack"));
|
|
14
|
+
const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
|
|
15
|
+
const terser_webpack_plugin_1 = (0, tslib_1.__importDefault)(require("terser-webpack-plugin"));
|
|
16
|
+
const css_minimizer_webpack_plugin_1 = (0, tslib_1.__importDefault)(require("css-minimizer-webpack-plugin"));
|
|
17
|
+
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
18
|
+
const crypto_1 = (0, tslib_1.__importDefault)(require("crypto"));
|
|
19
|
+
const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
|
|
20
20
|
const constants_1 = require("../constants");
|
|
21
21
|
const lodash_1 = require("lodash");
|
|
22
22
|
// Utility method to get style loaders
|
|
@@ -66,7 +66,7 @@ function getStyleLoaders(isServer, cssOptions = {}) {
|
|
|
66
66
|
// https://github.com/facebook/create-react-app/issues/2677
|
|
67
67
|
ident: 'postcss',
|
|
68
68
|
plugins: [
|
|
69
|
-
// eslint-disable-next-line
|
|
69
|
+
// eslint-disable-next-line global-require
|
|
70
70
|
require('autoprefixer'),
|
|
71
71
|
],
|
|
72
72
|
},
|
|
@@ -112,7 +112,7 @@ const getCustomizableJSLoader = (jsLoader = 'babel') => ({ isServer, babelOption
|
|
|
112
112
|
: jsLoader(isServer);
|
|
113
113
|
exports.getCustomizableJSLoader = getCustomizableJSLoader;
|
|
114
114
|
// TODO remove this before end of 2021?
|
|
115
|
-
const warnBabelLoaderOnce = lodash_1.memoize(function () {
|
|
115
|
+
const warnBabelLoaderOnce = (0, lodash_1.memoize)(function () {
|
|
116
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
117
|
});
|
|
118
118
|
const getBabelLoaderDeprecated = function getBabelLoaderDeprecated(isServer, babelOptions) {
|
|
@@ -120,7 +120,7 @@ const getBabelLoaderDeprecated = function getBabelLoaderDeprecated(isServer, bab
|
|
|
120
120
|
return getDefaultBabelLoader({ isServer, babelOptions });
|
|
121
121
|
};
|
|
122
122
|
// TODO remove this before end of 2021 ?
|
|
123
|
-
const warnCacheLoaderOnce = lodash_1.memoize(function () {
|
|
123
|
+
const warnCacheLoaderOnce = (0, lodash_1.memoize)(function () {
|
|
124
124
|
console.warn(chalk_1.default.yellow('Docusaurus uses Webpack 5 and getCacheLoader() usage is now deprecated.'));
|
|
125
125
|
});
|
|
126
126
|
function getCacheLoaderDeprecated() {
|
|
@@ -140,18 +140,17 @@ function applyConfigureWebpack(configureWebpack, config, isServer, jsLoader, con
|
|
|
140
140
|
// Export some utility functions
|
|
141
141
|
const utils = {
|
|
142
142
|
getStyleLoaders,
|
|
143
|
-
getJSLoader: exports.getCustomizableJSLoader(jsLoader),
|
|
143
|
+
getJSLoader: (0, exports.getCustomizableJSLoader)(jsLoader),
|
|
144
144
|
getBabelLoader: getBabelLoaderDeprecated,
|
|
145
145
|
getCacheLoader: getCacheLoaderDeprecated,
|
|
146
146
|
};
|
|
147
147
|
if (typeof configureWebpack === 'function') {
|
|
148
148
|
const { mergeStrategy, ...res } = configureWebpack(config, isServer, utils, content);
|
|
149
149
|
if (res && typeof res === 'object') {
|
|
150
|
-
// @ts-expect-error: annoying error due to enums: https://github.com/survivejs/webpack-merge/issues/179
|
|
151
150
|
const customizeRules = mergeStrategy !== null && mergeStrategy !== void 0 ? mergeStrategy : {};
|
|
152
|
-
return webpack_merge_1.mergeWithCustomize({
|
|
153
|
-
customizeArray: webpack_merge_1.customizeArray(customizeRules),
|
|
154
|
-
customizeObject: webpack_merge_1.customizeObject(customizeRules),
|
|
151
|
+
return (0, webpack_merge_1.mergeWithCustomize)({
|
|
152
|
+
customizeArray: (0, webpack_merge_1.customizeArray)(customizeRules),
|
|
153
|
+
customizeObject: (0, webpack_merge_1.customizeObject)(customizeRules),
|
|
155
154
|
})(config, res);
|
|
156
155
|
}
|
|
157
156
|
}
|
|
@@ -176,16 +175,16 @@ function applyConfigurePostCss(configurePostCss, config) {
|
|
|
176
175
|
else if (Array.isArray(entry.use)) {
|
|
177
176
|
entry.use
|
|
178
177
|
.filter((u) => typeof u === 'object')
|
|
179
|
-
.forEach(overridePostCssOptions);
|
|
178
|
+
.forEach((rule) => overridePostCssOptions(rule));
|
|
180
179
|
}
|
|
181
180
|
}
|
|
182
|
-
(_b = (_a = config.module) === null || _a === void 0 ? void 0 : _a.rules) === null || _b === void 0 ? void 0 : _b.forEach(overridePostCssOptions);
|
|
181
|
+
(_b = (_a = config.module) === null || _a === void 0 ? void 0 : _a.rules) === null || _b === void 0 ? void 0 : _b.forEach((rule) => overridePostCssOptions(rule));
|
|
183
182
|
return config;
|
|
184
183
|
}
|
|
185
184
|
exports.applyConfigurePostCss = applyConfigurePostCss;
|
|
186
185
|
function compile(config) {
|
|
187
186
|
return new Promise((resolve, reject) => {
|
|
188
|
-
const compiler = webpack_1.default(config);
|
|
187
|
+
const compiler = (0, webpack_1.default)(config);
|
|
189
188
|
compiler.run((err, stats) => {
|
|
190
189
|
var _a;
|
|
191
190
|
if (err) {
|
|
@@ -224,8 +223,8 @@ function compile(config) {
|
|
|
224
223
|
exports.compile = compile;
|
|
225
224
|
// Inspired by https://github.com/gatsbyjs/gatsby/blob/8e6e021014da310b9cc7d02e58c9b3efe938c665/packages/gatsby/src/utils/webpack-utils.ts#L447
|
|
226
225
|
function getFileLoaderUtils() {
|
|
227
|
-
// files/images <
|
|
228
|
-
const urlLoaderLimit =
|
|
226
|
+
// files/images < urlLoaderLimit will be inlined as base64 strings directly in the html
|
|
227
|
+
const urlLoaderLimit = constants_1.WEBPACK_URL_LOADER_LIMIT;
|
|
229
228
|
// defines the path/pattern of the assets handled by webpack
|
|
230
229
|
const fileLoaderFileName = (folder) => `${constants_1.OUTPUT_STATIC_ASSETS_DIR_NAME}/${folder}/[name]-[hash].[ext]`;
|
|
231
230
|
const loaders = {
|
|
@@ -325,7 +324,7 @@ function getFileLoaderUtils() {
|
|
|
325
324
|
exports.getFileLoaderUtils = getFileLoaderUtils;
|
|
326
325
|
// Ensure the certificate and key provided are valid and if not
|
|
327
326
|
// throw an easy to debug error
|
|
328
|
-
function validateKeyAndCerts({ cert, key, keyFile, crtFile }) {
|
|
327
|
+
function validateKeyAndCerts({ cert, key, keyFile, crtFile, }) {
|
|
329
328
|
let encrypted;
|
|
330
329
|
try {
|
|
331
330
|
// publicEncrypt will throw an error with an invalid cert
|
|
@@ -391,10 +390,11 @@ function getMinimizer(useSimpleCssMinifier = false) {
|
|
|
391
390
|
// into invalid ecma 5 code. This is why the 'compress' and 'output'
|
|
392
391
|
// sections only apply transformations that are ecma 5 safe
|
|
393
392
|
// https://github.com/facebook/create-react-app/pull/4234
|
|
394
|
-
ecma:
|
|
393
|
+
ecma: 2020,
|
|
395
394
|
},
|
|
396
395
|
compress: {
|
|
397
396
|
ecma: 5,
|
|
397
|
+
// @ts-expect-error: API change in new version?
|
|
398
398
|
warnings: false,
|
|
399
399
|
},
|
|
400
400
|
mangle: {
|
|
@@ -425,10 +425,12 @@ function getMinimizer(useSimpleCssMinifier = false) {
|
|
|
425
425
|
},
|
|
426
426
|
// CleanCss options
|
|
427
427
|
{
|
|
428
|
+
// @ts-expect-error: API change in new version?
|
|
428
429
|
inline: false,
|
|
429
430
|
level: {
|
|
430
431
|
1: {
|
|
431
432
|
all: false,
|
|
433
|
+
removeWhitespace: true,
|
|
432
434
|
},
|
|
433
435
|
2: {
|
|
434
436
|
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.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.9",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -31,88 +31,94 @@
|
|
|
31
31
|
"url": "https://github.com/facebook/docusaurus/issues"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@docusaurus/module-type-aliases": "2.0.0-beta.
|
|
34
|
+
"@docusaurus/module-type-aliases": "2.0.0-beta.9",
|
|
35
|
+
"@types/copy-webpack-plugin": "^8.0.1",
|
|
36
|
+
"@types/css-minimizer-webpack-plugin": "^3.0.2",
|
|
35
37
|
"@types/detect-port": "^1.3.0",
|
|
38
|
+
"@types/mini-css-extract-plugin": "^1.4.3",
|
|
36
39
|
"@types/nprogress": "^0.2.0",
|
|
40
|
+
"@types/react-dom": "^17.0.9",
|
|
41
|
+
"@types/rtl-detect": "^1.0.0",
|
|
42
|
+
"@types/serve-handler": "^6.1.1",
|
|
43
|
+
"@types/webpack-bundle-analyzer": "^4.4.1",
|
|
37
44
|
"tmp-promise": "^3.0.2"
|
|
38
45
|
},
|
|
39
46
|
"dependencies": {
|
|
40
47
|
"@babel/core": "^7.12.16",
|
|
41
48
|
"@babel/generator": "^7.12.15",
|
|
42
49
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
43
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
44
|
-
"@babel/preset-env": "^7.
|
|
50
|
+
"@babel/plugin-transform-runtime": "^7.15.0",
|
|
51
|
+
"@babel/preset-env": "^7.15.6",
|
|
45
52
|
"@babel/preset-react": "^7.12.13",
|
|
46
53
|
"@babel/preset-typescript": "^7.12.16",
|
|
47
|
-
"@babel/runtime": "^7.
|
|
48
|
-
"@babel/runtime-corejs3": "^7.
|
|
54
|
+
"@babel/runtime": "^7.15.4",
|
|
55
|
+
"@babel/runtime-corejs3": "^7.15.4",
|
|
49
56
|
"@babel/traverse": "^7.12.13",
|
|
50
|
-
"@docusaurus/cssnano-preset": "2.0.0-beta.
|
|
51
|
-
"@docusaurus/react-loadable": "5.5.
|
|
52
|
-
"@docusaurus/types": "2.0.0-beta.
|
|
53
|
-
"@docusaurus/utils": "2.0.0-beta.
|
|
54
|
-
"@docusaurus/utils-common": "2.0.0-beta.
|
|
55
|
-
"@docusaurus/utils-validation": "2.0.0-beta.
|
|
57
|
+
"@docusaurus/cssnano-preset": "2.0.0-beta.9",
|
|
58
|
+
"@docusaurus/react-loadable": "5.5.2",
|
|
59
|
+
"@docusaurus/types": "2.0.0-beta.9",
|
|
60
|
+
"@docusaurus/utils": "2.0.0-beta.9",
|
|
61
|
+
"@docusaurus/utils-common": "2.0.0-beta.9",
|
|
62
|
+
"@docusaurus/utils-validation": "2.0.0-beta.9",
|
|
56
63
|
"@slorber/static-site-generator-webpack-plugin": "^4.0.0",
|
|
57
64
|
"@svgr/webpack": "^5.5.0",
|
|
58
|
-
"autoprefixer": "^10.
|
|
65
|
+
"autoprefixer": "^10.3.5",
|
|
59
66
|
"babel-loader": "^8.2.2",
|
|
60
67
|
"babel-plugin-dynamic-import-node": "2.3.0",
|
|
61
68
|
"boxen": "^5.0.1",
|
|
62
|
-
"chalk": "^4.1.
|
|
63
|
-
"chokidar": "^3.5.
|
|
64
|
-
"clean-css": "^5.1.
|
|
69
|
+
"chalk": "^4.1.2",
|
|
70
|
+
"chokidar": "^3.5.2",
|
|
71
|
+
"clean-css": "^5.1.5",
|
|
65
72
|
"commander": "^5.1.0",
|
|
66
|
-
"copy-webpack-plugin": "^9.0.
|
|
67
|
-
"core-js": "^3.
|
|
73
|
+
"copy-webpack-plugin": "^9.0.1",
|
|
74
|
+
"core-js": "^3.18.0",
|
|
68
75
|
"css-loader": "^5.1.1",
|
|
69
|
-
"css-minimizer-webpack-plugin": "^3.0.
|
|
70
|
-
"cssnano": "^5.0.
|
|
76
|
+
"css-minimizer-webpack-plugin": "^3.0.2",
|
|
77
|
+
"cssnano": "^5.0.8",
|
|
71
78
|
"del": "^6.0.0",
|
|
72
79
|
"detect-port": "^1.3.0",
|
|
73
80
|
"escape-html": "^1.0.3",
|
|
74
|
-
"eta": "^1.12.
|
|
75
|
-
"express": "^4.17.1",
|
|
81
|
+
"eta": "^1.12.3",
|
|
76
82
|
"file-loader": "^6.2.0",
|
|
77
83
|
"fs-extra": "^10.0.0",
|
|
78
|
-
"github-slugger": "^1.
|
|
84
|
+
"github-slugger": "^1.4.0",
|
|
79
85
|
"globby": "^11.0.2",
|
|
80
|
-
"html-minifier-terser": "^
|
|
86
|
+
"html-minifier-terser": "^6.0.2",
|
|
81
87
|
"html-tags": "^3.1.0",
|
|
82
|
-
"html-webpack-plugin": "^5.
|
|
88
|
+
"html-webpack-plugin": "^5.4.0",
|
|
83
89
|
"import-fresh": "^3.3.0",
|
|
84
90
|
"is-root": "^2.1.0",
|
|
85
91
|
"leven": "^3.1.0",
|
|
86
92
|
"lodash": "^4.17.20",
|
|
87
93
|
"mini-css-extract-plugin": "^1.6.0",
|
|
88
|
-
"module-alias": "^2.2.2",
|
|
89
94
|
"nprogress": "^0.2.0",
|
|
90
|
-
"postcss": "^8.
|
|
91
|
-
"postcss-loader": "^
|
|
95
|
+
"postcss": "^8.3.7",
|
|
96
|
+
"postcss-loader": "^6.1.1",
|
|
92
97
|
"prompts": "^2.4.1",
|
|
93
|
-
"react-dev-utils": "
|
|
98
|
+
"react-dev-utils": "12.0.0-next.47",
|
|
94
99
|
"react-error-overlay": "^6.0.9",
|
|
95
100
|
"react-helmet": "^6.1.0",
|
|
96
|
-
"react-loadable": "
|
|
101
|
+
"react-loadable": "npm:@docusaurus/react-loadable@5.5.2",
|
|
97
102
|
"react-loadable-ssr-addon-v5-slorber": "^1.0.1",
|
|
98
103
|
"react-router": "^5.2.0",
|
|
99
104
|
"react-router-config": "^5.1.1",
|
|
100
105
|
"react-router-dom": "^5.2.0",
|
|
106
|
+
"remark-admonitions": "^1.2.1",
|
|
101
107
|
"resolve-pathname": "^3.0.0",
|
|
102
|
-
"rtl-detect": "^1.0.
|
|
108
|
+
"rtl-detect": "^1.0.4",
|
|
103
109
|
"semver": "^7.3.4",
|
|
104
110
|
"serve-handler": "^6.1.3",
|
|
105
111
|
"shelljs": "^0.8.4",
|
|
106
112
|
"std-env": "^2.2.1",
|
|
107
113
|
"strip-ansi": "^6.0.0",
|
|
108
|
-
"terser-webpack-plugin": "^5.
|
|
109
|
-
"tslib": "^2.
|
|
114
|
+
"terser-webpack-plugin": "^5.2.4",
|
|
115
|
+
"tslib": "^2.3.1",
|
|
110
116
|
"update-notifier": "^5.1.0",
|
|
111
117
|
"url-loader": "^4.1.1",
|
|
112
|
-
"wait-on": "^
|
|
113
|
-
"webpack": "^5.
|
|
118
|
+
"wait-on": "^6.0.0",
|
|
119
|
+
"webpack": "^5.61.0",
|
|
114
120
|
"webpack-bundle-analyzer": "^4.4.2",
|
|
115
|
-
"webpack-dev-server": "^
|
|
121
|
+
"webpack-dev-server": "^4.4.0",
|
|
116
122
|
"webpack-merge": "^5.8.0",
|
|
117
123
|
"webpackbar": "^5.0.0-3"
|
|
118
124
|
},
|
|
@@ -121,7 +127,7 @@
|
|
|
121
127
|
"react-dom": "^16.8.4 || ^17.0.0"
|
|
122
128
|
},
|
|
123
129
|
"engines": {
|
|
124
|
-
"node": ">=
|
|
130
|
+
"node": ">=14"
|
|
125
131
|
},
|
|
126
|
-
"gitHead": "
|
|
132
|
+
"gitHead": "8a491fc29ad002f90e97f5b5fe4178ac8fa0c4d7"
|
|
127
133
|
}
|
package/tsconfig.client.json
CHANGED
package/tsconfig.json
CHANGED
|
@@ -6,8 +6,9 @@
|
|
|
6
6
|
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
|
7
7
|
"rootDir": "src",
|
|
8
8
|
"outDir": "lib",
|
|
9
|
-
"
|
|
10
|
-
"
|
|
9
|
+
"jsx": "react",
|
|
10
|
+
"allowJs": true
|
|
11
11
|
},
|
|
12
|
-
"
|
|
12
|
+
"include": ["src"],
|
|
13
|
+
"exclude": ["**/__tests__/**/*", "src/client"]
|
|
13
14
|
}
|