@docusaurus/core 0.0.0-5823 → 0.0.0-5828

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.
@@ -6,4 +6,18 @@
6
6
  */
7
7
  import type { Props } from '@docusaurus/types';
8
8
  import type { Configuration } from 'webpack';
9
- export default function createClientConfig(props: Props, minify?: boolean, hydrate?: boolean): Promise<Configuration>;
9
+ export declare function createStartClientConfig({ props, minify, poll, }: {
10
+ props: Props;
11
+ minify: boolean;
12
+ poll: number | boolean | undefined;
13
+ }): Promise<{
14
+ clientConfig: Configuration;
15
+ }>;
16
+ export declare function createBuildClientConfig({ props, minify, bundleAnalyzer, }: {
17
+ props: Props;
18
+ minify: boolean;
19
+ bundleAnalyzer: boolean;
20
+ }): Promise<{
21
+ config: Configuration;
22
+ clientManifestPath: string;
23
+ }>;
@@ -6,19 +6,36 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.createBuildClientConfig = exports.createStartClientConfig = void 0;
9
10
  const tslib_1 = require("tslib");
10
11
  const path_1 = tslib_1.__importDefault(require("path"));
11
12
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
12
13
  const webpack_merge_1 = tslib_1.__importDefault(require("webpack-merge"));
13
14
  const webpackbar_1 = tslib_1.__importDefault(require("webpackbar"));
14
- const webpack_1 = require("webpack");
15
+ const webpack_1 = tslib_1.__importDefault(require("webpack"));
16
+ const webpack_bundle_analyzer_1 = require("webpack-bundle-analyzer");
17
+ const react_loadable_ssr_addon_v5_slorber_1 = tslib_1.__importDefault(require("react-loadable-ssr-addon-v5-slorber"));
18
+ const html_webpack_plugin_1 = tslib_1.__importDefault(require("html-webpack-plugin"));
15
19
  const base_1 = require("./base");
16
20
  const ChunkAssetPlugin_1 = tslib_1.__importDefault(require("./plugins/ChunkAssetPlugin"));
17
21
  const utils_1 = require("./utils");
