@docusaurus/core 2.0.0-beta.12faed89d → 2.0.0-beta.14
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 +46 -22
- package/bin/docusaurus.js +42 -44
- package/lib/babel/preset.d.ts +6 -0
- package/lib/babel/preset.js +3 -3
- package/lib/choosePort.js +19 -20
- package/lib/client/.eslintrc.js +0 -1
- package/lib/client/App.js +12 -22
- package/lib/client/LinksCollector.d.ts +2 -2
- package/lib/client/LinksCollector.js +4 -8
- package/lib/client/PendingNavigation.d.ts +24 -1
- package/lib/client/PendingNavigation.js +1 -1
- package/lib/client/baseUrlIssueBanner/BaseUrlIssueBanner.d.ts +5 -0
- package/lib/client/client-lifecycles-dispatcher.d.ts +2 -2
- package/lib/client/client-lifecycles-dispatcher.js +0 -2
- package/lib/client/docusaurus.d.ts +6 -0
- package/lib/client/docusaurus.js +11 -19
- package/lib/client/exports/BrowserOnly.js +5 -3
- package/lib/client/exports/ErrorBoundary.d.ts +18 -0
- package/lib/client/exports/ErrorBoundary.js +35 -0
- package/lib/client/exports/Interpolate.js +12 -15
- package/lib/client/exports/Link.js +9 -9
- package/lib/client/exports/Translate.d.ts +2 -2
- package/lib/client/exports/Translate.js +13 -9
- 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 +2 -4
- 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/{webpack/sharedModuleAliases.d.ts → client/exports/useIsBrowser.js} +5 -4
- package/lib/client/flat.d.ts +2 -1
- package/lib/client/flat.js +7 -9
- package/lib/client/normalizeLocation.d.ts +1 -3
- package/lib/client/prefetch.js +0 -1
- package/lib/client/serverEntry.js +20 -42
- package/lib/client/theme-fallback/Error/index.js +47 -0
- package/lib/client/theme-fallback/Layout/index.js +1 -1
- package/lib/client/theme-fallback/Loading/index.js +2 -2
- package/lib/client/theme-fallback/Root/index.js +1 -3
- package/lib/commands/build.js +39 -44
- package/lib/commands/clear.d.ts +6 -0
- package/lib/commands/clear.js +17 -18
- package/lib/commands/commandUtils.d.ts +6 -0
- package/lib/commands/commandUtils.js +7 -7
- package/lib/commands/deploy.d.ts +3 -0
- package/lib/commands/deploy.js +99 -64
- package/lib/commands/external.js +4 -4
- package/lib/commands/serve.js +12 -18
- package/lib/commands/start.js +98 -86
- package/lib/commands/swizzle.js +42 -51
- package/lib/commands/writeHeadingIds.d.ts +9 -6
- package/lib/commands/writeHeadingIds.js +33 -34
- package/lib/commands/writeTranslations.js +31 -11
- package/lib/server/brokenLinks.js +13 -17
- package/lib/server/client-modules/index.js +1 -3
- package/lib/server/config.js +4 -4
- package/lib/server/configValidation.d.ts +1 -1
- package/lib/server/configValidation.js +14 -7
- package/lib/server/duplicateRoutes.js +8 -2
- package/lib/server/html-tags/htmlTags.js +5 -6
- package/lib/server/html-tags/index.js +2 -2
- package/lib/server/i18n.js +16 -16
- package/lib/server/index.js +132 -59
- package/lib/server/loadSetup.js +3 -3
- package/lib/server/moduleShorthand.d.ts +9 -0
- package/lib/server/moduleShorthand.js +42 -0
- package/lib/server/plugins/applyRouteTrailingSlash.js +1 -1
- package/lib/server/plugins/index.d.ts +1 -1
- package/lib/server/plugins/index.js +25 -21
- package/lib/server/plugins/init.js +9 -12
- package/lib/server/plugins/pluginIds.js +6 -4
- package/lib/server/presets/index.js +12 -12
- package/lib/server/routes.js +9 -11
- package/lib/server/themes/alias.d.ts +1 -0
- package/lib/server/themes/alias.js +21 -12
- package/lib/server/themes/index.d.ts +1 -1
- package/lib/server/themes/index.js +22 -23
- package/lib/server/translations/translations.d.ts +6 -0
- package/lib/server/translations/translations.js +19 -26
- package/lib/server/translations/translationsExtractor.d.ts +7 -1
- package/lib/server/translations/translationsExtractor.js +66 -59
- package/lib/server/utils.d.ts +8 -2
- package/lib/server/utils.js +8 -10
- 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 +14 -16
- package/lib/webpack/client.js +9 -18
- package/lib/webpack/plugins/CleanWebpackPlugin.js +4 -11
- package/lib/webpack/plugins/LogPlugin.js +5 -6
- package/lib/webpack/plugins/WaitPlugin.js +4 -4
- package/lib/webpack/server.js +9 -9
- package/lib/webpack/utils.d.ts +0 -22
- package/lib/webpack/utils.js +37 -134
- package/package.json +55 -50
- package/lib/.tsbuildinfo +0 -1
- package/lib/client/.tsbuildinfo +0 -1
- package/lib/commands/buildRemoteBranchUrl.d.ts +0 -7
- package/lib/commands/buildRemoteBranchUrl.js +0 -27
- package/lib/constants.d.ts +0 -18
- package/lib/constants.js +0 -23
- 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.js +0 -18
- package/tsconfig.client.json +0 -13
- package/tsconfig.json +0 -13
|
@@ -10,16 +10,16 @@ const __1 = require("..");
|
|
|
10
10
|
const path_1 = require("path");
|
|
11
11
|
describe('getPluginVersion', () => {
|
|
12
12
|
it('Can detect external packages plugins versions of correctly.', () => {
|
|
13
|
-
expect(__1.getPluginVersion(path_1.join(__dirname, '..', '__fixtures__', 'dummy-plugin.js'),
|
|
13
|
+
expect((0, __1.getPluginVersion)((0, path_1.join)(__dirname, '..', '__fixtures__', 'dummy-plugin.js'),
|
|
14
14
|
// Make the plugin appear external.
|
|
15
|
-
path_1.join(__dirname, '..', '..', '..', '..', '..', '..', 'website'))).toEqual({ type: 'package', version: 'random-version' });
|
|
15
|
+
(0, path_1.join)(__dirname, '..', '..', '..', '..', '..', '..', 'website'))).toEqual({ type: 'package', version: 'random-version' });
|
|
16
16
|
});
|
|
17
17
|
it('Can detect project plugins versions correctly.', () => {
|
|
18
|
-
expect(__1.getPluginVersion(path_1.join(__dirname, '..', '__fixtures__', 'dummy-plugin.js'),
|
|
18
|
+
expect((0, __1.getPluginVersion)((0, path_1.join)(__dirname, '..', '__fixtures__', 'dummy-plugin.js'),
|
|
19
19
|
// Make the plugin appear project local.
|
|
20
|
-
path_1.join(__dirname, '..', '__fixtures__'))).toEqual({ type: 'project' });
|
|
20
|
+
(0, path_1.join)(__dirname, '..', '__fixtures__'))).toEqual({ type: 'project' });
|
|
21
21
|
});
|
|
22
22
|
it('Can detect local packages versions correctly.', () => {
|
|
23
|
-
expect(__1.getPluginVersion('/', '/')).toEqual({ type: 'local' });
|
|
23
|
+
expect((0, __1.getPluginVersion)('/', '/')).toEqual({ type: 'local' });
|
|
24
24
|
});
|
|
25
25
|
});
|
|
@@ -10,7 +10,7 @@ exports.getPluginVersion = exports.getPackageJsonName = exports.getPackageJsonVe
|
|
|
10
10
|
const fs_extra_1 = require("fs-extra");
|
|
11
11
|
const path_1 = require("path");
|
|
12
12
|
function getPackageJsonVersion(packageJsonPath) {
|
|
13
|
-
if (fs_extra_1.existsSync(packageJsonPath)) {
|
|
13
|
+
if ((0, fs_extra_1.existsSync)(packageJsonPath)) {
|
|
14
14
|
// eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-dynamic-require, global-require
|
|
15
15
|
const { version } = require(packageJsonPath);
|
|
16
16
|
return typeof version === 'string' ? version : undefined;
|
|
@@ -19,7 +19,7 @@ function getPackageJsonVersion(packageJsonPath) {
|
|
|
19
19
|
}
|
|
20
20
|
exports.getPackageJsonVersion = getPackageJsonVersion;
|
|
21
21
|
function getPackageJsonName(packageJsonPath) {
|
|
22
|
-
if (fs_extra_1.existsSync(packageJsonPath)) {
|
|
22
|
+
if ((0, fs_extra_1.existsSync)(packageJsonPath)) {
|
|
23
23
|
// eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-dynamic-require, global-require
|
|
24
24
|
const { name } = require(packageJsonPath);
|
|
25
25
|
return typeof name === 'string' ? name : undefined;
|
|
@@ -28,10 +28,10 @@ function getPackageJsonName(packageJsonPath) {
|
|
|
28
28
|
}
|
|
29
29
|
exports.getPackageJsonName = getPackageJsonName;
|
|
30
30
|
function getPluginVersion(pluginPath, siteDir) {
|
|
31
|
-
let potentialPluginPackageJsonDirectory = path_1.dirname(pluginPath);
|
|
31
|
+
let potentialPluginPackageJsonDirectory = (0, path_1.dirname)(pluginPath);
|
|
32
32
|
while (potentialPluginPackageJsonDirectory !== '/') {
|
|
33
|
-
const packageJsonPath = path_1.join(potentialPluginPackageJsonDirectory, 'package.json');
|
|
34
|
-
if (fs_extra_1.existsSync(packageJsonPath) && fs_extra_1.lstatSync(packageJsonPath).isFile()) {
|
|
33
|
+
const packageJsonPath = (0, path_1.join)(potentialPluginPackageJsonDirectory, 'package.json');
|
|
34
|
+
if ((0, fs_extra_1.existsSync)(packageJsonPath) && (0, fs_extra_1.lstatSync)(packageJsonPath).isFile()) {
|
|
35
35
|
if (potentialPluginPackageJsonDirectory === siteDir) {
|
|
36
36
|
// If the plugin belongs to the same docusaurus project, we classify it as local plugin.
|
|
37
37
|
return { type: 'project' };
|
|
@@ -42,7 +42,7 @@ function getPluginVersion(pluginPath, siteDir) {
|
|
|
42
42
|
version: getPackageJsonVersion(packageJsonPath),
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
|
-
potentialPluginPackageJsonDirectory = path_1.dirname(potentialPluginPackageJsonDirectory);
|
|
45
|
+
potentialPluginPackageJsonDirectory = (0, path_1.dirname)(potentialPluginPackageJsonDirectory);
|
|
46
46
|
}
|
|
47
47
|
// In rare cases where a plugin is a path where no parent directory contains package.json, we can only classify it as local.
|
|
48
48
|
return { type: 'local' };
|
package/lib/webpack/base.js
CHANGED
|
@@ -8,12 +8,10 @@
|
|
|
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
|
-
const constants_1 = require("../constants");
|
|
16
|
-
const sharedModuleAliases_1 = tslib_1.__importDefault(require("./sharedModuleAliases"));
|
|
17
15
|
const themes_1 = require("../server/themes");
|
|
18
16
|
const utils_2 = require("@docusaurus/utils");
|
|
19
17
|
const CSS_REGEX = /\.css$/;
|
|
@@ -55,10 +53,10 @@ function createBaseConfig(props, isServer, minify = true) {
|
|
|
55
53
|
const isProd = process.env.NODE_ENV === 'production';
|
|
56
54
|
const minimizeEnabled = minify && isProd && !isServer;
|
|
57
55
|
const useSimpleCssMinifier = process.env.USE_SIMPLE_CSS_MINIFIER === 'true';
|
|
58
|
-
const fileLoaderUtils =
|
|
56
|
+
const fileLoaderUtils = (0, utils_2.getFileLoaderUtils)();
|
|
59
57
|
const name = isServer ? 'server' : 'client';
|
|
60
58
|
const mode = isProd ? 'production' : 'development';
|
|
61
|
-
const themeAliases = themes_1.loadPluginsThemeAliases({ siteDir, plugins });
|
|
59
|
+
const themeAliases = (0, themes_1.loadPluginsThemeAliases)({ siteDir, plugins });
|
|
62
60
|
return {
|
|
63
61
|
mode,
|
|
64
62
|
name,
|
|
@@ -73,7 +71,7 @@ function createBaseConfig(props, isServer, minify = true) {
|
|
|
73
71
|
siteMetadata.docusaurusVersion,
|
|
74
72
|
// Webpack does not evict the cache correctly on alias/swizzle change, so we force eviction.
|
|
75
73
|
// See https://github.com/webpack/webpack/issues/13627
|
|
76
|
-
utils_2.md5Hash(JSON.stringify(themeAliases)),
|
|
74
|
+
(0, utils_2.md5Hash)(JSON.stringify(themeAliases)),
|
|
77
75
|
].join('-'),
|
|
78
76
|
// When one of those modules/dependencies change (including transitive deps), cache is invalidated
|
|
79
77
|
buildDependencies: {
|
|
@@ -94,6 +92,7 @@ function createBaseConfig(props, isServer, minify = true) {
|
|
|
94
92
|
? 'assets/js/[name].[contenthash:8].js'
|
|
95
93
|
: '[name].js',
|
|
96
94
|
publicPath: baseUrl,
|
|
95
|
+
hashFunction: 'xxhash64',
|
|
97
96
|
},
|
|
98
97
|
// Don't throw warning when asset created is over 250kb
|
|
99
98
|
performance: {
|
|
@@ -103,17 +102,16 @@ function createBaseConfig(props, isServer, minify = true) {
|
|
|
103
102
|
resolve: {
|
|
104
103
|
unsafeCache: false,
|
|
105
104
|
extensions: ['.wasm', '.mjs', '.js', '.jsx', '.ts', '.tsx', '.json'],
|
|
106
|
-
symlinks:
|
|
105
|
+
symlinks: true,
|
|
107
106
|
roots: [
|
|
108
107
|
// Allow resolution of url("/fonts/xyz.ttf") by webpack
|
|
109
108
|
// See https://webpack.js.org/configuration/resolve/#resolveroots
|
|
110
109
|
// See https://github.com/webpack-contrib/css-loader/issues/1256
|
|
111
|
-
path_1.default.
|
|
110
|
+
...siteConfig.staticDirectories.map((dir) => path_1.default.resolve(siteDir, dir)),
|
|
112
111
|
siteDir,
|
|
113
112
|
process.cwd(),
|
|
114
113
|
],
|
|
115
114
|
alias: {
|
|
116
|
-
...sharedModuleAliases_1.default,
|
|
117
115
|
'@site': siteDir,
|
|
118
116
|
'@generated': generatedFilesDir,
|
|
119
117
|
// Note: a @docusaurus alias would also catch @docusaurus/theme-common,
|
|
@@ -140,7 +138,7 @@ function createBaseConfig(props, isServer, minify = true) {
|
|
|
140
138
|
// Only minimize client bundle in production because server bundle is only used for static site generation
|
|
141
139
|
minimize: minimizeEnabled,
|
|
142
140
|
minimizer: minimizeEnabled
|
|
143
|
-
? utils_1.getMinimizer(useSimpleCssMinifier)
|
|
141
|
+
? (0, utils_1.getMinimizer)(useSimpleCssMinifier)
|
|
144
142
|
: undefined,
|
|
145
143
|
splitChunks: isServer
|
|
146
144
|
? false
|
|
@@ -180,16 +178,16 @@ function createBaseConfig(props, isServer, minify = true) {
|
|
|
180
178
|
test: /\.(j|t)sx?$/,
|
|
181
179
|
exclude: excludeJS,
|
|
182
180
|
use: [
|
|
183
|
-
utils_1.getCustomizableJSLoader((_a = siteConfig.webpack) === null || _a === void 0 ? void 0 : _a.jsLoader)({
|
|
181
|
+
(0, utils_1.getCustomizableJSLoader)((_a = siteConfig.webpack) === null || _a === void 0 ? void 0 : _a.jsLoader)({
|
|
184
182
|
isServer,
|
|
185
|
-
babelOptions: utils_1.getCustomBabelConfigFilePath(siteDir),
|
|
183
|
+
babelOptions: (0, utils_1.getCustomBabelConfigFilePath)(siteDir),
|
|
186
184
|
}),
|
|
187
185
|
],
|
|
188
186
|
},
|
|
189
187
|
{
|
|
190
188
|
test: CSS_REGEX,
|
|
191
189
|
exclude: CSS_MODULE_REGEX,
|
|
192
|
-
use: utils_1.getStyleLoaders(isServer, {
|
|
190
|
+
use: (0, utils_1.getStyleLoaders)(isServer, {
|
|
193
191
|
importLoaders: 1,
|
|
194
192
|
sourceMap: !isProd,
|
|
195
193
|
}),
|
|
@@ -198,7 +196,7 @@ function createBaseConfig(props, isServer, minify = true) {
|
|
|
198
196
|
// using the extension .module.css
|
|
199
197
|
{
|
|
200
198
|
test: CSS_MODULE_REGEX,
|
|
201
|
-
use: utils_1.getStyleLoaders(isServer, {
|
|
199
|
+
use: (0, utils_1.getStyleLoaders)(isServer, {
|
|
202
200
|
modules: {
|
|
203
201
|
localIdentName: isProd
|
|
204
202
|
? `[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
|
|
11
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
12
|
-
const webpack_merge_1 = tslib_1.__importDefault(require("webpack-merge"));
|
|
10
|
+
const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
|
|
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
|
|
@@ -48,7 +39,7 @@ function createClientConfig(props, minify = true) {
|
|
|
48
39
|
apply: (compiler) => {
|
|
49
40
|
compiler.hooks.done.tap('client:done', (stats) => {
|
|
50
41
|
if (stats.hasErrors()) {
|
|
51
|
-
|
|
42
|
+
logger_1.default.error('Client bundle compiled with errors therefore further build is impossible.');
|
|
52
43
|
process.exit(1);
|
|
53
44
|
}
|
|
54
45
|
});
|
|
@@ -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;
|
|
@@ -88,17 +86,13 @@ class CleanWebpackPlugin {
|
|
|
88
86
|
all: false,
|
|
89
87
|
assets: true,
|
|
90
88
|
}).assets || [];
|
|
91
|
-
const assets = statsAssets.map((asset) =>
|
|
92
|
-
return asset.name;
|
|
93
|
-
});
|
|
89
|
+
const assets = statsAssets.map((asset) => asset.name);
|
|
94
90
|
/**
|
|
95
91
|
* Get all files that were in the previous build but not the current
|
|
96
92
|
*
|
|
97
93
|
* (relies on del's cwd: outputPath option)
|
|
98
94
|
*/
|
|
99
|
-
const staleFiles = this.currentAssets.filter((previousAsset) =>
|
|
100
|
-
return assets.includes(previousAsset) === false;
|
|
101
|
-
});
|
|
95
|
+
const staleFiles = this.currentAssets.filter((previousAsset) => assets.includes(previousAsset) === false);
|
|
102
96
|
/**
|
|
103
97
|
* Save assets for next compilation
|
|
104
98
|
*/
|
|
@@ -116,7 +110,7 @@ class CleanWebpackPlugin {
|
|
|
116
110
|
}
|
|
117
111
|
removeFiles(patterns) {
|
|
118
112
|
try {
|
|
119
|
-
const deleted = del_1.sync(patterns, {
|
|
113
|
+
const deleted = (0, del_1.sync)(patterns, {
|
|
120
114
|
force: false,
|
|
121
115
|
// Change context to build directory
|
|
122
116
|
cwd: this.outputPath,
|
|
@@ -135,7 +129,6 @@ class CleanWebpackPlugin {
|
|
|
135
129
|
* https://github.com/webpack/webpack/issues/1904
|
|
136
130
|
* https://github.com/johnagan/clean-webpack-plugin/issues/11
|
|
137
131
|
*/
|
|
138
|
-
// eslint-disable-next-line no-console
|
|
139
132
|
console.warn(`clean-webpack-plugin: removed ${filename}`);
|
|
140
133
|
});
|
|
141
134
|
}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
2
|
/**
|
|
5
3
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
4
|
*
|
|
7
5
|
* This source code is licensed under the MIT license found in the
|
|
8
6
|
* LICENSE file in the root directory of this source tree.
|
|
9
7
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
const tslib_1 = require("tslib");
|
|
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
|
})
|
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"));
|
|
15
|
-
const
|
|
13
|
+
const WaitPlugin_1 = (0, tslib_1.__importDefault)(require("./plugins/WaitPlugin"));
|
|
14
|
+
const LogPlugin_1 = (0, tslib_1.__importDefault)(require("./plugins/LogPlugin"));
|
|
15
|
+
const utils_1 = require("@docusaurus/utils");
|
|
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,8 +25,8 @@ function createServerConfig({ props, onLinksCollected = () => { }, }) {
|
|
|
25
25
|
routesLocation[ssgPath] = str;
|
|
26
26
|
return ssgPath;
|
|
27
27
|
});
|
|
28
|
-
const serverConfig = webpack_merge_1.default(config, {
|
|
29
|
-
target: `node${
|
|
28
|
+
const serverConfig = (0, webpack_merge_1.default)(config, {
|
|
29
|
+
target: `node${utils_1.NODE_MAJOR_VERSION}.${utils_1.NODE_MINOR_VERSION}`,
|
|
30
30
|
entry: {
|
|
31
31
|
main: path_1.default.resolve(__dirname, '../client/serverEntry.js'),
|
|
32
32
|
},
|
package/lib/webpack/utils.d.ts
CHANGED
|
@@ -32,30 +32,8 @@ export declare const getCustomizableJSLoader: (jsLoader?: "babel" | ((isServer:
|
|
|
32
32
|
export declare function applyConfigureWebpack(configureWebpack: ConfigureWebpackFn, config: Configuration, isServer: boolean, jsLoader: 'babel' | ((isServer: boolean) => RuleSetRule) | undefined, content: unknown): Configuration;
|
|
33
33
|
export declare function applyConfigurePostCss(configurePostCss: NonNullable<ConfigurePostCssFn>, config: Configuration): Configuration;
|
|
34
34
|
export declare function compile(config: Configuration[]): Promise<void>;
|
|
35
|
-
declare type AssetFolder = 'images' | 'files' | 'fonts' | 'medias';
|
|
36
|
-
declare type FileLoaderUtils = {
|
|
37
|
-
loaders: {
|
|
38
|
-
file: (options: {
|
|
39
|
-
folder: AssetFolder;
|
|
40
|
-
}) => RuleSetRule;
|
|
41
|
-
url: (options: {
|
|
42
|
-
folder: AssetFolder;
|
|
43
|
-
}) => RuleSetRule;
|
|
44
|
-
inlineMarkdownImageFileLoader: string;
|
|
45
|
-
inlineMarkdownLinkFileLoader: string;
|
|
46
|
-
};
|
|
47
|
-
rules: {
|
|
48
|
-
images: () => RuleSetRule;
|
|
49
|
-
fonts: () => RuleSetRule;
|
|
50
|
-
media: () => RuleSetRule;
|
|
51
|
-
svg: () => RuleSetRule;
|
|
52
|
-
otherAssets: () => RuleSetRule;
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
export declare function getFileLoaderUtils(): FileLoaderUtils;
|
|
56
35
|
export declare function getHttpsConfig(): boolean | {
|
|
57
36
|
cert: Buffer;
|
|
58
37
|
key: Buffer;
|
|
59
38
|
};
|
|
60
39
|
export declare function getMinimizer(useSimpleCssMinifier?: boolean): WebpackPluginInstance[];
|
|
61
|
-
export {};
|