@docusaurus/core 2.0.0-beta.14 → 2.0.0-beta.15

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.
Files changed (81) hide show
  1. package/bin/docusaurus.js +1 -1
  2. package/lib/babel/preset.d.ts +1 -1
  3. package/lib/client/LinksCollector.d.ts +1 -1
  4. package/lib/client/PendingNavigation.d.ts +2 -2
  5. package/lib/client/exports/BrowserOnly.d.ts +1 -1
  6. package/lib/client/exports/BrowserOnly.js +7 -2
  7. package/lib/client/exports/ErrorBoundary.d.ts +1 -1
  8. package/lib/client/exports/ErrorBoundary.js +3 -1
  9. package/lib/client/exports/Interpolate.d.ts +1 -1
  10. package/lib/client/exports/Translate.d.ts +2 -2
  11. package/lib/client/exports/browserContext.d.ts +1 -1
  12. package/lib/client/exports/docusaurusContext.d.ts +2 -2
  13. package/lib/client/exports/useBaseUrl.js +2 -2
  14. package/lib/client/exports/useDocusaurusContext.d.ts +1 -1
  15. package/lib/client/nprogress.css +2 -2
  16. package/lib/client/preload.d.ts +1 -1
  17. package/lib/client/serverEntry.d.ts +10 -0
  18. package/lib/client/serverEntry.js +81 -115
  19. package/lib/commands/build.d.ts +1 -1
  20. package/lib/commands/build.js +11 -7
  21. package/lib/commands/commandUtils.d.ts +1 -1
  22. package/lib/commands/deploy.d.ts +1 -1
  23. package/lib/commands/deploy.js +1 -1
  24. package/lib/commands/external.d.ts +1 -1
  25. package/lib/commands/external.js +1 -1
  26. package/lib/commands/serve.d.ts +1 -1
  27. package/lib/commands/start.d.ts +1 -1
  28. package/lib/commands/start.js +4 -5
  29. package/lib/commands/swizzle.d.ts +1 -1
  30. package/lib/commands/swizzle.js +2 -2
  31. package/lib/commands/writeHeadingIds.d.ts +1 -1
  32. package/lib/commands/writeHeadingIds.js +1 -1
  33. package/lib/commands/writeTranslations.d.ts +2 -2
  34. package/lib/commands/writeTranslations.js +1 -1
  35. package/lib/server/brokenLinks.d.ts +1 -1
  36. package/lib/server/brokenLinks.js +1 -2
  37. package/lib/server/client-modules/index.d.ts +1 -1
  38. package/lib/server/config.d.ts +2 -2
  39. package/lib/server/config.js +5 -2
  40. package/lib/server/configValidation.d.ts +1 -1
  41. package/lib/server/configValidation.js +2 -3
  42. package/lib/server/duplicateRoutes.d.ts +1 -1
  43. package/lib/server/html-tags/index.d.ts +1 -1
  44. package/lib/server/i18n.d.ts +1 -1
  45. package/lib/server/i18n.js +3 -8
  46. package/lib/server/index.d.ts +1 -1
  47. package/lib/server/index.js +18 -10
  48. package/lib/server/loadSetup.d.ts +1 -1
  49. package/lib/server/moduleShorthand.js +11 -7
  50. package/lib/server/plugins/applyRouteTrailingSlash.d.ts +2 -2
  51. package/lib/server/plugins/index.d.ts +1 -1
  52. package/lib/server/plugins/index.js +1 -1
  53. package/lib/server/plugins/init.d.ts +2 -2
  54. package/lib/server/plugins/init.js +10 -9
  55. package/lib/server/plugins/pluginIds.d.ts +1 -1
  56. package/lib/server/presets/index.d.ts +1 -1
  57. package/lib/server/presets/index.js +1 -1
  58. package/lib/server/routes.d.ts +1 -1
  59. package/lib/server/routes.js +1 -2
  60. package/lib/server/themes/alias.d.ts +1 -1
  61. package/lib/server/themes/index.d.ts +1 -1
  62. package/lib/server/translations/translations.d.ts +1 -1
  63. package/lib/server/translations/translations.js +1 -1
  64. package/lib/server/translations/translationsExtractor.d.ts +2 -2
  65. package/lib/server/translations/translationsExtractor.js +121 -88
  66. package/lib/server/utils.d.ts +1 -1
  67. package/lib/server/versions/__tests/index.test.js +6 -5
  68. package/lib/server/versions/index.d.ts +1 -1
  69. package/lib/webpack/base.d.ts +2 -2
  70. package/lib/webpack/client.d.ts +2 -2
  71. package/lib/webpack/plugins/ChunkAssetPlugin.d.ts +1 -1
  72. package/lib/webpack/plugins/CleanWebpackPlugin.d.ts +1 -1
  73. package/lib/webpack/plugins/LogPlugin.d.ts +1 -1
  74. package/lib/webpack/plugins/WaitPlugin.d.ts +1 -1
  75. package/lib/webpack/server.d.ts +2 -2
  76. package/lib/{client → webpack}/templates/index.html.template.ejs +0 -0
  77. package/lib/webpack/templates/ssr.html.template.d.ts +8 -0
  78. package/lib/{client → webpack}/templates/ssr.html.template.js +3 -2
  79. package/lib/webpack/utils.d.ts +4 -4
  80. package/lib/webpack/utils.js +8 -5
  81. package/package.json +22 -22
