@docusaurus/core 2.0.0-beta.fc64c12e4 → 2.0.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/README.md +1 -0
- package/bin/beforeCli.mjs +140 -0
- package/bin/{docusaurus.js → docusaurus.mjs} +81 -118
- 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 -8
- 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 +18 -51
- package/lib/client/exports/Link.d.ts +4 -10
- package/lib/client/exports/Link.js +38 -38
- package/lib/client/exports/Translate.d.ts +1 -1
- package/lib/client/exports/Translate.js +11 -10
- 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 +6 -13
- 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 +108 -146
- 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/{server/html-tags/htmlTags.d.ts → client/theme-fallback/NotFound/index.d.ts} +2 -1
- 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/client/{exports/context.js → theme-fallback/SiteMetadata/index.d.ts} +2 -2
- 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 +94 -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 +29 -28
- package/lib/commands/start.d.ts +9 -2
- package/lib/commands/start.js +107 -102
- 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 +46 -25
- 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 +4 -4
- package/lib/server/configValidation.js +86 -41
- 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 -13
- package/lib/server/index.js +83 -165
- package/lib/server/plugins/configs.d.ts +51 -0
- package/lib/server/plugins/configs.js +101 -0
- package/lib/server/plugins/index.d.ts +9 -8
- package/lib/server/plugins/index.js +73 -137
- package/lib/server/plugins/init.d.ts +6 -5
- 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 +5 -1
- 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 +166 -99
- package/lib/server/siteMetadata.d.ts +12 -0
- package/lib/server/siteMetadata.js +81 -0
- package/lib/server/translations/translations.d.ts +14 -19
- package/lib/server/translations/translations.js +40 -72
- package/lib/server/translations/translationsExtractor.d.ts +10 -4
- package/lib/server/translations/translationsExtractor.js +158 -122
- package/lib/server/utils.d.ts +7 -1
- package/lib/server/utils.js +7 -8
- 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 +45 -57
- 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 +33 -17
- 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 +30 -29
- package/lib/webpack/server.d.ts +5 -5
- package/lib/webpack/server.js +21 -12
- 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 +3 -2
- package/lib/webpack/utils.d.ts +15 -31
- package/lib/webpack/utils.js +61 -182
- package/package.json +81 -77
- package/bin/beforeCli.js +0 -103
- package/lib/.tsbuildinfo +0 -1
- package/lib/choosePort.js +0 -105
- package/lib/client/.eslintrc.js +0 -29
- package/lib/client/.tsbuildinfo +0 -1
- 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 -40
- 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/plugins/applyRouteTrailingSlash.d.ts +0 -9
- package/lib/server/plugins/applyRouteTrailingSlash.js +0 -19
- 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 -12
- package/lib/server/themes/index.js +0 -47
- 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
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2015-present, Facebook, Inc.
|
|
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
|
-
/* eslint-disable */
|
|
8
|
-
/*
|
|
9
|
-
* THIS FILE IS MODIFIED FOR DOCUSAURUS
|
|
10
|
-
* the above copyright header must be preserved for license compliance.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
/*
|
|
14
|
-
Implementation has been copied from https://github.com/facebook/create-react-app/pull/10656
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
const friendlySyntaxErrorLabel = 'Syntax error:';
|
|
18
|
-
|
|
19
|
-
function isLikelyASyntaxError(message) {
|
|
20
|
-
return message.indexOf(friendlySyntaxErrorLabel) !== -1;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// Cleans up webpack error messages.
|
|
24
|
-
function formatMessage(message) {
|
|
25
|
-
let lines = [];
|
|
26
|
-
|
|
27
|
-
// modified for Docusaurus => see https://github.com/facebook/create-react-app/pull/10656
|
|
28
|
-
if (typeof message === 'string') {
|
|
29
|
-
lines = message.split('\n');
|
|
30
|
-
} else if ('message' in message) {
|
|
31
|
-
lines = message['message'].split('\n');
|
|
32
|
-
} else if (Array.isArray(message)) {
|
|
33
|
-
message.forEach((message) => {
|
|
34
|
-
if ('message' in message) {
|
|
35
|
-
lines = message['message'].split('\n');
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// Strip webpack-added headers off errors/warnings
|
|
41
|
-
// https://github.com/webpack/webpack/blob/master/lib/ModuleError.js
|
|
42
|
-
lines = lines.filter((line) => !/Module [A-z ]+\(from/.test(line));
|
|
43
|
-
|
|
44
|
-
// Transform parsing error into syntax error
|
|
45
|
-
// TODO: move this to our ESLint formatter?
|
|
46
|
-
lines = lines.map((line) => {
|
|
47
|
-
const parsingError = /Line (\d+):(?:(\d+):)?\s*Parsing error: (.+)$/.exec(
|
|
48
|
-
line,
|
|
49
|
-
);
|
|
50
|
-
if (!parsingError) {
|
|
51
|
-
return line;
|
|
52
|
-
}
|
|
53
|
-
const [, errorLine, errorColumn, errorMessage] = parsingError;
|
|
54
|
-
return `${friendlySyntaxErrorLabel} ${errorMessage} (${errorLine}:${errorColumn})`;
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
message = lines.join('\n');
|
|
58
|
-
// Smoosh syntax errors (commonly found in CSS)
|
|
59
|
-
message = message.replace(
|
|
60
|
-
/SyntaxError\s+\((\d+):(\d+)\)\s*(.+?)\n/g,
|
|
61
|
-
`${friendlySyntaxErrorLabel} $3 ($1:$2)\n`,
|
|
62
|
-
);
|
|
63
|
-
// Clean up export errors
|
|
64
|
-
message = message.replace(
|
|
65
|
-
/^.*export '(.+?)' was not found in '(.+?)'.*$/gm,
|
|
66
|
-
`Attempted import error: '$1' is not exported from '$2'.`,
|
|
67
|
-
);
|
|
68
|
-
message = message.replace(
|
|
69
|
-
/^.*export 'default' \(imported as '(.+?)'\) was not found in '(.+?)'.*$/gm,
|
|
70
|
-
`Attempted import error: '$2' does not contain a default export (imported as '$1').`,
|
|
71
|
-
);
|
|
72
|
-
message = message.replace(
|
|
73
|
-
/^.*export '(.+?)' \(imported as '(.+?)'\) was not found in '(.+?)'.*$/gm,
|
|
74
|
-
`Attempted import error: '$1' is not exported from '$3' (imported as '$2').`,
|
|
75
|
-
);
|
|
76
|
-
lines = message.split('\n');
|
|
77
|
-
|
|
78
|
-
// Remove leading newline
|
|
79
|
-
if (lines.length > 2 && lines[1].trim() === '') {
|
|
80
|
-
lines.splice(1, 1);
|
|
81
|
-
}
|
|
82
|
-
// Clean up file name
|
|
83
|
-
lines[0] = lines[0].replace(/^(.*) \d+:\d+-\d+$/, '$1');
|
|
84
|
-
|
|
85
|
-
// Cleans up verbose "module not found" messages for files and packages.
|
|
86
|
-
if (lines[1] && lines[1].indexOf('Module not found: ') === 0) {
|
|
87
|
-
lines = [
|
|
88
|
-
lines[0],
|
|
89
|
-
lines[1]
|
|
90
|
-
.replace('Error: ', '')
|
|
91
|
-
.replace('Module not found: Cannot find file:', 'Cannot find file:'),
|
|
92
|
-
];
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// Add helpful message for users trying to use Sass for the first time
|
|
96
|
-
if (lines[1] && lines[1].match(/Cannot find module.+node-sass/)) {
|
|
97
|
-
lines[1] = 'To import Sass files, you first need to install node-sass.\n';
|
|
98
|
-
lines[1] +=
|
|
99
|
-
'Run `npm install node-sass` or `yarn add node-sass` inside your workspace.';
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
message = lines.join('\n');
|
|
103
|
-
// Internal stacks are generally useless so we strip them... with the
|
|
104
|
-
// exception of stacks containing `webpack:` because they're normally
|
|
105
|
-
// from user code generated by webpack. For more information see
|
|
106
|
-
// https://github.com/facebook/create-react-app/pull/1050
|
|
107
|
-
message = message.replace(
|
|
108
|
-
/^\s*at\s((?!webpack:).)*:\d+:\d+[\s)]*(\n|$)/gm,
|
|
109
|
-
'',
|
|
110
|
-
); // at ... ...:x:y
|
|
111
|
-
message = message.replace(/^\s*at\s<anonymous>(\n|$)/gm, ''); // at <anonymous>
|
|
112
|
-
lines = message.split('\n');
|
|
113
|
-
|
|
114
|
-
// Remove duplicated newlines
|
|
115
|
-
lines = lines.filter(
|
|
116
|
-
(line, index, arr) =>
|
|
117
|
-
index === 0 ||
|
|
118
|
-
line.trim() !== '' ||
|
|
119
|
-
line.trim() !== arr[index - 1].trim(),
|
|
120
|
-
);
|
|
121
|
-
|
|
122
|
-
// Reassemble the message
|
|
123
|
-
message = lines.join('\n');
|
|
124
|
-
return message.trim();
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function formatWebpackMessages(json) {
|
|
128
|
-
const formattedErrors = json.errors.map(formatMessage);
|
|
129
|
-
const formattedWarnings = json.warnings.map(formatMessage);
|
|
130
|
-
const result = {errors: formattedErrors, warnings: formattedWarnings};
|
|
131
|
-
if (result.errors.some(isLikelyASyntaxError)) {
|
|
132
|
-
// If there are any syntax errors, show just them.
|
|
133
|
-
result.errors = result.errors.filter(isLikelyASyntaxError);
|
|
134
|
-
}
|
|
135
|
-
return result;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
module.exports = formatWebpackMessages;
|
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2015-present, Facebook, Inc.
|
|
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
|
-
/* eslint-disable */
|
|
8
|
-
/*
|
|
9
|
-
* THIS FILE IS MODIFIED FOR DOCUSAURUS
|
|
10
|
-
* the above copyright header must be preserved for license compliance.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
// This alternative WebpackDevServer combines the functionality of:
|
|
14
|
-
// https://github.com/webpack/webpack-dev-server/blob/webpack-1/client/index.js
|
|
15
|
-
// https://github.com/webpack/webpack/blob/webpack-1/hot/dev-server.js
|
|
16
|
-
|
|
17
|
-
// It only supports their simplest configuration (hot updates on same server).
|
|
18
|
-
// It makes some opinionated choices on top, like adding a syntax error overlay
|
|
19
|
-
// that looks similar to our console output. The error overlay is inspired by:
|
|
20
|
-
// https://github.com/glenjamin/webpack-hot-middleware
|
|
21
|
-
|
|
22
|
-
var stripAnsi = require('strip-ansi');
|
|
23
|
-
var url = require('url');
|
|
24
|
-
var launchEditorEndpoint = require('react-dev-utils/launchEditorEndpoint'); // modified for Docusaurus
|
|
25
|
-
var formatWebpackMessages = require('./formatWebpackMessages');
|
|
26
|
-
var ErrorOverlay = require('react-error-overlay');
|
|
27
|
-
|
|
28
|
-
ErrorOverlay.setEditorHandler(function editorHandler(errorLocation) {
|
|
29
|
-
// Keep this sync with errorOverlayMiddleware.js
|
|
30
|
-
fetch(
|
|
31
|
-
launchEditorEndpoint +
|
|
32
|
-
'?fileName=' +
|
|
33
|
-
window.encodeURIComponent(errorLocation.fileName) +
|
|
34
|
-
'&lineNumber=' +
|
|
35
|
-
window.encodeURIComponent(errorLocation.lineNumber || 1) +
|
|
36
|
-
'&colNumber=' +
|
|
37
|
-
window.encodeURIComponent(errorLocation.colNumber || 1),
|
|
38
|
-
);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
// We need to keep track of if there has been a runtime error.
|
|
42
|
-
// Essentially, we cannot guarantee application state was not corrupted by the
|
|
43
|
-
// runtime error. To prevent confusing behavior, we forcibly reload the entire
|
|
44
|
-
// application. This is handled below when we are notified of a compile (code
|
|
45
|
-
// change).
|
|
46
|
-
// See https://github.com/facebook/create-react-app/issues/3096
|
|
47
|
-
var hadRuntimeError = false;
|
|
48
|
-
ErrorOverlay.startReportingRuntimeErrors({
|
|
49
|
-
onError: function () {
|
|
50
|
-
hadRuntimeError = true;
|
|
51
|
-
},
|
|
52
|
-
filename: '/static/js/bundle.js',
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
if (module.hot && typeof module.hot.dispose === 'function') {
|
|
56
|
-
module.hot.dispose(function () {
|
|
57
|
-
// TODO: why do we need this?
|
|
58
|
-
ErrorOverlay.stopReportingRuntimeErrors();
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// Connect to WebpackDevServer via a socket.
|
|
63
|
-
var connection = new WebSocket(
|
|
64
|
-
url.format({
|
|
65
|
-
protocol: window.location.protocol === 'https:' ? 'wss' : 'ws',
|
|
66
|
-
// modified for Docusaurus => avoid "ReferenceError: process is not defined"
|
|
67
|
-
hostname: window.location.hostname,
|
|
68
|
-
port: window.location.port,
|
|
69
|
-
// Hardcoded in WebpackDevServer
|
|
70
|
-
pathname: '/sockjs-node',
|
|
71
|
-
slashes: true,
|
|
72
|
-
}),
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
// Unlike WebpackDevServer client, we won't try to reconnect
|
|
76
|
-
// to avoid spamming the console. Disconnect usually happens
|
|
77
|
-
// when developer stops the server.
|
|
78
|
-
connection.onclose = function () {
|
|
79
|
-
if (typeof console !== 'undefined' && typeof console.info === 'function') {
|
|
80
|
-
console.info(
|
|
81
|
-
'The development server has disconnected.\nRefresh the page if necessary.',
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
// Remember some state related to hot module replacement.
|
|
87
|
-
var isFirstCompilation = true;
|
|
88
|
-
var mostRecentCompilationHash = null;
|
|
89
|
-
var hasCompileErrors = false;
|
|
90
|
-
|
|
91
|
-
function clearOutdatedErrors() {
|
|
92
|
-
// Clean up outdated compile errors, if any.
|
|
93
|
-
if (typeof console !== 'undefined' && typeof console.clear === 'function') {
|
|
94
|
-
if (hasCompileErrors) {
|
|
95
|
-
console.clear();
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// Successful compilation.
|
|
101
|
-
function handleSuccess() {
|
|
102
|
-
clearOutdatedErrors();
|
|
103
|
-
|
|
104
|
-
var isHotUpdate = !isFirstCompilation;
|
|
105
|
-
isFirstCompilation = false;
|
|
106
|
-
hasCompileErrors = false;
|
|
107
|
-
|
|
108
|
-
// Attempt to apply hot updates or reload.
|
|
109
|
-
if (isHotUpdate) {
|
|
110
|
-
tryApplyUpdates(function onHotUpdateSuccess() {
|
|
111
|
-
// Only dismiss it when we're sure it's a hot update.
|
|
112
|
-
// Otherwise it would flicker right before the reload.
|
|
113
|
-
tryDismissErrorOverlay();
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// Compilation with warnings (e.g. ESLint).
|
|
119
|
-
function handleWarnings(warnings) {
|
|
120
|
-
clearOutdatedErrors();
|
|
121
|
-
|
|
122
|
-
var isHotUpdate = !isFirstCompilation;
|
|
123
|
-
isFirstCompilation = false;
|
|
124
|
-
hasCompileErrors = false;
|
|
125
|
-
|
|
126
|
-
function printWarnings() {
|
|
127
|
-
// Print warnings to the console.
|
|
128
|
-
var formatted = formatWebpackMessages({
|
|
129
|
-
warnings: warnings,
|
|
130
|
-
errors: [],
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
if (typeof console !== 'undefined' && typeof console.warn === 'function') {
|
|
134
|
-
for (var i = 0; i < formatted.warnings.length; i++) {
|
|
135
|
-
if (i === 5) {
|
|
136
|
-
console.warn(
|
|
137
|
-
'There were more warnings in other files.\n' +
|
|
138
|
-
'You can find a complete log in the terminal.',
|
|
139
|
-
);
|
|
140
|
-
break;
|
|
141
|
-
}
|
|
142
|
-
console.warn(stripAnsi(formatted.warnings[i]));
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
printWarnings();
|
|
148
|
-
|
|
149
|
-
// Attempt to apply hot updates or reload.
|
|
150
|
-
if (isHotUpdate) {
|
|
151
|
-
tryApplyUpdates(function onSuccessfulHotUpdate() {
|
|
152
|
-
// Only dismiss it when we're sure it's a hot update.
|
|
153
|
-
// Otherwise it would flicker right before the reload.
|
|
154
|
-
tryDismissErrorOverlay();
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// Compilation with errors (e.g. syntax error or missing modules).
|
|
160
|
-
function handleErrors(errors) {
|
|
161
|
-
clearOutdatedErrors();
|
|
162
|
-
|
|
163
|
-
isFirstCompilation = false;
|
|
164
|
-
hasCompileErrors = true;
|
|
165
|
-
|
|
166
|
-
// "Massage" webpack messages.
|
|
167
|
-
var formatted = formatWebpackMessages({
|
|
168
|
-
errors: errors,
|
|
169
|
-
warnings: [],
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
// Only show the first error.
|
|
173
|
-
ErrorOverlay.reportBuildError(formatted.errors[0]);
|
|
174
|
-
|
|
175
|
-
// Also log them to the console.
|
|
176
|
-
if (typeof console !== 'undefined' && typeof console.error === 'function') {
|
|
177
|
-
for (var i = 0; i < formatted.errors.length; i++) {
|
|
178
|
-
console.error(stripAnsi(formatted.errors[i]));
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
// Do not attempt to reload now.
|
|
183
|
-
// We will reload on next success instead.
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
function tryDismissErrorOverlay() {
|
|
187
|
-
if (!hasCompileErrors) {
|
|
188
|
-
ErrorOverlay.dismissBuildError();
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// There is a newer version of the code available.
|
|
193
|
-
function handleAvailableHash(hash) {
|
|
194
|
-
// Update last known compilation hash.
|
|
195
|
-
mostRecentCompilationHash = hash;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
// Handle messages from the server.
|
|
199
|
-
connection.onmessage = function (e) {
|
|
200
|
-
var message = JSON.parse(e.data);
|
|
201
|
-
switch (message.type) {
|
|
202
|
-
case 'hash':
|
|
203
|
-
handleAvailableHash(message.data);
|
|
204
|
-
break;
|
|
205
|
-
case 'still-ok':
|
|
206
|
-
case 'ok':
|
|
207
|
-
handleSuccess();
|
|
208
|
-
break;
|
|
209
|
-
case 'content-changed':
|
|
210
|
-
// Triggered when a file from `contentBase` changed.
|
|
211
|
-
window.location.reload();
|
|
212
|
-
break;
|
|
213
|
-
case 'warnings':
|
|
214
|
-
handleWarnings(message.data);
|
|
215
|
-
break;
|
|
216
|
-
case 'errors':
|
|
217
|
-
handleErrors(message.data);
|
|
218
|
-
break;
|
|
219
|
-
default:
|
|
220
|
-
// Do nothing.
|
|
221
|
-
}
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
// Is there a newer version of this code available?
|
|
225
|
-
function isUpdateAvailable() {
|
|
226
|
-
/* globals __webpack_hash__ */
|
|
227
|
-
// __webpack_hash__ is the hash of the current compilation.
|
|
228
|
-
// It's a global variable injected by webpack.
|
|
229
|
-
return mostRecentCompilationHash !== __webpack_hash__;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
// webpack disallows updates in other states.
|
|
233
|
-
function canApplyUpdates() {
|
|
234
|
-
return module.hot.status() === 'idle';
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
// Attempt to update code on the fly, fall back to a hard reload.
|
|
238
|
-
function tryApplyUpdates(onHotUpdateSuccess) {
|
|
239
|
-
if (!module.hot) {
|
|
240
|
-
// HotModuleReplacementPlugin is not in webpack configuration.
|
|
241
|
-
window.location.reload();
|
|
242
|
-
return;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
if (!isUpdateAvailable() || !canApplyUpdates()) {
|
|
246
|
-
return;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
function handleApplyUpdates(err, updatedModules) {
|
|
250
|
-
// NOTE: This var is injected by Webpack's DefinePlugin, and is a boolean instead of string.
|
|
251
|
-
// const hasReactRefresh = process.env.FAST_REFRESH;
|
|
252
|
-
const hasReactRefresh = true; // modified for Docusaurus => avoid "ReferenceError: process is not defined"
|
|
253
|
-
const wantsForcedReload = err || !updatedModules || hadRuntimeError;
|
|
254
|
-
// React refresh can handle hot-reloading over errors.
|
|
255
|
-
if (!hasReactRefresh && wantsForcedReload) {
|
|
256
|
-
window.location.reload();
|
|
257
|
-
return;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
if (typeof onHotUpdateSuccess === 'function') {
|
|
261
|
-
// Maybe we want to do something.
|
|
262
|
-
onHotUpdateSuccess();
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
if (isUpdateAvailable()) {
|
|
266
|
-
// While we were updating, there was a new update! Do it again.
|
|
267
|
-
tryApplyUpdates();
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
// https://webpack.github.io/docs/hot-module-replacement.html#check
|
|
272
|
-
var result = module.hot.check(/* autoApply */ true, handleApplyUpdates);
|
|
273
|
-
|
|
274
|
-
// // webpack 2 returns a Promise instead of invoking a callback
|
|
275
|
-
if (result && result.then) {
|
|
276
|
-
result.then(
|
|
277
|
-
function (updatedModules) {
|
|
278
|
-
handleApplyUpdates(null, updatedModules);
|
|
279
|
-
},
|
|
280
|
-
function (err) {
|
|
281
|
-
handleApplyUpdates(err, null);
|
|
282
|
-
},
|
|
283
|
-
);
|
|
284
|
-
}
|
|
285
|
-
}
|
|
@@ -1,10 +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
|
-
declare const SharedModuleAliases: {
|
|
8
|
-
'react-loadable': string;
|
|
9
|
-
};
|
|
10
|
-
export default SharedModuleAliases;
|
|
@@ -1,18 +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
|
-
const module_alias_1 = tslib_1.__importDefault(require("module-alias"));
|
|
11
|
-
// The shared module aliases are module aliases that need to work in both SSR/NodeJS + Webpack
|
|
12
|
-
const SharedModuleAliases = {
|
|
13
|
-
// Useful to fix the react-loadable warning
|
|
14
|
-
// See https://github.com/jamiebuilds/react-loadable/pull/213#issuecomment-778246548
|
|
15
|
-
'react-loadable': '@docusaurus/react-loadable',
|
|
16
|
-
};
|
|
17
|
-
module_alias_1.default.addAliases(SharedModuleAliases);
|
|
18
|
-
exports.default = SharedModuleAliases;
|
package/tsconfig.client.json
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"incremental": true,
|
|
5
|
-
"lib": ["DOM", "ES2019"],
|
|
6
|
-
"module": "esnext",
|
|
7
|
-
"tsBuildInfoFile": "./lib/client/.tsbuildinfo",
|
|
8
|
-
"outDir": "lib/client",
|
|
9
|
-
"noImplicitAny": false,
|
|
10
|
-
"jsx": "react"
|
|
11
|
-
},
|
|
12
|
-
"include": ["src/client"]
|
|
13
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"incremental": true,
|
|
5
|
-
"lib": ["DOM", "ES2019"],
|
|
6
|
-
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
|
7
|
-
"rootDir": "src",
|
|
8
|
-
"outDir": "lib",
|
|
9
|
-
"noImplicitAny": false,
|
|
10
|
-
"jsx": "react"
|
|
11
|
-
},
|
|
12
|
-
"exclude": ["node_modules", "**/__tests__/**/*", "**/lib/**/*", "src/client"]
|
|
13
|
-
}
|