@docusaurus/core 2.0.0-beta.1 → 2.0.0-beta.10
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 +125 -0
- package/bin/docusaurus.js +36 -105
- package/lib/.tsbuildinfo +1 -1
- package/lib/babel/preset.d.ts +6 -0
- package/lib/babel/preset.js +3 -3
- package/lib/choosePort.js +12 -13
- package/lib/client/.eslintrc.js +0 -1
- package/lib/client/.tsbuildinfo +1 -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 +11 -11
- 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 +15 -31
- 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 +37 -40
- package/lib/commands/clear.d.ts +6 -0
- package/lib/commands/clear.js +9 -9
- 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 +98 -53
- package/lib/commands/external.js +4 -4
- package/lib/commands/serve.js +13 -13
- package/lib/commands/start.js +83 -73
- package/lib/commands/swizzle.js +49 -49
- package/lib/commands/writeHeadingIds.d.ts +9 -6
- package/lib/commands/writeHeadingIds.js +32 -32
- 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 +12 -7
- package/lib/server/duplicateRoutes.js +8 -2
- package/lib/server/html-tags/htmlTags.js +5 -6
- package/lib/server/html-tags/index.d.ts +2 -2
- package/lib/server/html-tags/index.js +3 -3
- package/lib/server/i18n.js +16 -13
- package/lib/server/index.js +129 -71
- 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.d.ts +2 -1
- package/lib/server/plugins/applyRouteTrailingSlash.js +3 -3
- package/lib/server/plugins/index.d.ts +3 -4
- package/lib/server/plugins/index.js +44 -33
- package/lib/server/plugins/init.d.ts +2 -6
- package/lib/server/plugins/init.js +9 -12
- package/lib/server/plugins/pluginIds.d.ts +2 -2
- package/lib/server/plugins/pluginIds.js +6 -4
- package/lib/server/presets/index.js +12 -12
- package/lib/server/routes.js +41 -23
- package/lib/server/themes/alias.d.ts +3 -2
- package/lib/server/themes/alias.js +22 -12
- package/lib/server/themes/index.d.ts +6 -2
- package/lib/server/themes/index.js +32 -21
- package/lib/server/translations/translations.d.ts +10 -5
- package/lib/server/translations/translations.js +15 -17
- package/lib/server/translations/translationsExtractor.d.ts +8 -3
- package/lib/server/translations/translationsExtractor.js +65 -56
- 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 +29 -21
- package/lib/webpack/client.js +8 -17
- 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 +13 -9
- package/lib/webpack/utils.d.ts +2 -23
- package/lib/webpack/utils.js +29 -127
- package/package.json +56 -51
- package/tsconfig.client.json +1 -2
- package/tsconfig.json +5 -4
- 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
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.extractSourceCodeFileTranslations = exports.extractAllSourceCodeFileTranslations = exports.extractSiteSourceCodeTranslations = exports.globSourceCodeFilePaths = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
2
|
/**
|
|
6
3
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
7
4
|
*
|
|
8
5
|
* This source code is licensed under the MIT license found in the
|
|
9
6
|
* LICENSE file in the root directory of this source tree.
|
|
10
7
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
const
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.extractSourceCodeFileTranslations = exports.extractAllSourceCodeFileTranslations = exports.extractSiteSourceCodeTranslations = exports.globSourceCodeFilePaths = void 0;
|
|
10
|
+
const tslib_1 = require("tslib");
|
|
11
|
+
const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
|
|
12
|
+
const traverse_1 = (0, tslib_1.__importDefault)(require("@babel/traverse"));
|
|
13
|
+
const generator_1 = (0, tslib_1.__importDefault)(require("@babel/generator"));
|
|
14
|
+
const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
|
|
15
15
|
const core_1 = require("@babel/core");
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const utils_1 = require("../utils");
|
|
16
|
+
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
17
|
+
const utils_1 = require("@docusaurus/utils");
|
|
18
|
+
const utils_2 = require("../utils");
|
|
20
19
|
// We only support extracting source code translations from these kind of files
|
|
21
20
|
const TranslatableSourceCodeExtension = new Set([
|
|
22
21
|
'.js',
|
|
@@ -32,7 +31,7 @@ function isTranslatableSourceCodePath(filePath) {
|
|
|
32
31
|
return TranslatableSourceCodeExtension.has(path_1.default.extname(filePath));
|
|
33
32
|
}
|
|
34
33
|
function getSiteSourceCodeFilePaths(siteDir) {
|
|
35
|
-
return [path_1.default.join(siteDir,
|
|
34
|
+
return [path_1.default.join(siteDir, utils_1.SRC_DIR_NAME)];
|
|
36
35
|
}
|
|
37
36
|
function getPluginSourceCodeFilePaths(plugin) {
|
|
38
37
|
var _a, _b, _c;
|
|
@@ -48,7 +47,7 @@ function getPluginSourceCodeFilePaths(plugin) {
|
|
|
48
47
|
return codePaths;
|
|
49
48
|
}
|
|
50
49
|
async function globSourceCodeFilePaths(dirPaths) {
|
|
51
|
-
const filePaths = await
|
|
50
|
+
const filePaths = await (0, utils_2.safeGlobby)(dirPaths);
|
|
52
51
|
return filePaths.filter(isTranslatableSourceCodePath);
|
|
53
52
|
}
|
|
54
53
|
exports.globSourceCodeFilePaths = globSourceCodeFilePaths;
|
|
@@ -57,19 +56,21 @@ async function getSourceCodeFilePaths(siteDir, plugins) {
|
|
|
57
56
|
// The getPathsToWatch() generally returns the js/jsx/ts/tsx/md/mdx file paths
|
|
58
57
|
// We can use this method as well to know which folders we should try to extract translations from
|
|
59
58
|
// Hacky/implicit, but do we want to introduce a new lifecycle method for that???
|
|
60
|
-
const pluginsPaths =
|
|
59
|
+
const pluginsPaths = plugins.flatMap(getPluginSourceCodeFilePaths);
|
|
61
60
|
const allPaths = [...sitePaths, ...pluginsPaths];
|
|
62
61
|
return globSourceCodeFilePaths(allPaths);
|
|
63
62
|
}
|
|
64
|
-
async function extractSiteSourceCodeTranslations(siteDir, plugins, babelOptions) {
|
|
63
|
+
async function extractSiteSourceCodeTranslations(siteDir, plugins, babelOptions, extraSourceCodeFilePaths = []) {
|
|
65
64
|
// Should we warn here if the same translation "key" is found in multiple source code files?
|
|
66
65
|
function toTranslationFileContent(sourceCodeFileTranslations) {
|
|
67
|
-
return sourceCodeFileTranslations.reduce((acc, item) => {
|
|
68
|
-
return { ...acc, ...item.translations };
|
|
69
|
-
}, {});
|
|
66
|
+
return sourceCodeFileTranslations.reduce((acc, item) => ({ ...acc, ...item.translations }), {});
|
|
70
67
|
}
|
|
71
68
|
const sourceCodeFilePaths = await getSourceCodeFilePaths(siteDir, plugins);
|
|
72
|
-
const
|
|
69
|
+
const allSourceCodeFilePaths = [
|
|
70
|
+
...sourceCodeFilePaths,
|
|
71
|
+
...extraSourceCodeFilePaths,
|
|
72
|
+
];
|
|
73
|
+
const sourceCodeFilesTranslations = await extractAllSourceCodeFileTranslations(allSourceCodeFilePaths, babelOptions);
|
|
73
74
|
logSourceCodeFileTranslationsWarnings(sourceCodeFilesTranslations);
|
|
74
75
|
return toTranslationFileContent(sourceCodeFilesTranslations);
|
|
75
76
|
}
|
|
@@ -82,23 +83,26 @@ function logSourceCodeFileTranslationsWarnings(sourceCodeFilesTranslations) {
|
|
|
82
83
|
});
|
|
83
84
|
}
|
|
84
85
|
async function extractAllSourceCodeFileTranslations(sourceCodeFilePaths, babelOptions) {
|
|
85
|
-
return
|
|
86
|
+
return Promise.all(sourceCodeFilePaths.flatMap((sourceFilePath) => extractSourceCodeFileTranslations(sourceFilePath, babelOptions)));
|
|
86
87
|
}
|
|
87
88
|
exports.extractAllSourceCodeFileTranslations = extractAllSourceCodeFileTranslations;
|
|
88
89
|
async function extractSourceCodeFileTranslations(sourceCodeFilePath, babelOptions) {
|
|
89
90
|
try {
|
|
90
91
|
const code = await fs_extra_1.default.readFile(sourceCodeFilePath, 'utf8');
|
|
91
|
-
const ast = core_1.parse(code, {
|
|
92
|
+
const ast = (0, core_1.parse)(code, {
|
|
92
93
|
...babelOptions,
|
|
93
94
|
ast: true,
|
|
94
95
|
// filename is important, because babel does not process the same files according to their js/ts extensions
|
|
95
96
|
// see see https://twitter.com/NicoloRibaudo/status/1321130735605002243
|
|
96
97
|
filename: sourceCodeFilePath,
|
|
97
98
|
});
|
|
98
|
-
|
|
99
|
+
const translations = await extractSourceCodeAstTranslations(ast, sourceCodeFilePath);
|
|
100
|
+
return translations;
|
|
99
101
|
}
|
|
100
102
|
catch (e) {
|
|
101
|
-
e
|
|
103
|
+
if (e instanceof Error) {
|
|
104
|
+
e.message = `Error while attempting to extract Docusaurus translations from source code file at path=${sourceCodeFilePath}\n${e.message}`;
|
|
105
|
+
}
|
|
102
106
|
throw e;
|
|
103
107
|
}
|
|
104
108
|
}
|
|
@@ -112,20 +116,14 @@ https://github.com/formatjs/formatjs/blob/main/packages/babel-plugin-formatjs/in
|
|
|
112
116
|
https://github.com/pugjs/babel-walk
|
|
113
117
|
*/
|
|
114
118
|
function extractSourceCodeAstTranslations(ast, sourceCodeFilePath) {
|
|
115
|
-
function
|
|
116
|
-
return 'Translate content could not be extracted.\nIt has to be a static string and use optional but static props, like <Translate id="my-id" description="my-description">text</Translate>.';
|
|
117
|
-
}
|
|
118
|
-
function sourceFileWarningPart(node) {
|
|
119
|
+
function sourceWarningPart(node) {
|
|
119
120
|
var _a;
|
|
120
|
-
return `File
|
|
121
|
-
}
|
|
122
|
-
function generateCode(node) {
|
|
123
|
-
return generator_1.default(node).code;
|
|
121
|
+
return `File: ${sourceCodeFilePath} at ${(_a = node.loc) === null || _a === void 0 ? void 0 : _a.start.line} line\nFull code: ${(0, generator_1.default)(node).code}`;
|
|
124
122
|
}
|
|
125
123
|
const translations = {};
|
|
126
124
|
const warnings = [];
|
|
127
125
|
// TODO we should check the presence of the correct @docusaurus imports here!
|
|
128
|
-
traverse_1.default(ast, {
|
|
126
|
+
(0, traverse_1.default)(ast, {
|
|
129
127
|
JSXElement(path) {
|
|
130
128
|
if (!path
|
|
131
129
|
.get('openingElement')
|
|
@@ -150,41 +148,52 @@ function extractSourceCodeAstTranslations(ast, sourceCodeFilePath) {
|
|
|
150
148
|
return attributeValueEvaluated.value;
|
|
151
149
|
}
|
|
152
150
|
else {
|
|
153
|
-
warnings.push(`<Translate> prop=${propName} should be a statically evaluable object.\nExample: <Translate id="optional.id" description="optional description">Message</Translate>\nDynamically constructed values are not allowed, because they prevent translations to be extracted.\n${
|
|
151
|
+
warnings.push(`<Translate> prop=${propName} should be a statically evaluable object.\nExample: <Translate id="optional.id" description="optional description">Message</Translate>\nDynamically constructed values are not allowed, because they prevent translations to be extracted.\n${sourceWarningPart(path.node)}`);
|
|
154
152
|
}
|
|
155
153
|
}
|
|
156
154
|
return undefined;
|
|
157
155
|
}
|
|
158
|
-
|
|
159
|
-
const
|
|
160
|
-
|
|
156
|
+
const id = evaluateJSXProp('id');
|
|
157
|
+
const description = evaluateJSXProp('description');
|
|
158
|
+
let message;
|
|
159
|
+
const childrenPath = path.get('children');
|
|
160
|
+
// Handle empty content
|
|
161
|
+
if (!childrenPath.length) {
|
|
162
|
+
if (!id) {
|
|
163
|
+
warnings.push(`
|
|
164
|
+
<Translate> without children must have id prop.\nExample: <Translate id="my-id" />\n${sourceWarningPart(path.node)}
|
|
165
|
+
`);
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
translations[id] = {
|
|
169
|
+
message: message !== null && message !== void 0 ? message : id,
|
|
170
|
+
...(description && { description }),
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
// Handle single non-empty content
|
|
176
|
+
const singleChildren = childrenPath
|
|
161
177
|
// Remove empty/useless text nodes that might be around our translation!
|
|
162
178
|
// Makes the translation system more reliable to JSX formatting issues
|
|
163
|
-
.filter((
|
|
164
|
-
|
|
179
|
+
.filter((children) => !(children.isJSXText() &&
|
|
180
|
+
children.node.value.replace('\n', '').trim() === ''))
|
|
165
181
|
.pop();
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
const id = evaluateJSXProp('id');
|
|
169
|
-
const description = evaluateJSXProp('description');
|
|
170
|
-
translations[id !== null && id !== void 0 ? id : message] = {
|
|
171
|
-
message,
|
|
172
|
-
...(description && { description }),
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
else if (singleChildren &&
|
|
182
|
+
const isJSXText = singleChildren && singleChildren.isJSXText();
|
|
183
|
+
const isJSXExpressionContainer = singleChildren &&
|
|
176
184
|
singleChildren.isJSXExpressionContainer() &&
|
|
177
|
-
singleChildren.get('expression').evaluate().confident
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
185
|
+
singleChildren.get('expression').evaluate().confident;
|
|
186
|
+
if (isJSXText || isJSXExpressionContainer) {
|
|
187
|
+
message = isJSXText
|
|
188
|
+
? singleChildren.node.value.trim().replace(/\s+/g, ' ')
|
|
189
|
+
: singleChildren.get('expression').evaluate().value;
|
|
181
190
|
translations[id !== null && id !== void 0 ? id : message] = {
|
|
182
191
|
message,
|
|
183
192
|
...(description && { description }),
|
|
184
193
|
};
|
|
185
194
|
}
|
|
186
195
|
else {
|
|
187
|
-
warnings.push(
|
|
196
|
+
warnings.push(`Translate content could not be extracted. It has to be a static string and use optional but static props, like <Translate id="my-id" description="my-description">text</Translate>.\n${sourceWarningPart(path.node)}`);
|
|
188
197
|
}
|
|
189
198
|
},
|
|
190
199
|
CallExpression(path) {
|
|
@@ -202,16 +211,16 @@ function extractSourceCodeAstTranslations(ast, sourceCodeFilePath) {
|
|
|
202
211
|
typeof firstArgEvaluated.value === 'object') {
|
|
203
212
|
const { message, id, description } = firstArgEvaluated.value;
|
|
204
213
|
translations[id !== null && id !== void 0 ? id : message] = {
|
|
205
|
-
message,
|
|
214
|
+
message: message !== null && message !== void 0 ? message : id,
|
|
206
215
|
...(description && { description }),
|
|
207
216
|
};
|
|
208
217
|
}
|
|
209
218
|
else {
|
|
210
|
-
warnings.push(`translate() first arg should be a statically evaluable object.\nExample: translate({message: "text",id: "optional.id",description: "optional description"}\nDynamically constructed values are not allowed, because they prevent translations to be extracted.\n${
|
|
219
|
+
warnings.push(`translate() first arg should be a statically evaluable object.\nExample: translate({message: "text",id: "optional.id",description: "optional description"}\nDynamically constructed values are not allowed, because they prevent translations to be extracted.\n${sourceWarningPart(path.node)}`);
|
|
211
220
|
}
|
|
212
221
|
}
|
|
213
222
|
else {
|
|
214
|
-
warnings.push(`translate() function only takes 1 or 2 args\n${
|
|
223
|
+
warnings.push(`translate() function only takes 1 or 2 args\n${sourceWarningPart(path.node)}`);
|
|
215
224
|
}
|
|
216
225
|
},
|
|
217
226
|
});
|
package/lib/server/utils.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
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
|
+
*/
|
|
1
7
|
import { RouteConfig } from '@docusaurus/types';
|
|
2
|
-
import
|
|
8
|
+
import { Globby } from '@docusaurus/utils';
|
|
3
9
|
export declare function getAllFinalRoutes(routeConfig: RouteConfig[]): RouteConfig[];
|
|
4
|
-
export declare function safeGlobby(patterns: string[], options?:
|
|
10
|
+
export declare function safeGlobby(patterns: string[], options?: Globby.GlobbyOptions): Promise<string[]>;
|
package/lib/server/utils.js
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.safeGlobby = exports.getAllFinalRoutes = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
2
|
/**
|
|
6
3
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
7
4
|
*
|
|
8
5
|
* This source code is licensed under the MIT license found in the
|
|
9
6
|
* LICENSE file in the root directory of this source tree.
|
|
10
7
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.safeGlobby = exports.getAllFinalRoutes = void 0;
|
|
10
|
+
const tslib_1 = require("tslib");
|
|
11
|
+
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
14
12
|
const utils_1 = require("@docusaurus/utils");
|
|
15
13
|
// Recursively get the final routes (routes with no subroutes)
|
|
16
14
|
function getAllFinalRoutes(routeConfig) {
|
|
17
15
|
function getFinalRoutes(route) {
|
|
18
|
-
return route.routes ?
|
|
16
|
+
return route.routes ? route.routes.flatMap(getFinalRoutes) : [route];
|
|
19
17
|
}
|
|
20
|
-
return
|
|
18
|
+
return routeConfig.flatMap(getFinalRoutes);
|
|
21
19
|
}
|
|
22
20
|
exports.getAllFinalRoutes = getAllFinalRoutes;
|
|
23
21
|
// Globby that fix Windows path patterns
|
|
@@ -25,7 +23,7 @@ exports.getAllFinalRoutes = getAllFinalRoutes;
|
|
|
25
23
|
async function safeGlobby(patterns, options) {
|
|
26
24
|
// Required for Windows support, as paths using \ should not be used by globby
|
|
27
25
|
// (also using the windows hard drive prefix like c: is not a good idea)
|
|
28
|
-
const globPaths = patterns.map((dirPath) => utils_1.posixPath(path_1.default.relative(process.cwd(), dirPath)));
|
|
29
|
-
return
|
|
26
|
+
const globPaths = patterns.map((dirPath) => (0, utils_1.posixPath)(path_1.default.relative(process.cwd(), dirPath)));
|
|
27
|
+
return (0, utils_1.Globby)(globPaths, options);
|
|
30
28
|
}
|
|
31
29
|
exports.safeGlobby = safeGlobby;
|
|
File without changes
|
|
@@ -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,12 @@
|
|
|
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
|
|
16
|
-
const
|
|
15
|
+
const themes_1 = require("../server/themes");
|
|
16
|
+
const utils_2 = require("@docusaurus/utils");
|
|
17
17
|
const CSS_REGEX = /\.css$/;
|
|
18
18
|
const CSS_MODULE_REGEX = /\.module\.css$/;
|
|
19
19
|
exports.clientDir = path_1.default.join(__dirname, '..', 'client');
|
|
@@ -48,32 +48,39 @@ function getDocusaurusAliases() {
|
|
|
48
48
|
exports.getDocusaurusAliases = getDocusaurusAliases;
|
|
49
49
|
function createBaseConfig(props, isServer, minify = true) {
|
|
50
50
|
var _a;
|
|
51
|
-
const { outDir, siteDir, siteConfig, baseUrl, generatedFilesDir, routesPaths, siteMetadata, } = props;
|
|
51
|
+
const { outDir, siteDir, siteConfig, siteConfigPath, baseUrl, generatedFilesDir, routesPaths, siteMetadata, plugins, } = props;
|
|
52
52
|
const totalPages = routesPaths.length;
|
|
53
53
|
const isProd = process.env.NODE_ENV === 'production';
|
|
54
54
|
const minimizeEnabled = minify && isProd && !isServer;
|
|
55
55
|
const useSimpleCssMinifier = process.env.USE_SIMPLE_CSS_MINIFIER === 'true';
|
|
56
|
-
const fileLoaderUtils =
|
|
56
|
+
const fileLoaderUtils = (0, utils_2.getFileLoaderUtils)();
|
|
57
57
|
const name = isServer ? 'server' : 'client';
|
|
58
58
|
const mode = isProd ? 'production' : 'development';
|
|
59
|
+
const themeAliases = (0, themes_1.loadPluginsThemeAliases)({ siteDir, plugins });
|
|
59
60
|
return {
|
|
60
61
|
mode,
|
|
61
62
|
name,
|
|
62
63
|
cache: {
|
|
63
|
-
|
|
64
|
-
// maybe expose an official api, once this is solved? https://github.com/webpack/webpack/issues/13034
|
|
65
|
-
type: process.env.DOCUSAURUS_WEBPACK_CACHE_TYPE ||
|
|
66
|
-
'filesystem',
|
|
64
|
+
type: 'filesystem',
|
|
67
65
|
// Can we share the same cache across locales?
|
|
68
66
|
// Exploring that question at https://github.com/webpack/webpack/issues/13034
|
|
69
67
|
// name: `${name}-${mode}`,
|
|
70
68
|
name: `${name}-${mode}-${props.i18n.currentLocale}`,
|
|
71
|
-
version
|
|
69
|
+
// When version string changes, cache is evicted
|
|
70
|
+
version: [
|
|
71
|
+
siteMetadata.docusaurusVersion,
|
|
72
|
+
// Webpack does not evict the cache correctly on alias/swizzle change, so we force eviction.
|
|
73
|
+
// See https://github.com/webpack/webpack/issues/13627
|
|
74
|
+
(0, utils_2.md5Hash)(JSON.stringify(themeAliases)),
|
|
75
|
+
].join('-'),
|
|
76
|
+
// When one of those modules/dependencies change (including transitive deps), cache is invalidated
|
|
72
77
|
buildDependencies: {
|
|
73
|
-
// When one of dependencies change, cache is invalidated
|
|
74
78
|
config: [
|
|
75
79
|
__filename,
|
|
76
80
|
path_1.default.join(__dirname, isServer ? 'server.js' : 'client.js'),
|
|
81
|
+
// Docusaurus config changes can affect MDX/JSX compilation, so we'd rather evict the cache.
|
|
82
|
+
// See https://github.com/questdb/questdb.io/issues/493
|
|
83
|
+
siteConfigPath,
|
|
77
84
|
],
|
|
78
85
|
},
|
|
79
86
|
},
|
|
@@ -85,6 +92,7 @@ function createBaseConfig(props, isServer, minify = true) {
|
|
|
85
92
|
? 'assets/js/[name].[contenthash:8].js'
|
|
86
93
|
: '[name].js',
|
|
87
94
|
publicPath: baseUrl,
|
|
95
|
+
hashFunction: 'xxhash64',
|
|
88
96
|
},
|
|
89
97
|
// Don't throw warning when asset created is over 250kb
|
|
90
98
|
performance: {
|
|
@@ -99,18 +107,18 @@ function createBaseConfig(props, isServer, minify = true) {
|
|
|
99
107
|
// Allow resolution of url("/fonts/xyz.ttf") by webpack
|
|
100
108
|
// See https://webpack.js.org/configuration/resolve/#resolveroots
|
|
101
109
|
// See https://github.com/webpack-contrib/css-loader/issues/1256
|
|
102
|
-
path_1.default.
|
|
110
|
+
...siteConfig.staticDirectories.map((dir) => path_1.default.resolve(siteDir, dir)),
|
|
103
111
|
siteDir,
|
|
104
112
|
process.cwd(),
|
|
105
113
|
],
|
|
106
114
|
alias: {
|
|
107
|
-
...sharedModuleAliases_1.default,
|
|
108
115
|
'@site': siteDir,
|
|
109
116
|
'@generated': generatedFilesDir,
|
|
110
117
|
// Note: a @docusaurus alias would also catch @docusaurus/theme-common,
|
|
111
118
|
// so we use fine-grained aliases instead
|
|
112
119
|
// '@docusaurus': path.resolve(__dirname, '../client/exports'),
|
|
113
120
|
...getDocusaurusAliases(),
|
|
121
|
+
...themeAliases,
|
|
114
122
|
},
|
|
115
123
|
// This allows you to set a fallback for where Webpack should look for modules.
|
|
116
124
|
// We want `@docusaurus/core` own dependencies/`node_modules` to "win" if there is conflict
|
|
@@ -130,7 +138,7 @@ function createBaseConfig(props, isServer, minify = true) {
|
|
|
130
138
|
// Only minimize client bundle in production because server bundle is only used for static site generation
|
|
131
139
|
minimize: minimizeEnabled,
|
|
132
140
|
minimizer: minimizeEnabled
|
|
133
|
-
? utils_1.getMinimizer(useSimpleCssMinifier)
|
|
141
|
+
? (0, utils_1.getMinimizer)(useSimpleCssMinifier)
|
|
134
142
|
: undefined,
|
|
135
143
|
splitChunks: isServer
|
|
136
144
|
? false
|
|
@@ -170,16 +178,16 @@ function createBaseConfig(props, isServer, minify = true) {
|
|
|
170
178
|
test: /\.(j|t)sx?$/,
|
|
171
179
|
exclude: excludeJS,
|
|
172
180
|
use: [
|
|
173
|
-
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)({
|
|
174
182
|
isServer,
|
|
175
|
-
babelOptions: utils_1.getCustomBabelConfigFilePath(siteDir),
|
|
183
|
+
babelOptions: (0, utils_1.getCustomBabelConfigFilePath)(siteDir),
|
|
176
184
|
}),
|
|
177
185
|
],
|
|
178
186
|
},
|
|
179
187
|
{
|
|
180
188
|
test: CSS_REGEX,
|
|
181
189
|
exclude: CSS_MODULE_REGEX,
|
|
182
|
-
use: utils_1.getStyleLoaders(isServer, {
|
|
190
|
+
use: (0, utils_1.getStyleLoaders)(isServer, {
|
|
183
191
|
importLoaders: 1,
|
|
184
192
|
sourceMap: !isProd,
|
|
185
193
|
}),
|
|
@@ -188,11 +196,11 @@ function createBaseConfig(props, isServer, minify = true) {
|
|
|
188
196
|
// using the extension .module.css
|
|
189
197
|
{
|
|
190
198
|
test: CSS_MODULE_REGEX,
|
|
191
|
-
use: utils_1.getStyleLoaders(isServer, {
|
|
199
|
+
use: (0, utils_1.getStyleLoaders)(isServer, {
|
|
192
200
|
modules: {
|
|
193
201
|
localIdentName: isProd
|
|
194
202
|
? `[local]_[contenthash:base64:4]`
|
|
195
|
-
: `[local]_[path]`,
|
|
203
|
+
: `[local]_[path][name]`,
|
|
196
204
|
exportOnlyLocals: isServer,
|
|
197
205
|
},
|
|
198
206
|
importLoaders: 1,
|
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;
|
|
@@ -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
|
})
|