@@ -23,7 +23,7 @@ const TranslatableSourceCodeExtension = new Set([
23
23
  '.ts',
24
24
  '.tsx',
25
25
  // TODO support md/mdx too? (may be overkill)
26
- // need to compile the MDX to JSX first and remove frontmatter
26
+ // need to compile the MDX to JSX first and remove front matter
27
27
  // '.md',
28
28
  // '.mdx',
29
29
  ]);
@@ -118,109 +118,142 @@ https://github.com/pugjs/babel-walk
118
118
  function extractSourceCodeAstTranslations(ast, sourceCodeFilePath) {
119
119
  function sourceWarningPart(node) {
120
120
  var _a;
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}`;
121
+ return `File: ${sourceCodeFilePath} at line ${(_a = node.loc) === null || _a === void 0 ? void 0 : _a.start.line}
122
+ Full code: ${(0, generator_1.default)(node).code}`;
122
123
  }
123
124
  const translations = {};
124
125
  const warnings = [];
125
- // TODO we should check the presence of the correct @docusaurus imports here!
126
+ let translateComponentName;
127
+ let translateFunctionName;
128
+ // First pass: find import declarations of Translate / translate.
129
+ // If not found, don't process the rest to avoid false positives
126
130
  (0, traverse_1.default)(ast, {
127
- JSXElement(path) {
128
- if (!path
129
- .get('openingElement')
130
- .get('name')
131
- .isJSXIdentifier({ name: 'Translate' })) {
131
+ ImportDeclaration(path) {
132
+ if (path.node.importKind === 'type' ||
133
+ path.get('source').node.value !== '@docusaurus/Translate') {
132
134
  return;
133
135
  }
134
- function evaluateJSXProp(propName) {
135
- const attributePath = path
136
- .get('openingElement.attributes')
137
- .find((attr) => attr.isJSXAttribute() &&
138
- attr
139
- .get('name')
140
- .isJSXIdentifier({ name: propName }));
141
- if (attributePath) {
142
- const attributeValue = attributePath.get('value');
143
- const attributeValueEvaluated = attributeValue.isJSXExpressionContainer()
144
- ? attributeValue.get('expression').evaluate()
145
- : attributeValue.evaluate();
146
- if (attributeValueEvaluated.confident &&
147
- typeof attributeValueEvaluated.value === 'string') {
148
- return attributeValueEvaluated.value;
136
+ const importSpecifiers = path.get('specifiers');
137
+ const defaultImport = importSpecifiers.find((specifier) => specifier.node.type === 'ImportDefaultSpecifier');
138
+ const callbackImport = importSpecifiers.find((specifier) => specifier.node.type === 'ImportSpecifier' &&
139
+ (specifier.get('imported')
140
+ .node.name === 'translate' ||
141
+ specifier.get('imported')
142
+ .node.value === 'translate'));
143
+ translateComponentName = defaultImport === null || defaultImport === void 0 ? void 0 : defaultImport.get('local').node.name;
144
+ translateFunctionName = callbackImport === null || callbackImport === void 0 ? void 0 : callbackImport.get('local').node.name;
145
+ },
146
+ });
147
+ (0, traverse_1.default)(ast, {
148
+ ...(translateComponentName && {
149
+ JSXElement(path) {
150
+ if (!path
151
+ .get('openingElement')
152
+ .get('name')
153
+ .isJSXIdentifier({ name: translateComponentName })) {
154
+ return;
155
+ }
156
+ function evaluateJSXProp(propName) {
157
+ const attributePath = path
158
+ .get('openingElement.attributes')
159
+ .find((attr) => attr.isJSXAttribute() &&
160
+ attr
161
+ .get('name')
162
+ .isJSXIdentifier({ name: propName }));
163
+ if (attributePath) {
164
+ const attributeValue = attributePath.get('value');
165
+ const attributeValueEvaluated = attributeValue.isJSXExpressionContainer()
166
+ ? attributeValue.get('expression').evaluate()
167
+ : attributeValue.evaluate();
168
+ if (attributeValueEvaluated.confident &&
169
+ typeof attributeValueEvaluated.value === 'string') {
170
+ return attributeValueEvaluated.value;
171
+ }
172
+ else {
173
+ warnings.push(`<Translate> prop=${propName} should be a statically evaluable object.
174
+ Example: <Translate id="optional id" description="optional description">Message</Translate>
175
+ Dynamically constructed values are not allowed, because they prevent translations to be extracted.
176
+ ${sourceWarningPart(path.node)}`);
177
+ }
178
+ }
179
+ return undefined;
180
+ }
181
+ const id = evaluateJSXProp('id');
182
+ const description = evaluateJSXProp('description');
183
+ let message;
184
+ const childrenPath = path.get('children');
185
+ // Handle empty content
186
+ if (!childrenPath.length) {
187
+ if (!id) {
188
+ warnings.push(`<Translate> without children must have id prop.
189
+ Example: <Translate id="my-id" />
190
+ ${sourceWarningPart(path.node)}`);
149
191
  }
150
192
  else {
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)}`);
193
+ translations[id] = {
194
+ message: message !== null && message !== void 0 ? message : id,
195
+ ...(description && { description }),
196
+ };
152
197
  }