18
- async function createClientConfig(props, minify = true, hydrate = true) {
19
- const isBuilding = process.argv[2] === 'build';
20
- const config = await (0, base_1.createBaseConfig)(props, false, minify);
21
- const clientConfig = (0, webpack_merge_1.default)(config, {
22
+ const CleanWebpackPlugin_1 = tslib_1.__importDefault(require("./plugins/CleanWebpackPlugin"));
23
+ // When building, include the plugin to force terminate building if errors
24
+ // happened in the client bundle.
25
+ class ForceTerminatePlugin {
26
+ apply(compiler) {
27
+ compiler.hooks.done.tap('client:done', (stats) => {
28
+ if (stats.hasErrors()) {
29
+ const errorsWarnings = stats.toJson('errors-warnings');
30
+ logger_1.default.error(`Client bundle compiled with errors therefore further build is impossible.\n${(0, utils_1.formatStatsErrorMessage)(errorsWarnings)}`);
31
+ process.exit(1);
32
+ }
33
+ });
34
+ }
35
+ }
36
+ async function createBaseClientConfig({ props, hydrate, minify, }) {
37
+ const baseConfig = await (0, base_1.createBaseConfig)({ props, isServer: false, minify });
38
+ return (0, webpack_merge_1.default)(baseConfig, {
22
39
  // Useless, disabled on purpose (errors on existing sites with no
23
40
  // browserslist config)
24
41
  // target: 'browserslist',
@@ -29,7 +46,7 @@ async function createClientConfig(props, minify = true, hydrate = true) {
29
46
  runtimeChunk: true,
30
47
  },
31
48
  plugins: [
32
- new webpack_1.DefinePlugin({
49
+ new webpack_1.default.DefinePlugin({
33
50
  'process.env.HYDRATE_CLIENT_ENTRY': JSON.stringify(hydrate),
34
51
  }),
35
52
  new ChunkAssetPlugin_1.default(),
@@ -39,21 +56,59 @@ async function createClientConfig(props, minify = true, hydrate = true) {
39
56
  }),
40
57
  ],
41
58
  });
42
- // When building, include the plugin to force terminate building if errors
43
- // happened in the client bundle.
44
- if (isBuilding) {
45
- clientConfig.plugins?.push({
46
- apply: (compiler) => {
47
- compiler.hooks.done.tap('client:done', (stats) => {
48
- if (stats.hasErrors()) {
49
- const errorsWarnings = stats.toJson('errors-warnings');
50
- logger_1.default.error(`Client bundle compiled with errors therefore further build is impossible.\n${(0, utils_1.formatStatsErrorMessage)(errorsWarnings)}`);
51
- process.exit(1);
52
- }
53
- });
54
- },
55
- });
56
- }
57
- return clientConfig;
58
59
  }
59
- exports.default = createClientConfig;
60
+ // client config when running "docusaurus start"
61
+ async function createStartClientConfig({ props, minify, poll, }) {
62
+ const { siteConfig, headTags, preBodyTags, postBodyTags } = props;
63
+ const clientConfig = (0, webpack_merge_1.default)(await createBaseClientConfig({
64
+ props,
65
+ minify,
66
+ hydrate: false,
67
+ }), {
68
+ watchOptions: {
69
+ ignored: /node_modules\/(?!@docusaurus)/,
70
+ poll,
71
+ },
72
+ infrastructureLogging: {
73
+ // Reduce log verbosity, see https://github.com/facebook/docusaurus/pull/5420#issuecomment-906613105
74
+ level: 'warn',
75
+ },
76
+ plugins: [
77
+ // Generates an `index.html` file with the <script> injected.
78
+ new html_webpack_plugin_1.default({
79
+ template: path_1.default.join(__dirname, '../templates/dev.html.template.ejs'),
80
+ // So we can define the position where the scripts are injected.
81
+ inject: false,
82
+ filename: 'index.html',
83
+ title: siteConfig.title,
84
+ headTags,
85
+ preBodyTags,
86
+ postBodyTags,
87
+ }),
88
+ ],
89
+ });
90
+ return { clientConfig };
91
+ }
92
+ exports.createStartClientConfig = createStartClientConfig;
93
+ // client config when running "docusaurus build"
94
+ async function createBuildClientConfig({ props, minify, bundleAnalyzer, }) {
95
+ // Apply user webpack config.
96
+ const { generatedFilesDir } = props;
97
+ const clientManifestPath = path_1.default.join(generatedFilesDir, 'client-manifest.json');
98
+ const config = (0, webpack_merge_1.default)(await createBaseClientConfig({ props, minify, hydrate: true }), {
99
+ plugins: [
100
+ new ForceTerminatePlugin(),
101
+ // Remove/clean build folders before building bundles.
102
+ new CleanWebpackPlugin_1.default({ verbose: false }),
103
+ // Visualize size of webpack output files with an interactive zoomable
104
+ // tree map.
105
+ bundleAnalyzer && new webpack_bundle_analyzer_1.BundleAnalyzerPlugin(),
106
+ // Generate client manifests file that will be used for server bundle.
107
+ new react_loadable_ssr_addon_v5_slorber_1.default({
108
+ filename: clientManifestPath,
109
+ }),
110
+ ].filter((x) => Boolean(x)),
111
+ });
112
+ return { config, clientManifestPath };
113
+ }
114
+ exports.createBuildClientConfig = createBuildClientConfig;
@@ -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
+ import type { WebpackPluginInstance } from 'webpack';
8
+ export declare function getMinimizer(): WebpackPluginInstance[];
@@ -0,0 +1,97 @@
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.getMinimizer = void 0;
10
+ const tslib_1 = require("tslib");
11
+ const terser_webpack_plugin_1 = tslib_1.__importDefault(require("terser-webpack-plugin"));
12
+ const css_minimizer_webpack_plugin_1 = tslib_1.__importDefault(require("css-minimizer-webpack-plugin"));
13
+ // See https://github.com/webpack-contrib/terser-webpack-plugin#parallel
14
+ function getTerserParallel() {
15
+ let terserParallel = true;
16
+ if (process.env.TERSER_PARALLEL === 'false') {
17
+ terserParallel = false;
18
+ }
19
+ else if (process.env.TERSER_PARALLEL &&
20
+ parseInt(process.env.TERSER_PARALLEL, 10) > 0) {
21
+ terserParallel = parseInt(process.env.TERSER_PARALLEL, 10);
22
+ }
23
+ return terserParallel;
24
+ }
25
+ function getJsMinifierPlugin() {
26
+ return new terser_webpack_plugin_1.default({
27
+ parallel: getTerserParallel(),
28
+ terserOptions: {
29
+ parse: {
30
+ // We want uglify-js to parse ecma 8 code. However, we don't want it
31
+ // to apply any minification steps that turns valid ecma 5 code
32
+ // into invalid ecma 5 code. This is why the 'compress' and 'output'
33
+ // sections only apply transformations that are ecma 5 safe
34
+ // https://github.com/facebook/create-react-app/pull/4234
35
+ ecma: 2020,
36
+ },
37
+ compress: {
38
+ ecma: 5,
39
+ },
40
+ mangle: {
41
+ safari10: true,
42
+ },
43
+ output: {
44
+ ecma: 5,
45
+ comments: false,
46
+ // Turned on because emoji and regex is not minified properly using
47
+ // default. See https://github.com/facebook/create-react-app/issues/2488
48
+ ascii_only: true,
49
+ },
50
+ },
51
+ });
52
+ }
53
+ function getAdvancedCssMinifier() {
54
+ // Using the array syntax to add 2 minimizers
55
+ // see https://github.com/webpack-contrib/css-minimizer-webpack-plugin#array
56
+ return new css_minimizer_webpack_plugin_1.default({
57
+ minimizerOptions: [
58
+ // CssNano options
59
+ {
60
+ preset: require.resolve('@docusaurus/cssnano-preset'),
61
+ },
62
+ // CleanCss options
63
+ {
64
+ inline: false,
65
+ level: {
66
+ 1: {
67
+ all: false,
68
+ removeWhitespace: true,
69
+ },
70
+ 2: {
71
+ all: true,
72
+ restructureRules: true,
73
+ removeUnusedAtRules: false,
74
+ },
75
+ },
76
+ },
77
+ ],
78
+ minify: [
79
+ css_minimizer_webpack_plugin_1.default.cssnanoMinify,
80
+ css_minimizer_webpack_plugin_1.default.cleanCssMinify,
81
+ ],
82
+ });
83
+ }
84
+ function getMinimizer() {
85
+ // This is an historical env variable to opt-out of the advanced minifier
86
+ // Sometimes there's a bug in it and people are happy to disable it
87
+ const useSimpleCssMinifier = process.env.USE_SIMPLE_CSS_MINIFIER === 'true';
88
+ const minimizer = [getJsMinifierPlugin()];
89
+ if (useSimpleCssMinifier) {
90
+ minimizer.push(new css_minimizer_webpack_plugin_1.default());
91
+ }
92
+ else {
93
+ minimizer.push(getAdvancedCssMinifier());
94
+ }
95
+ return minimizer;
96
+ }
97
+ exports.getMinimizer = getMinimizer;
@@ -4,9 +4,11 @@
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 { type Locals } from '@slorber/static-site-generator-webpack-plugin';
8
7
  import type { Props } from '@docusaurus/types';
9
8
  import type { Configuration } from 'webpack';
10
- export default function createServerConfig({ props, onLinksCollected, onHeadTagsCollected, }: Pick<Locals, 'onLinksCollected' | 'onHeadTagsCollected'> & {
9
+ export default function createServerConfig(params: {
11
10
  props: Props;
12
- }): Promise<Configuration>;
11
+ }): Promise<{
12
+ config: Configuration;
13
+ serverBundlePath: string;
14
+ }>;
@@ -8,76 +8,67 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  const tslib_1 = require("tslib");
10
10
  const path_1 = tslib_1.__importDefault(require("path"));
11
+ const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
11
12
  const webpack_merge_1 = tslib_1.__importDefault(require("webpack-merge"));
12
13
  const utils_1 = require("@docusaurus/utils");
13
- // Forked for Docusaurus: https://github.com/slorber/static-site-generator-webpack-plugin
14
- const static_site_generator_webpack_plugin_1 = tslib_1.__importDefault(require("@slorber/static-site-generator-webpack-plugin"));
15
14
  const webpackbar_1 = tslib_1.__importDefault(require("webpackbar"));
15
+ const copy_webpack_plugin_1 = tslib_1.__importDefault(require("copy-webpack-plugin"));
16
16
  const base_1 = require("./base");
17
- const WaitPlugin_1 = tslib_1.__importDefault(require("./plugins/WaitPlugin"));
18
- const ssr_html_template_1 = tslib_1.__importDefault(require("./templates/ssr.html.template"));
19
- async function createServerConfig({ props, onLinksCollected, onHeadTagsCollected, }) {
20
- const { baseUrl, routesPaths, generatedFilesDir, headTags, preBodyTags, postBodyTags, siteConfig: { noIndex, trailingSlash, ssrTemplate }, } = props;
21
- const config = await (0, base_1.createBaseConfig)(props, true);
22
- const routesLocation = {};
23
- // Array of paths to be rendered. Relative to output directory
24
- const ssgPaths = routesPaths.map((str) => {
25
- const ssgPath = baseUrl === '/' ? str : str.replace(new RegExp(`^${baseUrl}`), '/');
26
- routesLocation[ssgPath] = str;
27
- return ssgPath;
17
+ async function createServerConfig(params) {
18
+ const { props } = params;
19
+ const baseConfig = await (0, base_1.createBaseConfig)({
20
+ props,
21
+ isServer: true,
22
+ // Minification of server bundle reduces size but doubles bundle time :/
23
+ minify: false,
28
24
  });
29
- const serverConfig = (0, webpack_merge_1.default)(config, {
25
+ const outputFilename = 'server.bundle.js';
26
+ const serverBundlePath = path_1.default.join(props.outDir, outputFilename);
27
+ const config = (0, webpack_merge_1.default)(baseConfig, {
30
28
  target: `node${utils_1.NODE_MAJOR_VERSION}.${utils_1.NODE_MINOR_VERSION}`,
31
29
  entry: {
32
30
  main: path_1.default.resolve(__dirname, '../client/serverEntry.js'),
33
31
  },
34
32
  output: {
35
- filename: 'server.bundle.js',
33
+ filename: outputFilename,
36
34
  libraryTarget: 'commonjs2',
37
35
  // Workaround for Webpack 4 Bug (https://github.com/webpack/webpack/issues/6522)
38
36
  globalObject: 'this',
39
37
  },
40
38
  plugins: [
41
- // Wait until manifest from client bundle is generated
42
- new WaitPlugin_1.default({
43
- filepath: path_1.default.join(generatedFilesDir, 'client-manifest.json'),
44
- }),
45
- // Static site generator webpack plugin.
46
- new static_site_generator_webpack_plugin_1.default({
47
- entry: 'main',
48
- locals: {
49
- baseUrl,
50
- generatedFilesDir,
51
- routesLocation,
52
- headTags,
53
- preBodyTags,
54
- postBodyTags,
55
- onLinksCollected,
56
- onHeadTagsCollected,
57
- ssrTemplate: ssrTemplate ?? ssr_html_template_1.default,
58
- noIndex,
59
- DOCUSAURUS_VERSION: utils_1.DOCUSAURUS_VERSION,
60
- },
61
- paths: ssgPaths,
62
- preferFoldersOutput: trailingSlash,
63
- // When using "new URL('file.js', import.meta.url)", Webpack will emit
64
- // __filename, and this plugin will throw. not sure the __filename value
65
- // has any importance for this plugin, just using an empty string to
66
- // avoid the error. See https://github.com/facebook/docusaurus/issues/4922
67
- globals: { __filename: '' },
68
- // Secret way to set SSR plugin concurrency option
69
- // Waiting for feedback before documenting this officially?
70
- concurrency: process.env.DOCUSAURUS_SSR_CONCURRENCY
71
- ? parseInt(process.env.DOCUSAURUS_SSR_CONCURRENCY, 10)
72
- : undefined,
73
- }),
74
39
  // Show compilation progress bar.
75
40
  new webpackbar_1.default({
76
41
  name: 'Server',
77
42
  color: 'yellow',
78
43
  }),
79
- ],
44
+ await createStaticDirectoriesCopyPlugin(params),
45
+ ].filter(Boolean),
80
46
  });
81
- return serverConfig;
47
+ return { config, serverBundlePath };
82
48
  }
83
49
  exports.default = createServerConfig;
50
+ async function createStaticDirectoriesCopyPlugin({ props }) {
51
+ const { outDir, siteDir, siteConfig: { staticDirectories: staticDirectoriesOption }, } = props;
52
+ // The staticDirectories option can contain empty directories, or non-existent
53
+ // directories (e.g. user deleted `static`). Instead of issuing an error, we
54
+ // just silently filter them out, because user could have never configured it
55
+ // in the first place (the default option should always "work").
56
+ const staticDirectories = (await Promise.all(staticDirectoriesOption.map(async (dir) => {
57
+ const staticDir = path_1.default.resolve(siteDir, dir);
58
+ if ((await fs_extra_1.default.pathExists(staticDir)) &&
59
+ (await fs_extra_1.default.readdir(staticDir)).length > 0) {
60
+ return staticDir;
61
+ }
62
+ return '';
63
+ }))).filter(Boolean);
64
+ if (staticDirectories.length === 0) {
65
+ return undefined;
66
+ }
67
+ return new copy_webpack_plugin_1.default({
68
+ patterns: staticDirectories.map((dir) => ({
69
+ from: dir,
70
+ to: outDir,
71
+ toType: 'dir',
72
+ })),
73
+ });
74
+ }
@@ -5,9 +5,9 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  /// <reference types="node" />
8
- import webpack, { type Configuration, type RuleSetRule, type WebpackPluginInstance } from 'webpack';
8
+ import webpack, { type Configuration, type RuleSetRule } from 'webpack';
9
9
  import type { TransformOptions } from '@babel/core';
10
- import type { Plugin } from '@docusaurus/types';
10
+ import type { Plugin, LoadedPlugin } from '@docusaurus/types';
11
11
  export declare function formatStatsErrorMessage(statsJson: ReturnType<webpack.Stats['toJson']> | undefined): string | undefined;
12
12
  export declare function printStatsWarnings(statsJson: ReturnType<webpack.Stats['toJson']> | undefined): void;
13
13
  export declare function getStyleLoaders(isServer: boolean, cssOptionsArg?: {
@@ -33,15 +33,24 @@ export declare const getCustomizableJSLoader: (jsLoader?: "babel" | ((isServer:
33
33
  */
34
34
  export declare function applyConfigureWebpack(configureWebpack: NonNullable<Plugin['configureWebpack']>, config: Configuration, isServer: boolean, jsLoader: 'babel' | ((isServer: boolean) => RuleSetRule) | undefined, content: unknown): Configuration;
35
35
  export declare function applyConfigurePostCss(configurePostCss: NonNullable<Plugin['configurePostCss']>, config: Configuration): Configuration;
36
+ export declare function executePluginsConfigurePostCss({ plugins, config, }: {
37
+ plugins: LoadedPlugin[];
38
+ config: Configuration;
39
+ }): Configuration;
40
+ export declare function executePluginsConfigureWebpack({ plugins, config, isServer, jsLoader, }: {
41
+ plugins: LoadedPlugin[];
42
+ config: Configuration;
43
+ isServer: boolean;
44
+ jsLoader: 'babel' | ((isServer: boolean) => RuleSetRule) | undefined;
45
+ }): Configuration;
36
46
  declare global {
37
47
  interface Error {
38
48
  /** @see https://webpack.js.org/api/node/#error-handling */
39
49
  details: unknown;
40
50
  }
41
51
  }
42
- export declare function compile(config: Configuration[]): Promise<void>;
52
+ export declare function compile(config: Configuration[]): Promise<webpack.MultiStats>;
43
53
  export declare function getHttpsConfig(): Promise<boolean | {
44
54
  cert: Buffer;
45
55
  key: Buffer;
46
56
  }>;
47
- export declare function getMinimizer(useSimpleCssMinifier?: boolean): WebpackPluginInstance[];
@@ -6,7 +6,7 @@
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.compile = exports.applyConfigurePostCss = exports.applyConfigureWebpack = exports.getCustomizableJSLoader = exports.getBabelOptions = exports.getCustomBabelConfigFilePath = exports.getStyleLoaders = exports.printStatsWarnings = exports.formatStatsErrorMessage = void 0;
9
+ exports.getHttpsConfig = exports.compile = exports.executePluginsConfigureWebpack = exports.executePluginsConfigurePostCss = exports.applyConfigurePostCss = exports.applyConfigureWebpack = exports.getCustomizableJSLoader = exports.getBabelOptions = exports.getCustomBabelConfigFilePath = exports.getStyleLoaders = exports.printStatsWarnings = exports.formatStatsErrorMessage = void 0;
10
10
  const tslib_1 = require("tslib");
11
11
  const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
12
12
  const path_1 = tslib_1.__importDefault(require("path"));
@@ -16,8 +16,6 @@ const utils_1 = require("@docusaurus/utils");
16
16
  const mini_css_extract_plugin_1 = tslib_1.__importDefault(require("mini-css-extract-plugin"));
17
17
  const webpack_merge_1 = require("webpack-merge");
18
18
  const webpack_1 = tslib_1.__importDefault(require("webpack"));
19
- const terser_webpack_plugin_1 = tslib_1.__importDefault(require("terser-webpack-plugin"));
20
- const css_minimizer_webpack_plugin_1 = tslib_1.__importDefault(require("css-minimizer-webpack-plugin"));
21
19
  const formatWebpackMessages_1 = tslib_1.__importDefault(require("react-dev-utils/formatWebpackMessages"));
22
20
  function formatStatsErrorMessage(statsJson) {
23
21
  if (statsJson?.errors?.length) {
@@ -189,6 +187,31 @@ function applyConfigurePostCss(configurePostCss, config) {
189
187
  return config;
190
188
  }
191
189
  exports.applyConfigurePostCss = applyConfigurePostCss;
190
+ // Plugin Lifecycle - configurePostCss()
191
+ function executePluginsConfigurePostCss({ plugins, config, }) {
192
+ let resultConfig = config;
193
+ plugins.forEach((plugin) => {
194
+ const { configurePostCss } = plugin;
195
+ if (configurePostCss) {
196
+ resultConfig = applyConfigurePostCss(configurePostCss.bind(plugin), resultConfig);
197
+ }
198
+ });
199
+ return resultConfig;
200
+ }
201
+ exports.executePluginsConfigurePostCss = executePluginsConfigurePostCss;
202
+ // Plugin Lifecycle - configureWebpack()
203
+ function executePluginsConfigureWebpack({ plugins, config, isServer, jsLoader, }) {
204
+ let resultConfig = config;
205
+ plugins.forEach((plugin) => {
206
+ const { configureWebpack } = plugin;
207
+ if (configureWebpack) {
208
+ resultConfig = applyConfigureWebpack(configureWebpack.bind(plugin), // The plugin lifecycle may reference `this`.
209
+ resultConfig, isServer, jsLoader, plugin.content);
210
+ }
211
+ });
212
+ return resultConfig;
213
+ }
214
+ exports.executePluginsConfigureWebpack = executePluginsConfigureWebpack;
192
215
  function compile(config) {
193
216
  return new Promise((resolve, reject) => {
194
217
  const compiler = (0, webpack_1.default)(config);
@@ -215,7 +238,7 @@ function compile(config) {
215
238
  reject(errClose);
216
239
  }
217
240
  else {
218
- resolve();
241
+ resolve(stats);
219
242
  }
220
243
  });
221
244
  });
@@ -269,82 +292,3 @@ async function getHttpsConfig() {
269
292
  return isHttps;
270
293
  }
271
294
  exports.getHttpsConfig = getHttpsConfig;
272
- // See https://github.com/webpack-contrib/terser-webpack-plugin#parallel
273
- function getTerserParallel() {
274
- let terserParallel = true;
275
- if (process.env.TERSER_PARALLEL === 'false') {
276
- terserParallel = false;
277
- }
278
- else if (process.env.TERSER_PARALLEL &&
279
- parseInt(process.env.TERSER_PARALLEL, 10) > 0) {
280
- terserParallel = parseInt(process.env.TERSER_PARALLEL, 10);
281
- }
282
- return terserParallel;
283
- }
284
- function getMinimizer(useSimpleCssMinifier = false) {
285
- const minimizer = [
286
- new terser_webpack_plugin_1.default({
287
- parallel: getTerserParallel(),
288
- terserOptions: {
289
- parse: {
290
- // We want uglify-js to parse ecma 8 code. However, we don't want it
291
- // to apply any minification steps that turns valid ecma 5 code
292
- // into invalid ecma 5 code. This is why the 'compress' and 'output'
293
- // sections only apply transformations that are ecma 5 safe
294
- // https://github.com/facebook/create-react-app/pull/4234
295
- ecma: 2020,
296
- },
297
- compress: {
298
- ecma: 5,
299
- },
300
- mangle: {
301
- safari10: true,
302
- },
303
- output: {
304
- ecma: 5,
305
- comments: false,
306
- // Turned on because emoji and regex is not minified properly using
307
- // default. See https://github.com/facebook/create-react-app/issues/2488
308
- ascii_only: true,
309
- },
310
- },
311
- }),
312
- ];
313
- if (useSimpleCssMinifier) {
314
- minimizer.push(new css_minimizer_webpack_plugin_1.default());
315
- }
316
- else {
317
- minimizer.push(
318
- // Using the array syntax to add 2 minimizers
319
- // see https://github.com/webpack-contrib/css-minimizer-webpack-plugin#array
320
- new css_minimizer_webpack_plugin_1.default({
321
- minimizerOptions: [
322
- // CssNano options
323
- {
324
- preset: require.resolve('@docusaurus/cssnano-preset'),
325
- },
326
- // CleanCss options
327
- {
328
- inline: false,
329
- level: {
330
- 1: {
331
- all: false,
332
- removeWhitespace: true,
333
- },
334
- 2: {
335
- all: true,
336
- restructureRules: true,
337
- removeUnusedAtRules: false,
338
- },
339
- },
340
- },
341
- ],
342
- minify: [
343
- css_minimizer_webpack_plugin_1.default.cssnanoMinify,
344
- css_minimizer_webpack_plugin_1.default.cleanCssMinify,
345
- ],
346
- }));
347
- }
348
- return minimizer;
349
- }
350
- exports.getMinimizer = getMinimizer;
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": "0.0.0-5823",
4
+ "version": "0.0.0-5828",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -43,14 +43,13 @@
43
43
  "@babel/runtime": "^7.22.6",
44
44
  "@babel/runtime-corejs3": "^7.22.6",
45
45
  "@babel/traverse": "^7.22.8",
46
- "@docusaurus/cssnano-preset": "0.0.0-5823",
47
- "@docusaurus/logger": "0.0.0-5823",
48
- "@docusaurus/mdx-loader": "0.0.0-5823",
46
+ "@docusaurus/cssnano-preset": "0.0.0-5828",
47
+ "@docusaurus/logger": "0.0.0-5828",
48
+ "@docusaurus/mdx-loader": "0.0.0-5828",
49
49
  "@docusaurus/react-loadable": "5.5.2",
50
- "@docusaurus/utils": "0.0.0-5823",
51
- "@docusaurus/utils-common": "0.0.0-5823",
52
- "@docusaurus/utils-validation": "0.0.0-5823",
53
- "@slorber/static-site-generator-webpack-plugin": "^4.0.7",
50
+ "@docusaurus/utils": "0.0.0-5828",
51
+ "@docusaurus/utils-common": "0.0.0-5828",
52
+ "@docusaurus/utils-validation": "0.0.0-5828",
54
53
  "@svgr/webpack": "^6.5.1",
55
54
  "autoprefixer": "^10.4.14",
56
55
  "babel-loader": "^9.1.3",
@@ -71,6 +70,7 @@
71
70
  "detect-port": "^1.5.1",
72
71
  "escape-html": "^1.0.3",
73
72
  "eta": "^2.2.0",
73
+ "eval": "^0.1.8",
74
74
  "file-loader": "^6.2.0",
75
75
  "fs-extra": "^11.1.1",
76
76
  "html-minifier-terser": "^7.2.0",
@@ -79,6 +79,7 @@
79
79
  "leven": "^3.1.0",
80
80
  "lodash": "^4.17.21",
81
81
  "mini-css-extract-plugin": "^2.7.6",
82
+ "p-map": "^4.0.0",
82
83
  "postcss": "^8.4.26",
83
84
  "postcss-loader": "^7.3.3",
84
85
  "prompts": "^2.4.2",
@@ -104,8 +105,8 @@
104
105
  "webpackbar": "^5.0.2"
105
106
  },
106
107
  "devDependencies": {
107
- "@docusaurus/module-type-aliases": "0.0.0-5823",
108
- "@docusaurus/types": "0.0.0-5823",
108
+ "@docusaurus/module-type-aliases": "0.0.0-5828",
109
+ "@docusaurus/types": "0.0.0-5828",
109
110
  "@types/detect-port": "^1.3.3",
110
111
  "@types/react-dom": "^18.2.7",
111
112
  "@types/react-router-config": "^5.0.7",
@@ -124,5 +125,5 @@
124
125
  "engines": {
125
126
  "node": ">=18.0"
126
127
  },
127
- "gitHead": "bf05b822f7070a55366ccfd68f8f73c969363835"
128
+ "gitHead": "16fd157785a56e88f361f7ff8667c18511dc0a1b"
128
129
  }