@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.
Files changed (115) hide show
  1. package/bin/beforeCli.js +125 -0
  2. package/bin/docusaurus.js +36 -105
  3. package/lib/.tsbuildinfo +1 -1
  4. package/lib/babel/preset.d.ts +6 -0
  5. package/lib/babel/preset.js +3 -3
  6. package/lib/choosePort.js +12 -13
  7. package/lib/client/.eslintrc.js +0 -1
  8. package/lib/client/.tsbuildinfo +1 -1
  9. package/lib/client/App.js +12 -22
  10. package/lib/client/LinksCollector.d.ts +2 -2
  11. package/lib/client/LinksCollector.js +4 -8
  12. package/lib/client/PendingNavigation.d.ts +24 -1
  13. package/lib/client/PendingNavigation.js +1 -1
  14. package/lib/client/baseUrlIssueBanner/BaseUrlIssueBanner.d.ts +5 -0
  15. package/lib/client/client-lifecycles-dispatcher.d.ts +2 -2
  16. package/lib/client/client-lifecycles-dispatcher.js +0 -2
  17. package/lib/client/docusaurus.d.ts +6 -0
  18. package/lib/client/docusaurus.js +11 -19
  19. package/lib/client/exports/BrowserOnly.js +5 -3
  20. package/lib/client/exports/ErrorBoundary.d.ts +18 -0
  21. package/lib/client/exports/ErrorBoundary.js +35 -0
  22. package/lib/client/exports/Interpolate.js +12 -15
  23. package/lib/client/exports/Link.js +11 -11
  24. package/lib/client/exports/Translate.d.ts +2 -2
  25. package/lib/client/exports/Translate.js +13 -9
  26. package/lib/client/exports/browserContext.d.ts +11 -0
  27. package/lib/client/exports/browserContext.js +21 -0
  28. package/lib/client/exports/constants.js +1 -11
  29. package/lib/client/exports/{context.d.ts → docusaurusContext.d.ts} +5 -3
  30. package/lib/client/exports/docusaurusContext.js +25 -0
  31. package/lib/client/exports/useBaseUrl.js +2 -4
  32. package/lib/client/exports/useDocusaurusContext.js +2 -7
  33. package/lib/client/exports/useGlobalData.js +1 -5
  34. package/lib/client/exports/{context.js → useIsBrowser.d.ts} +1 -2
  35. package/lib/{webpack/sharedModuleAliases.d.ts → client/exports/useIsBrowser.js} +5 -4
  36. package/lib/client/flat.d.ts +2 -1
  37. package/lib/client/flat.js +7 -9
  38. package/lib/client/normalizeLocation.d.ts +1 -3
  39. package/lib/client/prefetch.js +0 -1
  40. package/lib/client/serverEntry.js +15 -31
  41. package/lib/client/theme-fallback/Error/index.js +47 -0
  42. package/lib/client/theme-fallback/Layout/index.js +1 -1
  43. package/lib/client/theme-fallback/Loading/index.js +2 -2
  44. package/lib/client/theme-fallback/Root/index.js +1 -3
  45. package/lib/commands/build.js +37 -40
  46. package/lib/commands/clear.d.ts +6 -0
  47. package/lib/commands/clear.js +9 -9
  48. package/lib/commands/commandUtils.d.ts +6 -0
  49. package/lib/commands/commandUtils.js +7 -7
  50. package/lib/commands/deploy.d.ts +3 -0
  51. package/lib/commands/deploy.js +98 -53
  52. package/lib/commands/external.js +4 -4
  53. package/lib/commands/serve.js +13 -13
  54. package/lib/commands/start.js +83 -73
  55. package/lib/commands/swizzle.js +49 -49
  56. package/lib/commands/writeHeadingIds.d.ts +9 -6
  57. package/lib/commands/writeHeadingIds.js +32 -32
  58. package/lib/commands/writeTranslations.js +31 -11
  59. package/lib/server/brokenLinks.js +13 -17
  60. package/lib/server/client-modules/index.js +1 -3
  61. package/lib/server/config.js +4 -4
  62. package/lib/server/configValidation.d.ts +1 -1
  63. package/lib/server/configValidation.js +12 -7
  64. package/lib/server/duplicateRoutes.js +8 -2
  65. package/lib/server/html-tags/htmlTags.js +5 -6
  66. package/lib/server/html-tags/index.d.ts +2 -2
  67. package/lib/server/html-tags/index.js +3 -3
  68. package/lib/server/i18n.js +16 -13
  69. package/lib/server/index.js +129 -71
  70. package/lib/server/loadSetup.js +3 -3
  71. package/lib/server/moduleShorthand.d.ts +9 -0
  72. package/lib/server/moduleShorthand.js +42 -0
  73. package/lib/server/plugins/applyRouteTrailingSlash.d.ts +2 -1
  74. package/lib/server/plugins/applyRouteTrailingSlash.js +3 -3
  75. package/lib/server/plugins/index.d.ts +3 -4
  76. package/lib/server/plugins/index.js +44 -33
  77. package/lib/server/plugins/init.d.ts +2 -6
  78. package/lib/server/plugins/init.js +9 -12
  79. package/lib/server/plugins/pluginIds.d.ts +2 -2
  80. package/lib/server/plugins/pluginIds.js +6 -4
  81. package/lib/server/presets/index.js +12 -12
  82. package/lib/server/routes.js +41 -23
  83. package/lib/server/themes/alias.d.ts +3 -2
  84. package/lib/server/themes/alias.js +22 -12
  85. package/lib/server/themes/index.d.ts +6 -2
  86. package/lib/server/themes/index.js +32 -21
  87. package/lib/server/translations/translations.d.ts +10 -5
  88. package/lib/server/translations/translations.js +15 -17
  89. package/lib/server/translations/translationsExtractor.d.ts +8 -3
  90. package/lib/server/translations/translationsExtractor.js +65 -56
  91. package/lib/server/utils.d.ts +8 -2
  92. package/lib/server/utils.js +8 -10
  93. package/lib/server/versions/__fixtures__/dummy-plugin.d.ts +0 -0
  94. package/lib/server/versions/__tests/index.test.js +5 -5
  95. package/lib/server/versions/index.js +6 -6
  96. package/lib/webpack/base.js +29 -21
  97. package/lib/webpack/client.js +8 -17
  98. package/lib/webpack/plugins/CleanWebpackPlugin.js +4 -11
  99. package/lib/webpack/plugins/LogPlugin.js +5 -6
  100. package/lib/webpack/plugins/WaitPlugin.js +4 -4
  101. package/lib/webpack/server.js +13 -9
  102. package/lib/webpack/utils.d.ts +2 -23
  103. package/lib/webpack/utils.js +29 -127
  104. package/package.json +56 -51
  105. package/tsconfig.client.json +1 -2
  106. package/tsconfig.json +5 -4
  107. package/lib/commands/buildRemoteBranchUrl.d.ts +0 -7
  108. package/lib/commands/buildRemoteBranchUrl.js +0 -27
  109. package/lib/constants.d.ts +0 -18
  110. package/lib/constants.js +0 -23
  111. package/lib/webpack/react-dev-utils-webpack5/README.md +0 -11
  112. package/lib/webpack/react-dev-utils-webpack5/evalSourceMapMiddleware.js +0 -57
  113. package/lib/webpack/react-dev-utils-webpack5/formatWebpackMessages.js +0 -138
  114. package/lib/webpack/react-dev-utils-webpack5/webpackHotDevClient.js +0 -285
  115. package/lib/webpack/sharedModuleAliases.js +0 -18