198
+ return;
153
199
  }
154
- return undefined;
155
- }
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
177
- // Remove empty/useless text nodes that might be around our translation!
178
- // Makes the translation system more reliable to JSX formatting issues
179
- .filter((children) => !(children.isJSXText() &&
180
- children.node.value.replace('\n', '').trim() === ''))
181
- .pop();
182
- const isJSXText = singleChildren && singleChildren.isJSXText();
183
- const isJSXExpressionContainer = singleChildren &&
184
- singleChildren.isJSXExpressionContainer() &&
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;
190
- translations[id !== null && id !== void 0 ? id : message] = {
191
- message,
192
- ...(description && { description }),
193
- };
194
- }
195
- else {
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)}`);
197
- }
198
- },
199
- CallExpression(path) {
200
- if (!path.get('callee').isIdentifier({ name: 'translate' })) {
201
- return;
202
- }
203
- const args = path.get('arguments');
204
- if (args.length === 1 || args.length === 2) {
205
- const firstArgPath = args[0];
206
- // evaluation allows translate("x" + "y"); to be considered as translate("xy");
207
- const firstArgEvaluated = firstArgPath.evaluate();
208
- if (firstArgEvaluated.confident &&
209
- typeof firstArgEvaluated.value === 'object') {
210
- const { message, id, description } = firstArgEvaluated.value;
200
+ // Handle single non-empty content
201
+ const singleChildren = childrenPath
202
+ // Remove empty/useless text nodes that might be around our translation!
203
+ // Makes the translation system more reliable to JSX formatting issues
204
+ .filter((children) => !(children.isJSXText() &&
205
+ children.node.value.replace('\n', '').trim() === ''))
206
+ .pop();
207
+ const isJSXText = singleChildren && singleChildren.isJSXText();
208
+ const isJSXExpressionContainer = singleChildren &&
209
+ singleChildren.isJSXExpressionContainer() &&
210
+ singleChildren.get('expression').evaluate().confident;
211
+ if (isJSXText || isJSXExpressionContainer) {
212
+ message = isJSXText
213
+ ? singleChildren.node.value.trim().replace(/\s+/g, ' ')
214
+ : singleChildren.get('expression').evaluate().value;
211
215
  translations[id !== null && id !== void 0 ? id : message] = {
212
- message: message !== null && message !== void 0 ? message : id,
216
+ message,
213
217
  ...(description && { description }),
214
218
  };
215
219
  }
216
220
  else {
217
- 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)}`);
221
+ 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>.
222
+ ${sourceWarningPart(path.node)}`);
218
223
  }
219
- }
220
- else {
221
- warnings.push(`translate() function only takes 1 or 2 args\n${sourceWarningPart(path.node)}`);
222
- }
223
- },
224
+ },
225
+ }),
226
+ ...(translateFunctionName && {
227
+ CallExpression(path) {
228
+ if (!path.get('callee').isIdentifier({ name: translateFunctionName })) {
229
+ return;
230
+ }
231
+ const args = path.get('arguments');
232
+ if (args.length === 1 || args.length === 2) {
233
+ const firstArgPath = args[0];
234
+ // evaluation allows translate("x" + "y"); to be considered as translate("xy");
235
+ const firstArgEvaluated = firstArgPath.evaluate();
236
+ if (firstArgEvaluated.confident &&
237
+ typeof firstArgEvaluated.value === 'object') {
238
+ const { message, id, description } = firstArgEvaluated.value;
239
+ translations[id !== null && id !== void 0 ? id : message] = {
240
+ message: message !== null && message !== void 0 ? message : id,
241
+ ...(description && { description }),
242
+ };
243
+ }
244
+ else {
245
+ warnings.push(`translate() first arg should be a statically evaluable object.
246
+ Example: translate({message: "text",id: "optional.id",description: "optional description"}
247
+ Dynamically constructed values are not allowed, because they prevent translations to be extracted.
248
+ ${sourceWarningPart(path.node)}`);
249
+ }
250
+ }
251
+ else {
252
+ warnings.push(`translate() function only takes 1 or 2 args
253
+ ${sourceWarningPart(path.node)}`);
254
+ }
255
+ },
256
+ }),
224
257
  });
225
258
  return { sourceCodeFilePath, translations, warnings };
226
259
  }
@@ -4,7 +4,7 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- import { RouteConfig } from '@docusaurus/types';
7
+ import type { RouteConfig } from '@docusaurus/types';
8
8
  import { Globby } from '@docusaurus/utils';
9
9
  export declare function getAllFinalRoutes(routeConfig: RouteConfig[]): RouteConfig[];
10
10
  export declare function safeGlobby(patterns: string[], options?: Globby.GlobbyOptions): Promise<string[]>;
@@ -6,18 +6,19 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
+ const tslib_1 = require("tslib");
9
10
  const __1 = require("..");
10
- const path_1 = require("path");
11
+ const path_1 = (0, tslib_1.__importDefault)(require("path"));
11
12
  describe('getPluginVersion', () => {
12
13
  it('Can detect external packages plugins versions of correctly.', () => {
13
- expect((0, __1.getPluginVersion)((0, path_1.join)(__dirname, '..', '__fixtures__', 'dummy-plugin.js'),
14
+ expect((0, __1.getPluginVersion)(path_1.default.join(__dirname, '..', '__fixtures__', 'dummy-plugin.js'),
14
15
  // Make the plugin appear external.
15
- (0, path_1.join)(__dirname, '..', '..', '..', '..', '..', '..', 'website'))).toEqual({ type: 'package', version: 'random-version' });
16
+ path_1.default.join(__dirname, '..', '..', '..', '..', '..', '..', 'website'))).toEqual({ type: 'package', version: 'random-version' });
16
17
  });
17
18
  it('Can detect project plugins versions correctly.', () => {
18
- expect((0, __1.getPluginVersion)((0, path_1.join)(__dirname, '..', '__fixtures__', 'dummy-plugin.js'),
19
+ expect((0, __1.getPluginVersion)(path_1.default.join(__dirname, '..', '__fixtures__', 'dummy-plugin.js'),
19
20
  // Make the plugin appear project local.
20
- (0, path_1.join)(__dirname, '..', '__fixtures__'))).toEqual({ type: 'project' });
21
+ path_1.default.join(__dirname, '..', '__fixtures__'))).toEqual({ type: 'project' });
21
22
  });
22
23
  it('Can detect local packages versions correctly.', () => {
23
24
  expect((0, __1.getPluginVersion)('/', '/')).toEqual({ type: 'local' });
@@ -4,7 +4,7 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- import { DocusaurusPluginVersionInformation } from '@docusaurus/types';
7
+ import type { DocusaurusPluginVersionInformation } from '@docusaurus/types';
8
8
  export declare function getPackageJsonVersion(packageJsonPath: string): string | undefined;
9
9
  export declare function getPackageJsonName(packageJsonPath: string): string | undefined;
10
10
  export declare function getPluginVersion(pluginPath: string, siteDir: string): DocusaurusPluginVersionInformation;
@@ -4,8 +4,8 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- import { Configuration } from 'webpack';
8
- import { Props } from '@docusaurus/types';
7
+ import type { Configuration } from 'webpack';
8
+ import type { Props } from '@docusaurus/types';
9
9
  export declare const clientDir: string;
10
10
  export declare function excludeJS(modulePath: string): boolean;
11
11
  export declare function getDocusaurusAliases(): Record<string, string>;
@@ -4,6 +4,6 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- import { Configuration } from 'webpack';
8
- import { Props } from '@docusaurus/types';
7
+ import type { Configuration } from 'webpack';
8
+ import type { Props } from '@docusaurus/types';
9
9
  export default function createClientConfig(props: Props, minify?: boolean): Configuration;
@@ -4,7 +4,7 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- import { Compiler } from 'webpack';
7
+ import { type Compiler } from 'webpack';
8
8
  declare class ChunkAssetPlugin {
9
9
  apply(compiler: Compiler): void;
10
10
  }
@@ -23,7 +23,7 @@
23
23
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
24
  * SOFTWARE.
25
25
  */
26
- import { Compiler, Stats } from 'webpack';
26
+ import type { Compiler, Stats } from 'webpack';
27
27
  export interface Options {
28
28
  /**
29
29
  * Write Logs to Console
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import WebpackBar from 'webpackbar';
8
- import { Compiler } from 'webpack';
8
+ import type { Compiler } from 'webpack';
9
9
  export default class LogPlugin extends WebpackBar {
10
10
  apply(compiler: Compiler): void;
11
11
  }
@@ -4,7 +4,7 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- import { Compiler } from 'webpack';
7
+ import type { Compiler } from 'webpack';
8
8
  interface WaitPluginOptions {
9
9
  filepath: string;
10
10
  }
@@ -4,8 +4,8 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- import { Configuration } from 'webpack';
8
- import { Props } from '@docusaurus/types';
7
+ import type { Configuration } from 'webpack';
8
+ import type { Props } from '@docusaurus/types';
9
9
  export default function createServerConfig({ props, onLinksCollected, }: {
10
10
  props: Props;
11
11
  onLinksCollected?: (staticPagePath: string, links: string[]) => void;
@@ -0,0 +1,8 @@
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 _default: "\n<!DOCTYPE html>\n<html <%~ it.htmlAttributes %>>\n <head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <meta name=\"generator\" content=\"Docusaurus v<%= it.version %>\">\n <% if (it.noIndex) { %>\n <meta name=\"robots\" content=\"noindex, nofollow\" />\n <% } %>\n <%~ it.headTags %>\n <% it.metaAttributes.forEach((metaAttribute) => { %>\n <%~ metaAttribute %>\n <% }); %>\n <% it.stylesheets.forEach((stylesheet) => { %>\n <link rel=\"stylesheet\" href=\"<%= it.baseUrl %><%= stylesheet %>\" />\n <% }); %>\n <% it.scripts.forEach((script) => { %>\n <link rel=\"preload\" href=\"<%= it.baseUrl %><%= script %>\" as=\"script\">\n <% }); %>\n </head>\n <body <%~ it.bodyAttributes %>>\n <%~ it.preBodyTags %>\n <div id=\"__docusaurus\">\n <%~ it.appHtml %>\n </div>\n <% it.scripts.forEach((script) => { %>\n <script src=\"<%= it.baseUrl %><%= script %>\"></script>\n <% }); %>\n <%~ it.postBodyTags %>\n </body>\n</html>\n";
8
+ export default _default;
@@ -1,11 +1,12 @@
1
+ "use strict";
1
2
  /**
2
3
  * Copyright (c) Facebook, Inc. and its affiliates.
3
4
  *
4
5
  * This source code is licensed under the MIT license found in the
5
6
  * LICENSE file in the root directory of this source tree.
6
7
  */
7
-
8
- module.exports = `
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.default = `
9
10
  <!DOCTYPE html>
10
11
  <html <%~ it.htmlAttributes %>>
11
12
  <head>
@@ -5,10 +5,10 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  /// <reference types="node" />
8
- import { Configuration, RuleSetRule, WebpackPluginInstance } from 'webpack';
9
- import { TransformOptions } from '@babel/core';
10
- import { ConfigureWebpackFn, ConfigurePostCssFn } from '@docusaurus/types';
11
- export declare function getStyleLoaders(isServer: boolean, cssOptions?: {
8
+ import { type Configuration, type RuleSetRule, type WebpackPluginInstance } from 'webpack';
9
+ import type { TransformOptions } from '@babel/core';
10
+ import type { ConfigureWebpackFn, ConfigurePostCssFn } from '@docusaurus/types';
11
+ export declare function getStyleLoaders(isServer: boolean, cssOptionsArg?: {
12
12
  [key: string]: unknown;
13
13
  }): RuleSetRule[];
14
14
  export declare function getCustomBabelConfigFilePath(siteDir: string): string | undefined;
@@ -20,7 +20,12 @@ const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
20
20
  const utils_1 = require("@docusaurus/utils");
21
21
  const lodash_1 = require("lodash");
22
22
  // Utility method to get style loaders
23
- function getStyleLoaders(isServer, cssOptions = {}) {
23
+ function getStyleLoaders(isServer, cssOptionsArg = {}) {
24
+ const cssOptions = {
25
+ // TODO turn esModule on later, see https://github.com/facebook/docusaurus/pull/6424
26
+ esModule: false,
27
+ ...cssOptionsArg,
28
+ };
24
29
  if (isServer) {
25
30
  return cssOptions.modules
26
31
  ? [
@@ -159,7 +164,7 @@ function applyConfigureWebpack(configureWebpack, config, isServer, jsLoader, con
159
164
  exports.applyConfigureWebpack = applyConfigureWebpack;
160
165
  function applyConfigurePostCss(configurePostCss, config) {
161
166
  var _a, _b;
162
- // TODO not ideal heuristic but good enough for our usecase?
167
+ // not ideal heuristic but good enough for our use-case?
163
168
  function isPostCssLoader(loader) {
164
169
  var _a, _b;
165
170
  return !!((_b = (_a = loader) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.postcssOptions);
@@ -203,7 +208,7 @@ function compile(config) {
203
208
  }
204
209
  if (errorsWarnings && (stats === null || stats === void 0 ? void 0 : stats.hasWarnings())) {
205
210
  (_a = errorsWarnings.warnings) === null || _a === void 0 ? void 0 : _a.forEach((warning) => {
206
- logger_1.default.warn(`${warning}`);
211
+ logger_1.default.warn(warning);
207
212
  });
208
213
  }
209
214
  // Webpack 5 requires calling close() so that persistent caching works
@@ -295,7 +300,6 @@ function getMinimizer(useSimpleCssMinifier = false) {
295
300
  },
296
301
  compress: {
297
302
  ecma: 5,
298
- // @ts-expect-error: API change in new version?
299
303
  warnings: false,
300
304
  },
301
305
  mangle: {
@@ -326,7 +330,6 @@ function getMinimizer(useSimpleCssMinifier = false) {
326
330
  },
327
331
  // CleanCss options
328
332
  {
329
- // @ts-expect-error: API change in new version?
330
333
  inline: false,
331
334
  level: {
332
335
  1: {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@docusaurus/core",
3
3
  "description": "Easy to Maintain Open Source Documentation Websites",
4
- "version": "2.0.0-beta.14",
4
+ "version": "2.0.0-beta.15",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -24,8 +24,8 @@
24
24
  "docusaurus": "bin/docusaurus.js"
25
25
  },
26
26
  "scripts": {
27
- "build": "tsc && tsc -p tsconfig.client.json && node copyUntypedFiles.js",
28
- "watch": "node copyUntypedFiles.js && concurrently -n \"server,client\" --kill-others \"tsc --watch\" \"tsc -p tsconfig.client.json --watch\""
27
+ "build": "tsc && tsc -p tsconfig.client.json && node copyUntypedFiles.mjs",
28
+ "watch": "node copyUntypedFiles.mjs && concurrently -n \"server,client\" --kill-others \"tsc --watch\" \"tsc -p tsconfig.client.json --watch\""
29
29
  },
30
30
  "bugs": {
31
31
  "url": "https://github.com/facebook/docusaurus/issues"
@@ -41,13 +41,13 @@
41
41
  "@babel/runtime": "^7.16.3",
42
42
  "@babel/runtime-corejs3": "^7.16.3",
43
43
  "@babel/traverse": "^7.16.3",
44
- "@docusaurus/cssnano-preset": "2.0.0-beta.14",
45
- "@docusaurus/logger": "2.0.0-beta.14",
46
- "@docusaurus/mdx-loader": "2.0.0-beta.14",
44
+ "@docusaurus/cssnano-preset": "2.0.0-beta.15",
45
+ "@docusaurus/logger": "2.0.0-beta.15",
46
+ "@docusaurus/mdx-loader": "2.0.0-beta.15",
47
47
  "@docusaurus/react-loadable": "5.5.2",
48
- "@docusaurus/utils": "2.0.0-beta.14",
49
- "@docusaurus/utils-common": "2.0.0-beta.14",
50
- "@docusaurus/utils-validation": "2.0.0-beta.14",
48
+ "@docusaurus/utils": "2.0.0-beta.15",
49
+ "@docusaurus/utils-common": "2.0.0-beta.15",
50
+ "@docusaurus/utils-validation": "2.0.0-beta.15",
51
51
  "@slorber/static-site-generator-webpack-plugin": "^4.0.0",
52
52
  "@svgr/webpack": "^6.0.0",
53
53
  "autoprefixer": "^10.3.5",
@@ -57,10 +57,10 @@
57
57
  "chokidar": "^3.5.2",
58
58
  "clean-css": "^5.1.5",
59
59
  "commander": "^5.1.0",
60
- "copy-webpack-plugin": "^9.0.1",
60
+ "copy-webpack-plugin": "^10.2.0",
61
61
  "core-js": "^3.18.0",
62
- "css-loader": "^5.1.1",
63
- "css-minimizer-webpack-plugin": "^3.0.2",
62
+ "css-loader": "^6.5.1",
63
+ "css-minimizer-webpack-plugin": "^3.3.1",
64
64
  "cssnano": "^5.0.8",
65
65
  "del": "^6.0.0",
66
66
  "detect-port": "^1.3.0",
@@ -68,7 +68,6 @@
68
68
  "eta": "^1.12.3",
69
69
  "file-loader": "^6.2.0",
70
70
  "fs-extra": "^10.0.0",
71
- "globby": "^11.0.2",
72
71
  "html-minifier-terser": "^6.0.2",
73
72
  "html-tags": "^3.1.0",
74
73
  "html-webpack-plugin": "^5.4.0",
@@ -81,8 +80,7 @@
81
80
  "postcss": "^8.3.7",
82
81
  "postcss-loader": "^6.1.1",
83
82
  "prompts": "^2.4.1",
84
- "react-dev-utils": "12.0.0-next.47",
85
- "react-error-overlay": "^6.0.9",
83
+ "react-dev-utils": "^12.0.0",
86
84
  "react-helmet": "^6.1.0",
87
85
  "react-loadable": "npm:@docusaurus/react-loadable@5.5.2",
88
86
  "react-loadable-ssr-addon-v5-slorber": "^1.0.1",
@@ -90,7 +88,6 @@
90
88
  "react-router-config": "^5.1.1",
91
89
  "react-router-dom": "^5.2.0",
92
90
  "remark-admonitions": "^1.2.1",
93
- "resolve-pathname": "^3.0.0",
94
91
  "rtl-detect": "^1.0.4",
95
92
  "semver": "^7.3.4",
96
93
  "serve-handler": "^6.1.3",
@@ -103,22 +100,25 @@
103
100
  "wait-on": "^6.0.0",
104
101
  "webpack": "^5.61.0",
105
102
  "webpack-bundle-analyzer": "^4.4.2",
106
- "webpack-dev-server": "^4.5.0",
103
+ "webpack-dev-server": "^4.7.1",
107
104
  "webpack-merge": "^5.8.0",
108
- "webpackbar": "^5.0.0-3"
105
+ "webpackbar": "^5.0.2"
109
106
  },
110
107
  "devDependencies": {
111
- "@docusaurus/module-type-aliases": "2.0.0-beta.14",
112
- "@docusaurus/types": "2.0.0-beta.14",
108
+ "@docusaurus/module-type-aliases": "2.0.0-beta.15",
109
+ "@docusaurus/types": "2.0.0-beta.15",
113
110
  "@types/copy-webpack-plugin": "^8.0.1",
114
- "@types/css-minimizer-webpack-plugin": "^3.0.2",
115
111
  "@types/detect-port": "^1.3.0",
116
112
  "@types/mini-css-extract-plugin": "^1.4.3",
117
113
  "@types/nprogress": "^0.2.0",
118
114
  "@types/react-dom": "^17.0.9",
115
+ "@types/react-helmet": "^6.0.0",
116
+ "@types/react-router-config": "^5.0.1",
119
117
  "@types/rtl-detect": "^1.0.0",
120
118
  "@types/serve-handler": "^6.1.1",
119
+ "@types/wait-on": "^5.2.0",
121
120
  "@types/webpack-bundle-analyzer": "^4.4.1",
121
+ "react-test-renderer": "^17.0.2",
122
122
  "tmp-promise": "^3.0.2"
123
123
  },
124
124
  "peerDependencies": {
@@ -128,5 +128,5 @@
128
128
  "engines": {
129
129
  "node": ">=14"
130
130
  },
131
- "gitHead": "c4824a8937d8f1aa0806667749cbc74058e2b294"
131
+ "gitHead": "6cfad16436c07d8d11e5c2e1486dc59afd483e33"
132
132
  }