@@ -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 constants_1 = require("../constants");
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${constants_1.NODE_MAJOR_VERSION}.${constants_1.NODE_MINOR_VERSION}`,
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
  },
@@ -57,6 +57,10 @@ function createServerConfig({ props, onLinksCollected = () => { }, }) {
57
57
  },
58
58
  paths: ssgPaths,
59
59
  preferFoldersOutput: trailingSlash,
60
+ // When using "new URL('file.js', import.meta.url)", Webpack will emit __filename, and this plugin will throw
61
+ // not sure the __filename value has any importance for this plugin, just using an empty string to avoid the error
62
+ // See https://github.com/facebook/docusaurus/issues/4922
63
+ globals: { __filename: '' },
60
64
  }),
61
65
  // Show compilation progress bar.
62
66
  new LogPlugin_1.default({
@@ -26,35 +26,14 @@ export declare const getCustomizableJSLoader: (jsLoader?: "babel" | ((isServer:
26
26
  * @param config initial webpack config
27
27
  * @param isServer indicates if this is a server webpack configuration
28
28
  * @param jsLoader custom js loader config
29
+ * @param content content loaded by the plugin
29
30
  * @returns final/ modified webpack config
30
31
  */
31
- export declare function applyConfigureWebpack(configureWebpack: ConfigureWebpackFn, config: Configuration, isServer: boolean, jsLoader?: 'babel' | ((isServer: boolean) => RuleSetRule)): Configuration;
32
+ export declare function applyConfigureWebpack(configureWebpack: ConfigureWebpackFn, config: Configuration, isServer: boolean, jsLoader: 'babel' | ((isServer: boolean) => RuleSetRule) | undefined, content: unknown): Configuration;
32
33
  export declare function applyConfigurePostCss(configurePostCss: NonNullable<ConfigurePostCssFn>, config: Configuration): Configuration;
33
34
  export declare function compile(config: Configuration[]): Promise<void>;
34
- declare type AssetFolder = 'images' | 'files' | 'fonts' | 'medias';
35
- declare type FileLoaderUtils = {
36
- loaders: {
37
- file: (options: {
38
- folder: AssetFolder;
39
- }) => RuleSetRule;
40
- url: (options: {
41
- folder: AssetFolder;
42
- }) => RuleSetRule;
43
- inlineMarkdownImageFileLoader: string;
44
- inlineMarkdownLinkFileLoader: string;
45
- };
46
- rules: {
47
- images: () => RuleSetRule;
48
- fonts: () => RuleSetRule;
49
- media: () => RuleSetRule;
50
- svg: () => RuleSetRule;
51
- otherAssets: () => RuleSetRule;
52
- };
53
- };
54
- export declare function getFileLoaderUtils(): FileLoaderUtils;
55
35
  export declare function getHttpsConfig(): boolean | {
56
36
  cert: Buffer;
57
37
  key: Buffer;
58
38
  };
59
39
  export declare function getMinimizer(useSimpleCssMinifier?: boolean): WebpackPluginInstance[];
60
- export {};
@@ -6,18 +6,18 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.getMinimizer = exports.getHttpsConfig = exports.getFileLoaderUtils = exports.compile = exports.applyConfigurePostCss = exports.applyConfigureWebpack = exports.getCustomizableJSLoader = exports.getBabelOptions = exports.getCustomBabelConfigFilePath = exports.getStyleLoaders = void 0;
9
+ exports.getMinimizer = exports.getHttpsConfig = exports.compile = exports.applyConfigurePostCss = exports.applyConfigureWebpack = exports.getCustomizableJSLoader = exports.getBabelOptions = exports.getCustomBabelConfigFilePath = exports.getStyleLoaders = void 0;
10
10
  const tslib_1 = require("tslib");
11
- const mini_css_extract_plugin_1 = tslib_1.__importDefault(require("mini-css-extract-plugin"));
11
+ const mini_css_extract_plugin_1 = (0, tslib_1.__importDefault)(require("mini-css-extract-plugin"));
12
12
  const webpack_merge_1 = require("webpack-merge");
13
- const webpack_1 = tslib_1.__importDefault(require("webpack"));
14
- const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
15
- const terser_webpack_plugin_1 = tslib_1.__importDefault(require("terser-webpack-plugin"));
16
- const css_minimizer_webpack_plugin_1 = tslib_1.__importDefault(require("css-minimizer-webpack-plugin"));
17
- const path_1 = tslib_1.__importDefault(require("path"));
18
- const crypto_1 = tslib_1.__importDefault(require("crypto"));
19
- const chalk_1 = tslib_1.__importDefault(require("chalk"));
20
- const constants_1 = require("../constants");
13
+ const webpack_1 = (0, tslib_1.__importDefault)(require("webpack"));
14
+ const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
15
+ const terser_webpack_plugin_1 = (0, tslib_1.__importDefault)(require("terser-webpack-plugin"));
16
+ const css_minimizer_webpack_plugin_1 = (0, tslib_1.__importDefault)(require("css-minimizer-webpack-plugin"));
17
+ const path_1 = (0, tslib_1.__importDefault)(require("path"));
18
+ const crypto_1 = (0, tslib_1.__importDefault)(require("crypto"));
19
+ const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
20
+ const utils_1 = require("@docusaurus/utils");
21
21
  const lodash_1 = require("lodash");
22
22
  // Utility method to get style loaders
23
23
  function getStyleLoaders(isServer, cssOptions = {}) {
@@ -66,7 +66,7 @@ function getStyleLoaders(isServer, cssOptions = {}) {
66
66
  // https://github.com/facebook/create-react-app/issues/2677
67
67
  ident: 'postcss',
68
68
  plugins: [
69
- // eslint-disable-next-line @typescript-eslint/no-var-requires, global-require
69
+ // eslint-disable-next-line global-require
70
70
  require('autoprefixer'),
71
71
  ],
72
72
  },
@@ -76,7 +76,7 @@ function getStyleLoaders(isServer, cssOptions = {}) {
76
76
  }
77
77
  exports.getStyleLoaders = getStyleLoaders;
78
78
  function getCustomBabelConfigFilePath(siteDir) {
79
- const customBabelConfigurationPath = path_1.default.join(siteDir, constants_1.BABEL_CONFIG_FILE_NAME);
79
+ const customBabelConfigurationPath = path_1.default.join(siteDir, utils_1.BABEL_CONFIG_FILE_NAME);
80
80
  return fs_extra_1.default.existsSync(customBabelConfigurationPath)
81
81
  ? customBabelConfigurationPath
82
82
  : undefined;
@@ -112,7 +112,7 @@ const getCustomizableJSLoader = (jsLoader = 'babel') => ({ isServer, babelOption
112
112
  : jsLoader(isServer);
113
113
  exports.getCustomizableJSLoader = getCustomizableJSLoader;
114
114
  // TODO remove this before end of 2021?
115
- const warnBabelLoaderOnce = lodash_1.memoize(function () {
115
+ const warnBabelLoaderOnce = (0, lodash_1.memoize)(() => {
116
116
  console.warn(chalk_1.default.yellow('Docusaurus plans to support multiple JS loader strategies (Babel, esbuild...): "getBabelLoader(isServer)" is now deprecated in favor of "getJSLoader({isServer})".'));
117
117
  });
118
118
  const getBabelLoaderDeprecated = function getBabelLoaderDeprecated(isServer, babelOptions) {
@@ -120,7 +120,7 @@ const getBabelLoaderDeprecated = function getBabelLoaderDeprecated(isServer, bab
120
120
  return getDefaultBabelLoader({ isServer, babelOptions });
121
121
  };
122
122
  // TODO remove this before end of 2021 ?
123
- const warnCacheLoaderOnce = lodash_1.memoize(function () {
123
+ const warnCacheLoaderOnce = (0, lodash_1.memoize)(() => {
124
124
  console.warn(chalk_1.default.yellow('Docusaurus uses Webpack 5 and getCacheLoader() usage is now deprecated.'));
125
125
  });
126
126
  function getCacheLoaderDeprecated() {
@@ -133,24 +133,24 @@ function getCacheLoaderDeprecated() {
133
133
  * @param config initial webpack config
134
134
  * @param isServer indicates if this is a server webpack configuration
135
135
  * @param jsLoader custom js loader config
136
+ * @param content content loaded by the plugin
136
137
  * @returns final/ modified webpack config
137
138
  */
138
- function applyConfigureWebpack(configureWebpack, config, isServer, jsLoader) {
139
+ function applyConfigureWebpack(configureWebpack, config, isServer, jsLoader, content) {
139
140
  // Export some utility functions
140
141
  const utils = {
141
142
  getStyleLoaders,
142
- getJSLoader: exports.getCustomizableJSLoader(jsLoader),
143
+ getJSLoader: (0, exports.getCustomizableJSLoader)(jsLoader),
143
144
  getBabelLoader: getBabelLoaderDeprecated,
144
145
  getCacheLoader: getCacheLoaderDeprecated,
145
146
  };
146
147
  if (typeof configureWebpack === 'function') {
147
- const { mergeStrategy, ...res } = configureWebpack(config, isServer, utils);
148
+ const { mergeStrategy, ...res } = configureWebpack(config, isServer, utils, content);
148
149
  if (res && typeof res === 'object') {
149
- // @ts-expect-error: annoying error due to enums: https://github.com/survivejs/webpack-merge/issues/179
150
150
  const customizeRules = mergeStrategy !== null && mergeStrategy !== void 0 ? mergeStrategy : {};
151
- return webpack_merge_1.mergeWithCustomize({
152
- customizeArray: webpack_merge_1.customizeArray(customizeRules),
153
- customizeObject: webpack_merge_1.customizeObject(customizeRules),
151
+ return (0, webpack_merge_1.mergeWithCustomize)({
152
+ customizeArray: (0, webpack_merge_1.customizeArray)(customizeRules),
153
+ customizeObject: (0, webpack_merge_1.customizeObject)(customizeRules),
154
154
  })(config, res);
155
155
  }
156
156
  }
@@ -175,16 +175,16 @@ function applyConfigurePostCss(configurePostCss, config) {
175
175
  else if (Array.isArray(entry.use)) {
176
176
  entry.use
177
177
  .filter((u) => typeof u === 'object')
178
- .forEach(overridePostCssOptions);
178
+ .forEach((rule) => overridePostCssOptions(rule));
179
179
  }
180
180
  }
181
- (_b = (_a = config.module) === null || _a === void 0 ? void 0 : _a.rules) === null || _b === void 0 ? void 0 : _b.forEach(overridePostCssOptions);
181
+ (_b = (_a = config.module) === null || _a === void 0 ? void 0 : _a.rules) === null || _b === void 0 ? void 0 : _b.forEach((rule) => overridePostCssOptions(rule));
182
182
  return config;
183
183
  }
184
184
  exports.applyConfigurePostCss = applyConfigurePostCss;
185
185
  function compile(config) {
186
186
  return new Promise((resolve, reject) => {
187
- const compiler = webpack_1.default(config);
187
+ const compiler = (0, webpack_1.default)(config);
188
188
  compiler.run((err, stats) => {
189
189
  var _a;
190
190
  if (err) {
@@ -221,110 +221,9 @@ function compile(config) {
221
221
  });
222
222
  }
223
223
  exports.compile = compile;
224
- // Inspired by https://github.com/gatsbyjs/gatsby/blob/8e6e021014da310b9cc7d02e58c9b3efe938c665/packages/gatsby/src/utils/webpack-utils.ts#L447
225
- function getFileLoaderUtils() {
226
- // files/images < 10kb will be inlined as base64 strings directly in the html
227
- const urlLoaderLimit = 10000;
228
- // defines the path/pattern of the assets handled by webpack
229
- const fileLoaderFileName = (folder) => `${constants_1.OUTPUT_STATIC_ASSETS_DIR_NAME}/${folder}/[name]-[hash].[ext]`;
230
- const loaders = {
231
- file: (options) => {
232
- return {
233
- loader: require.resolve(`file-loader`),
234
- options: {
235
- name: fileLoaderFileName(options.folder),
236
- },
237
- };
238
- },
239
- url: (options) => {
240
- return {
241
- loader: require.resolve(`url-loader`),
242
- options: {
243
- limit: urlLoaderLimit,
244
- name: fileLoaderFileName(options.folder),
245
- fallback: require.resolve(`file-loader`),
246
- },
247
- };
248
- },
249
- // TODO find a better solution to avoid conflicts with the ideal-image plugin
250
- // TODO this may require a little breaking change for ideal-image users?
251
- // Maybe with the ideal image plugin, all md images should be "ideal"?
252
- // This is used to force url-loader+file-loader on markdown images
253
- // https://webpack.js.org/concepts/loaders/#inline
254
- inlineMarkdownImageFileLoader: `!url-loader?limit=${urlLoaderLimit}&name=${fileLoaderFileName('images')}&fallback=file-loader!`,
255
- inlineMarkdownLinkFileLoader: `!file-loader?name=${fileLoaderFileName('files')}!`,
256
- };
257
- const rules = {
258
- /**
259
- * Loads image assets, inlines images via a data URI if they are below
260
- * the size threshold
261
- */
262
- images: () => {
263
- return {
264
- use: [loaders.url({ folder: 'images' })],
265
- test: /\.(ico|jpg|jpeg|png|gif|webp)(\?.*)?$/,
266
- };
267
- },
268
- fonts: () => {
269
- return {
270
- use: [loaders.url({ folder: 'fonts' })],
271
- test: /\.(woff|woff2|eot|ttf|otf)$/,
272
- };
273
- },
274
- /**
275
- * Loads audio and video and inlines them via a data URI if they are below
276
- * the size threshold
277
- */
278
- media: () => {
279
- return {
280
- use: [loaders.url({ folder: 'medias' })],
281
- test: /\.(mp4|webm|ogv|wav|mp3|m4a|aac|oga|flac)$/,
282
- };
283
- },
284
- svg: () => {
285
- return {
286
- test: /\.svg?$/,
287
- oneOf: [
288
- {
289
- use: [
290
- {
291
- loader: '@svgr/webpack',
292
- options: {
293
- prettier: false,
294
- svgo: true,
295
- svgoConfig: {
296
- plugins: [{ removeViewBox: false }],
297
- },
298
- titleProp: true,
299
- ref: ![path_1.default],
300
- },
301
- },
302
- ],
303
- // We don't want to use SVGR loader for non-React source code
304
- // ie we don't want to use SVGR for CSS files...
305
- issuer: {
306
- and: [/\.(ts|tsx|js|jsx|md|mdx)$/],
307
- },
308
- },
309
- {
310
- use: [loaders.url({ folder: 'images' })],
311
- },
312
- ],
313
- };
314
- },
315
- otherAssets: () => {
316
- return {
317
- use: [loaders.file({ folder: 'files' })],
318
- test: /\.(pdf|doc|docx|xls|xlsx|zip|rar)$/,
319
- };
320
- },
321
- };
322
- return { loaders, rules };
323
- }
324
- exports.getFileLoaderUtils = getFileLoaderUtils;
325
224
  // Ensure the certificate and key provided are valid and if not
326
225
  // throw an easy to debug error
327
- function validateKeyAndCerts({ cert, key, keyFile, crtFile }) {
226
+ function validateKeyAndCerts({ cert, key, keyFile, crtFile, }) {
328
227
  let encrypted;
329
228
  try {
330
229
  // publicEncrypt will throw an error with an invalid cert
@@ -390,10 +289,11 @@ function getMinimizer(useSimpleCssMinifier = false) {
390
289
  // into invalid ecma 5 code. This is why the 'compress' and 'output'
391
290
  // sections only apply transformations that are ecma 5 safe
392
291
  // https://github.com/facebook/create-react-app/pull/4234
393
- ecma: 8,
292
+ ecma: 2020,
394
293
  },
395
294
  compress: {
396
295
  ecma: 5,
296
+ // @ts-expect-error: API change in new version?
397
297
  warnings: false,
398
298
  },
399
299
  mangle: {
@@ -424,10 +324,12 @@ function getMinimizer(useSimpleCssMinifier = false) {
424
324
  },
425
325
  // CleanCss options
426
326
  {
327
+ // @ts-expect-error: API change in new version?
427
328
  inline: false,
428
329
  level: {
429
330
  1: {
430
331
  all: false,
332
+ removeWhitespace: true,
431
333
  },
432
334
  2: {
433
335
  all: true,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@docusaurus/core",
3
3
  "description": "Easy to Maintain Open Source Documentation Websites",
4
- "version": "2.0.0-beta.1",
4
+ "version": "2.0.0-beta.10",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -30,98 +30,103 @@
30
30
  "bugs": {
31
31
  "url": "https://github.com/facebook/docusaurus/issues"
32
32
  },
33
- "devDependencies": {
34
- "@docusaurus/module-type-aliases": "2.0.0-beta.1",
35
- "@types/detect-port": "^1.3.0",
36
- "@types/nprogress": "^0.2.0",
37
- "tmp-promise": "^3.0.2"
38
- },
39
33
  "dependencies": {
40
- "@babel/core": "^7.12.16",
41
- "@babel/generator": "^7.12.15",
34
+ "@babel/core": "^7.16.0",
35
+ "@babel/generator": "^7.16.0",
42
36
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
43
- "@babel/plugin-transform-runtime": "^7.12.15",
44
- "@babel/preset-env": "^7.12.16",
45
- "@babel/preset-react": "^7.12.13",
46
- "@babel/preset-typescript": "^7.12.16",
47
- "@babel/runtime": "^7.12.5",
48
- "@babel/runtime-corejs3": "^7.12.13",
49
- "@babel/traverse": "^7.12.13",
50
- "@docusaurus/cssnano-preset": "2.0.0-beta.1",
51
- "@docusaurus/react-loadable": "5.5.0",
52
- "@docusaurus/types": "2.0.0-beta.1",
53
- "@docusaurus/utils": "2.0.0-beta.1",
54
- "@docusaurus/utils-common": "2.0.0-beta.1",
55
- "@docusaurus/utils-validation": "2.0.0-beta.1",
37
+ "@babel/plugin-transform-runtime": "^7.16.0",
38
+ "@babel/preset-env": "^7.16.4",
39
+ "@babel/preset-react": "^7.16.0",
40
+ "@babel/preset-typescript": "^7.16.0",
41
+ "@babel/runtime": "^7.16.3",
42
+ "@babel/runtime-corejs3": "^7.16.3",
43
+ "@babel/traverse": "^7.16.3",
44
+ "@docusaurus/cssnano-preset": "2.0.0-beta.10",
45
+ "@docusaurus/mdx-loader": "2.0.0-beta.10",
46
+ "@docusaurus/react-loadable": "5.5.2",
47
+ "@docusaurus/utils": "2.0.0-beta.10",
48
+ "@docusaurus/utils-common": "2.0.0-beta.10",
49
+ "@docusaurus/utils-validation": "2.0.0-beta.10",
56
50
  "@slorber/static-site-generator-webpack-plugin": "^4.0.0",
57
- "@svgr/webpack": "^5.5.0",
58
- "autoprefixer": "^10.2.5",
51
+ "@svgr/webpack": "^6.0.0",
52
+ "autoprefixer": "^10.3.5",
59
53
  "babel-loader": "^8.2.2",
60
54
  "babel-plugin-dynamic-import-node": "2.3.0",
61
55
  "boxen": "^5.0.1",
62
- "chalk": "^4.1.1",
63
- "chokidar": "^3.5.1",
64
- "clean-css": "^5.1.2",
56
+ "chalk": "^4.1.2",
57
+ "chokidar": "^3.5.2",
58
+ "clean-css": "^5.1.5",
65
59
  "commander": "^5.1.0",
66
- "copy-webpack-plugin": "^8.1.1",
67
- "core-js": "^3.9.1",
60
+ "copy-webpack-plugin": "^9.0.1",
61
+ "core-js": "^3.18.0",
68
62
  "css-loader": "^5.1.1",
69
- "css-minimizer-webpack-plugin": "^2.0.0",
70
- "cssnano": "^5.0.4",
63
+ "css-minimizer-webpack-plugin": "^3.0.2",
64
+ "cssnano": "^5.0.8",
71
65
  "del": "^6.0.0",
72
66
  "detect-port": "^1.3.0",
73
67
  "escape-html": "^1.0.3",
74
- "eta": "^1.12.1",
75
- "express": "^4.17.1",
68
+ "eta": "^1.12.3",
76
69
  "file-loader": "^6.2.0",
77
70
  "fs-extra": "^10.0.0",
78
- "github-slugger": "^1.3.0",
79
71
  "globby": "^11.0.2",
80
- "html-minifier-terser": "^5.1.1",
72
+ "html-minifier-terser": "^6.0.2",
81
73
  "html-tags": "^3.1.0",
82
- "html-webpack-plugin": "^5.3.1",
74
+ "html-webpack-plugin": "^5.4.0",
83
75
  "import-fresh": "^3.3.0",
84
76
  "is-root": "^2.1.0",
85
77
  "leven": "^3.1.0",
86
78
  "lodash": "^4.17.20",
87
79
  "mini-css-extract-plugin": "^1.6.0",
88
- "module-alias": "^2.2.2",
89
80
  "nprogress": "^0.2.0",
90
- "postcss": "^8.2.15",
91
- "postcss-loader": "^5.3.0",
81
+ "postcss": "^8.3.7",
82
+ "postcss-loader": "^6.1.1",
92
83
  "prompts": "^2.4.1",
93
- "react-dev-utils": "^11.0.1",
84
+ "react-dev-utils": "12.0.0-next.47",
94
85
  "react-error-overlay": "^6.0.9",
95
86
  "react-helmet": "^6.1.0",
96
- "react-loadable": "^5.5.0",
87
+ "react-loadable": "npm:@docusaurus/react-loadable@5.5.2",
97
88
  "react-loadable-ssr-addon-v5-slorber": "^1.0.1",
98
89
  "react-router": "^5.2.0",
99
90
  "react-router-config": "^5.1.1",
100
91
  "react-router-dom": "^5.2.0",
92
+ "remark-admonitions": "^1.2.1",
101
93
  "resolve-pathname": "^3.0.0",
102
- "rtl-detect": "^1.0.3",
94
+ "rtl-detect": "^1.0.4",
103
95
  "semver": "^7.3.4",
104
96
  "serve-handler": "^6.1.3",
105
97
  "shelljs": "^0.8.4",
106
- "std-env": "^2.2.1",
107
98
  "strip-ansi": "^6.0.0",
108
- "terser-webpack-plugin": "^5.1.2",
109
- "tslib": "^2.2.0",
99
+ "terser-webpack-plugin": "^5.2.4",
100
+ "tslib": "^2.3.1",
110
101
  "update-notifier": "^5.1.0",
111
102
  "url-loader": "^4.1.1",
112
- "wait-on": "^5.3.0",
113
- "webpack": "^5.37.0",
103
+ "wait-on": "^6.0.0",
104
+ "webpack": "^5.61.0",
114
105
  "webpack-bundle-analyzer": "^4.4.2",
115
- "webpack-dev-server": "^3.11.2",
116
- "webpack-merge": "^5.7.3",
106
+ "webpack-dev-server": "^4.5.0",
107
+ "webpack-merge": "^5.8.0",
117
108
  "webpackbar": "^5.0.0-3"
118
109
  },
110
+ "devDependencies": {
111
+ "@docusaurus/module-type-aliases": "2.0.0-beta.10",
112
+ "@docusaurus/types": "2.0.0-beta.10",
113
+ "@types/copy-webpack-plugin": "^8.0.1",
114
+ "@types/css-minimizer-webpack-plugin": "^3.0.2",
115
+ "@types/detect-port": "^1.3.0",
116
+ "@types/mini-css-extract-plugin": "^1.4.3",
117
+ "@types/nprogress": "^0.2.0",
118
+ "@types/react-dom": "^17.0.9",
119
+ "@types/rtl-detect": "^1.0.0",
120
+ "@types/serve-handler": "^6.1.1",
121
+ "@types/webpack-bundle-analyzer": "^4.4.1",
122
+ "tmp-promise": "^3.0.2"
123
+ },
119
124
  "peerDependencies": {
120
125
  "react": "^16.8.4 || ^17.0.0",
121
126
  "react-dom": "^16.8.4 || ^17.0.0"
122
127
  },
123
128
  "engines": {
124
- "node": ">=12.13.0"
129
+ "node": ">=14"
125
130
  },
126
- "gitHead": "72ed3476bf4ffe1fc2d1025dd2def536a2de8f12"
131
+ "gitHead": "6f4869af5721435d6995e63e2f24ac41646e34ea"
127
132
  }
@@ -2,11 +2,10 @@
2
2
  "extends": "../../tsconfig.json",
3
3
  "compilerOptions": {
4
4
  "incremental": true,
5
- "lib": ["DOM"],
5
+ "lib": ["DOM", "ES2019"],
6
6
  "module": "esnext",
7
7
  "tsBuildInfoFile": "./lib/client/.tsbuildinfo",
8
8
  "outDir": "lib/client",
9
- "noImplicitAny": false,
10
9
  "jsx": "react"
11
10
  },
12
11
  "include": ["src/client"]
package/tsconfig.json CHANGED
@@ -2,12 +2,13 @@
2
2
  "extends": "../../tsconfig.json",
3
3
  "compilerOptions": {
4
4
  "incremental": true,
5
- "lib": ["DOM"],
5
+ "lib": ["DOM", "ES2019"],
6
6
  "tsBuildInfoFile": "./lib/.tsbuildinfo",
7
7
  "rootDir": "src",
8
8
  "outDir": "lib",
9
- "noImplicitAny": false,
10
- "jsx": "react"
9
+ "jsx": "react",
10
+ "allowJs": true
11
11
  },
12
- "exclude": ["node_modules", "**/__tests__/**/*", "**/lib/**/*", "src/client"]
12
+ "include": ["src"],
13
+ "exclude": ["**/__tests__/**/*", "src/client"]
13
14
  }
@@ -1,7 +0,0 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
- export declare function buildUrl(githubHost: string, githubPort: string | undefined, gitCredentials: string | undefined, organizationName: string, projectName: string, useSSH: boolean | undefined): string;
@@ -1,27 +0,0 @@
1
- "use strict";
2
- /**
3
- * Copyright (c) Facebook, Inc. and its affiliates.
4
- *
5
- * This source code is licensed under the MIT license found in the
6
- * LICENSE file in the root directory of this source tree.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.buildUrl = void 0;
10
- function buildUrl(githubHost, githubPort, gitCredentials, organizationName, projectName, useSSH) {
11
- return useSSH
12
- ? buildSshUrl(githubHost, organizationName, projectName, githubPort)
13
- : buildHttpsUrl(gitCredentials, githubHost, organizationName, projectName, githubPort);
14
- }
15
- exports.buildUrl = buildUrl;
16
- function buildSshUrl(githubHost, organizationName, projectName, githubPort) {
17
- if (githubPort) {
18
- return `ssh://git@${githubHost}:${githubPort}/${organizationName}/${projectName}.git`;
19
- }
20
- return `git@${githubHost}:${organizationName}/${projectName}.git`;
21
- }
22
- function buildHttpsUrl(gitCredentials, githubHost, organizationName, projectName, githubPort) {
23
- if (githubPort) {
24
- return `https://${gitCredentials}@${githubHost}:${githubPort}/${organizationName}/${projectName}.git`;
25
- }
26
- return `https://${gitCredentials}@${githubHost}/${organizationName}/${projectName}.git`;
27
- }
@@ -1,18 +0,0 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
- export declare const NODE_MAJOR_VERSION: number;
8
- export declare const NODE_MINOR_VERSION: number;
9
- export declare const DEFAULT_BUILD_DIR_NAME = "build";
10
- export declare const DEFAULT_CONFIG_FILE_NAME = "docusaurus.config.js";
11
- export declare const BABEL_CONFIG_FILE_NAME: string;
12
- export declare const GENERATED_FILES_DIR_NAME: string;
13
- export declare const SRC_DIR_NAME = "src";
14
- export declare const STATIC_DIR_NAME = "static";
15
- export declare const OUTPUT_STATIC_ASSETS_DIR_NAME = "assets";
16
- export declare const THEME_PATH: string;
17
- export declare const DEFAULT_PORT = 3000;
18
- export declare const DEFAULT_PLUGIN_ID = "default";
package/lib/constants.js DELETED
@@ -1,23 +0,0 @@
1
- "use strict";
2
- /**
3
- * Copyright (c) Facebook, Inc. and its affiliates.
4
- *
5
- * This source code is licensed under the MIT license found in the
6
- * LICENSE file in the root directory of this source tree.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.DEFAULT_PLUGIN_ID = exports.DEFAULT_PORT = exports.THEME_PATH = exports.OUTPUT_STATIC_ASSETS_DIR_NAME = exports.STATIC_DIR_NAME = exports.SRC_DIR_NAME = exports.GENERATED_FILES_DIR_NAME = exports.BABEL_CONFIG_FILE_NAME = exports.DEFAULT_CONFIG_FILE_NAME = exports.DEFAULT_BUILD_DIR_NAME = exports.NODE_MINOR_VERSION = exports.NODE_MAJOR_VERSION = void 0;
10
- exports.NODE_MAJOR_VERSION = parseInt(process.versions.node.split('.')[0], 10);
11
- exports.NODE_MINOR_VERSION = parseInt(process.versions.node.split('.')[1], 10);
12
- // Can be overridden with cli option --out-dir
13
- exports.DEFAULT_BUILD_DIR_NAME = 'build';
14
- // Can be overridden with cli option --config
15
- exports.DEFAULT_CONFIG_FILE_NAME = 'docusaurus.config.js';
16
- exports.BABEL_CONFIG_FILE_NAME = process.env.DOCUSAURUS_BABEL_CONFIG_FILE_NAME || 'babel.config.js';
17
- exports.GENERATED_FILES_DIR_NAME = process.env.DOCUSAURUS_GENERATED_FILES_DIR_NAME || '.docusaurus';
18
- exports.SRC_DIR_NAME = 'src';
19
- exports.STATIC_DIR_NAME = 'static';
20
- exports.OUTPUT_STATIC_ASSETS_DIR_NAME = 'assets'; // files handled by webpack, hashed (can be cached aggressively)
21
- exports.THEME_PATH = `${exports.SRC_DIR_NAME}/theme`;
22
- exports.DEFAULT_PORT = 3000;
23
- exports.DEFAULT_PLUGIN_ID = 'default';
@@ -1,11 +0,0 @@
1
- This is a temporary copy of
2
-
3
- CRA / react-dev-utils does not support Webpack 5 yet
4
-
5
- https://github.com/facebook/create-react-app/issues/9994
6
-
7
- This folder is a temporary copy of some react-dev-utils code to which we made some changes to support Webpack 5 without warnings
8
-
9
- TODO remove this folder once Webpack 5 is supported (https://github.com/facebook/create-react-app/issues/9994)
10
-
11
- The comment `// modified for Docusaurus` is added near the modified elements