@docusaurus/bundler 4.0.0-canary-6918 → 4.0.0-canary-6920

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.
@@ -1 +1 @@
1
- {"version":3,"file":"minification.d.ts","sourceRoot":"","sources":["../src/minification.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAYH,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,SAAS,CAAC;AACnD,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAEtD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,cAAc,EAAE,cAAc,CAAC;CAChC,CAAC;AAoFF,wBAAsB,aAAa,CACjC,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,qBAAqB,EAAE,CAAC,CAKlC"}
1
+ {"version":3,"file":"minification.d.ts","sourceRoot":"","sources":["../src/minification.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAcH,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,SAAS,CAAC;AACnD,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAEtD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,cAAc,EAAE,cAAc,CAAC;CAChC,CAAC;AAmGF,wBAAsB,aAAa,CACjC,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,qBAAqB,EAAE,CAAC,CAKlC"}
@@ -7,6 +7,8 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.getMinimizers = getMinimizers;
10
+ const tslib_1 = require("tslib");
11
+ const node_path_1 = tslib_1.__importDefault(require("node:path"));
10
12
  const rspack_1 = require("./rspack");
11
13
  const browserslist_1 = require("./browserslist");
12
14
  // Shared by Webpack and Rspack, compatible with both SWC and Rspack types
@@ -26,32 +28,48 @@ const SwcJsMinimizerOptions = {
26
28
  ascii_only: true,
27
29
  },
28
30
  };
29
- // See https://github.com/webpack-contrib/terser-webpack-plugin#parallel
30
- function getTerserParallel() {
31
- let terserParallel = true;
32
- if (process.env.TERSER_PARALLEL === 'false') {
33
- terserParallel = false;
31
+ // Escape hatch to disable or limit the minimizer worker processes
32
+ // For CI environments that don't report their real number of CPUs
33
+ // See https://github.com/webpack/minimizer-webpack-plugin#parallel
34
+ function getMinimizerParallel() {
35
+ const value = process.env.DOCUSAURUS_BUNDLER_MINIMIZER_PARALLEL;
36
+ if (value === 'false') {
37
+ return false;
34
38
  }
35
- else if (process.env.TERSER_PARALLEL &&
36
- parseInt(process.env.TERSER_PARALLEL, 10) > 0) {
37
- terserParallel = parseInt(process.env.TERSER_PARALLEL, 10);
38
- }
39
- return terserParallel;
39
+ const workers = parseInt(value ?? '', 10);
40
+ return workers > 0 ? workers : true;
41
+ }
42
+ // Minify functions are referenced by module path, so that the plugin's
43
+ // worker processes can require them
44
+ // The extension is .ts when running tests on source files
45
+ // See https://github.com/webpack/minimizer-webpack-plugin#minify
46
+ function getMinifyFunction(name) {
47
+ const extension = node_path_1.default.extname(__filename);
48
+ return {
49
+ path: node_path_1.default.join(__dirname, `minifyFunctions${extension}`),
50
+ export: name,
51
+ };
40
52
  }
41
- // Terser is not used: terser-webpack-plugin only runs the SWC minifier
42
53
  async function getJsMinimizer() {
43
- const { default: TerserPlugin } = await import('terser-webpack-plugin');
44
- return new TerserPlugin({
45
- parallel: getTerserParallel(),
46
- minify: TerserPlugin.swcMinify,
47
- terserOptions: { ...SwcJsMinimizerOptions, safari10: true },
54
+ const { default: MinimizerPlugin } = await import('minimizer-webpack-plugin');
55
+ return new MinimizerPlugin({
56
+ parallel: getMinimizerParallel(),
57
+ minify: {
58
+ implementation: getMinifyFunction('swcMinify'),
59
+ options: { ...SwcJsMinimizerOptions, safari10: true },
60
+ },
48
61
  });
49
62
  }
50
63
  async function getCssMinimizer() {
51
- const { default: CssMinimizerPlugin } = await import('css-minimizer-webpack-plugin');
52
- return new CssMinimizerPlugin({
53
- minify: CssMinimizerPlugin.lightningCssMinify,
54
- minimizerOptions: (0, browserslist_1.getLightningCssMinimizerOptions)(),
64
+ const { default: MinimizerPlugin } = await import('minimizer-webpack-plugin');
65
+ return new MinimizerPlugin({
66
+ // The plugin's default test only matches JS files
67
+ test: /\.css(?:\?.*)?$/i,
68
+ parallel: getMinimizerParallel(),
69
+ minify: {
70
+ implementation: getMinifyFunction('lightningCssMinify'),
71
+ options: (0, browserslist_1.getLightningCssMinimizerOptions)(),
72
+ },
55
73
  });
56
74
  }
57
75
  // Webpack-only minimizers are imported lazily, only when Webpack is used
@@ -1 +1 @@
1
- {"version":3,"file":"minification.js","sourceRoot":"","sources":["../src/minification.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,qCAAgC;AAChC,iDAGwB;AAiBxB,0EAA0E;AAC1E,8DAA8D;AAC9D,qDAAqD;AACrD,uFAAuF;AACvF,MAAM,qBAAqB,GAAG;IAC5B,IAAI,EAAE,IAAI;IACV,QAAQ,EAAE;QACR,IAAI,EAAE,CAAC;KACR;IACD,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE;QACN,IAAI,EAAE,CAAC;QACP,QAAQ,EAAE,KAAK;QACf,UAAU,EAAE,IAAI;KACjB;CAC6C,CAAC;AAEjD,wEAAwE;AACxE,SAAS,iBAAiB;IACxB,IAAI,cAAc,GAAqB,IAAI,CAAC;IAC5C,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe,KAAK,OAAO,EAAE,CAAC;QAC5C,cAAc,GAAG,KAAK,CAAC;IACzB,CAAC;SAAM,IACL,OAAO,CAAC,GAAG,CAAC,eAAe;QAC3B,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,EAAE,CAAC,GAAG,CAAC,EAC7C,CAAC;QACD,cAAc,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;IAC7D,CAAC;IACD,OAAO,cAAc,CAAC;AACxB,CAAC;AAED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AAC,cAAc,CAAC,IAAI,KAAK,QAAQ;QAC5C,CAAC,CAAC,0DAA0D;YACzD,mBAAmB,EAAyC;QAC/D,CAAC,CAAC,oBAAoB,EAAE,CAAC;AAC7B,CAAC"}
@@ -0,0 +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
+ */
7
+ import MinimizerPlugin from 'minimizer-webpack-plugin';
8
+ export declare const swcMinify: typeof MinimizerPlugin.swcMinify;
9
+ export declare const lightningCssMinify: typeof MinimizerPlugin.lightningCssMinify;
10
+ //# sourceMappingURL=minifyFunctions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"minifyFunctions.d.ts","sourceRoot":"","sources":["../src/minifyFunctions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,eAAe,MAAM,0BAA0B,CAAC;AAcvD,eAAO,MAAM,SAAS,kCAAmD,CAAC;AAE1E,eAAO,MAAM,kBAAkB,2CAE9B,CAAC"}
@@ -0,0 +1,23 @@
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.lightningCssMinify = exports.swcMinify = void 0;
10
+ const tslib_1 = require("tslib");
11
+ const minimizer_webpack_plugin_1 = tslib_1.__importDefault(require("minimizer-webpack-plugin"));
12
+ // The minimizer-webpack-plugin built-in minify functions, without getTypes()
13
+ // Otherwise, the plugin also minifies the source that modules embed in JS
14
+ // Text imports (with {type: 'text'}) must remain the raw file content
15
+ // See https://github.com/webpack/minimizer-webpack-plugin#embedded-source
16
+ function withoutEmbeddedSource(minify) {
17
+ const copy = (...args) => minify(...args);
18
+ return Object.assign(copy, minify, { getTypes: undefined });
19
+ }
20
+ // Required by module path in the plugin's worker processes
21
+ exports.swcMinify = withoutEmbeddedSource(minimizer_webpack_plugin_1.default.swcMinify);
22
+ exports.lightningCssMinify = withoutEmbeddedSource(minimizer_webpack_plugin_1.default.lightningCssMinify);
23
+ //# sourceMappingURL=minifyFunctions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"minifyFunctions.js","sourceRoot":"","sources":["../src/minifyFunctions.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,gGAAuD;AAEvD,6EAA6E;AAC7E,0EAA0E;AAC1E,sEAAsE;AACtE,0EAA0E;AAC1E,SAAS,qBAAqB,CAC5B,MAAU;IAEV,MAAM,IAAI,GAAG,CAAC,GAAG,IAAoB,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;IAC1D,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,EAAC,QAAQ,EAAE,SAAS,EAAC,CAAkB,CAAC;AAC7E,CAAC;AAED,2DAA2D;AAC9C,QAAA,SAAS,GAAG,qBAAqB,CAAC,kCAAe,CAAC,SAAS,CAAC,CAAC;AAE7D,QAAA,kBAAkB,GAAG,qBAAqB,CACrD,kCAAe,CAAC,kBAAkB,CACnC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/bundler",
3
- "version": "4.0.0-canary-6918",
3
+ "version": "4.0.0-canary-6920",
4
4
  "description": "Docusaurus util package to abstract the current bundler.",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -19,9 +19,9 @@
19
19
  "license": "MIT",
20
20
  "dependencies": {
21
21
  "@babel/core": "^7.29.7",
22
- "@docusaurus/babel": "4.0.0-canary-6918",
23
- "@docusaurus/logger": "4.0.0-canary-6918",
24
- "@docusaurus/types": "4.0.0-canary-6918",
22
+ "@docusaurus/babel": "4.0.0-canary-6920",
23
+ "@docusaurus/logger": "4.0.0-canary-6920",
24
+ "@docusaurus/types": "4.0.0-canary-6920",
25
25
  "@rspack/core": "^2.2.3",
26
26
  "@rspack/dev-server": "^2.2.1",
27
27
  "@swc/core": "^1.16.2",
@@ -29,14 +29,13 @@
29
29
  "babel-loader": "^10.1.1",
30
30
  "browserslist": "^4.29.0",
31
31
  "css-loader": "^7.1.5",
32
- "css-minimizer-webpack-plugin": "^8.0.0",
33
32
  "lightningcss": "^1.33.0",
34
33
  "mini-css-extract-plugin": "^2.10.2",
34
+ "minimizer-webpack-plugin": "^5.13.0",
35
35
  "postcss": "^8.5.28",
36
36
  "postcss-loader": "^8.2.1",
37
37
  "postcss-preset-env": "^11.5.2",
38
38
  "semver": "^7.8.5",
39
- "terser-webpack-plugin": "^5.6.1",
40
39
  "tslib": "^2.8.1",
41
40
  "webpack": "^5.111.0",
42
41
  "webpackbar": "^7.0.0"
@@ -44,5 +43,5 @@
44
43
  "engines": {
45
44
  "node": ">=24.21"
46
45
  },
47
- "gitHead": "812d66312c93686793fe1b9e0db312ef0badd1f8"
46
+ "gitHead": "ac8fb402a42d544a64148417a93c375edc88e15a"
48
47
  }
@@ -18,7 +18,7 @@ export function getBrowserslistQueries(): string[] {
18
18
  );
19
19
  }
20
20
 
21
- // LightningCSS doesn't expose any type for css-minimizer-webpack-plugin setup
21
+ // LightningCSS doesn't expose any type for minimizer-webpack-plugin setup
22
22
  // So we derive it ourselves
23
23
  // see https://lightningcss.dev/docs.html#with-webpack
24
24
  type LightningCssMinimizerOptions = Omit<
@@ -5,11 +5,13 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
+ import path from 'node:path';
8
9
  import {rspack} from './rspack';
9
10
  import {
10
11
  getBrowserslistQueries,
11
12
  getLightningCssMinimizerOptions,
12
13
  } from './browserslist';
14
+ import type * as MinifyFunctions from './minifyFunctions';
13
15
  import type {JsMinifyOptions} from '@swc/core';
14
16
  import type {
15
17
  RspackPluginInstance,
@@ -44,36 +46,51 @@ const SwcJsMinimizerOptions = {
44
46
  },
45
47
  } as const satisfies RspackSwcJsMinimizerOptions;
46
48
 
47
- // See https://github.com/webpack-contrib/terser-webpack-plugin#parallel
48
- function getTerserParallel() {
49
- let terserParallel: boolean | number = true;
50
- if (process.env.TERSER_PARALLEL === 'false') {
51
- terserParallel = false;
52
- } else if (
53
- process.env.TERSER_PARALLEL &&
54
- parseInt(process.env.TERSER_PARALLEL, 10) > 0
55
- ) {
56
- terserParallel = parseInt(process.env.TERSER_PARALLEL, 10);
49
+ // Escape hatch to disable or limit the minimizer worker processes
50
+ // For CI environments that don't report their real number of CPUs
51
+ // See https://github.com/webpack/minimizer-webpack-plugin#parallel
52
+ function getMinimizerParallel(): boolean | number {
53
+ const value = process.env.DOCUSAURUS_BUNDLER_MINIMIZER_PARALLEL;
54
+ if (value === 'false') {
55
+ return false;
57
56
  }
58
- return terserParallel;
57
+ const workers = parseInt(value ?? '', 10);
58
+ return workers > 0 ? workers : true;
59
+ }
60
+
61
+ // Minify functions are referenced by module path, so that the plugin's
62
+ // worker processes can require them
63
+ // The extension is .ts when running tests on source files
64
+ // See https://github.com/webpack/minimizer-webpack-plugin#minify
65
+ function getMinifyFunction(name: keyof typeof MinifyFunctions) {
66
+ const extension = path.extname(__filename);
67
+ return {
68
+ path: path.join(__dirname, `minifyFunctions${extension}`),
69
+ export: name,
70
+ };
59
71
  }
60
72
 
61
- // Terser is not used: terser-webpack-plugin only runs the SWC minifier
62
73
  async function getJsMinimizer(): Promise<WebpackPluginInstance> {
63
- const {default: TerserPlugin} = await import('terser-webpack-plugin');
64
- return new TerserPlugin<JsMinifyOptions>({
65
- parallel: getTerserParallel(),
66
- minify: TerserPlugin.swcMinify,
67
- terserOptions: {...SwcJsMinimizerOptions, safari10: true},
74
+ const {default: MinimizerPlugin} = await import('minimizer-webpack-plugin');
75
+ return new MinimizerPlugin<JsMinifyOptions>({
76
+ parallel: getMinimizerParallel(),
77
+ minify: {
78
+ implementation: getMinifyFunction('swcMinify'),
79
+ options: {...SwcJsMinimizerOptions, safari10: true},
80
+ },
68
81
  });
69
82
  }
70
83
 
71
84
  async function getCssMinimizer(): Promise<WebpackPluginInstance> {
72
- const {default: CssMinimizerPlugin} =
73
- await import('css-minimizer-webpack-plugin');
74
- return new CssMinimizerPlugin({
75
- minify: CssMinimizerPlugin.lightningCssMinify,
76
- minimizerOptions: getLightningCssMinimizerOptions(),
85
+ const {default: MinimizerPlugin} = await import('minimizer-webpack-plugin');
86
+ return new MinimizerPlugin({
87
+ // The plugin's default test only matches JS files
88
+ test: /\.css(?:\?.*)?$/i,
89
+ parallel: getMinimizerParallel(),
90
+ minify: {
91
+ implementation: getMinifyFunction('lightningCssMinify'),
92
+ options: getLightningCssMinimizerOptions(),
93
+ },
77
94
  });
78
95
  }
79
96
 
@@ -0,0 +1,26 @@
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
+
8
+ import MinimizerPlugin from 'minimizer-webpack-plugin';
9
+
10
+ // The minimizer-webpack-plugin built-in minify functions, without getTypes()
11
+ // Otherwise, the plugin also minifies the source that modules embed in JS
12
+ // Text imports (with {type: 'text'}) must remain the raw file content
13
+ // See https://github.com/webpack/minimizer-webpack-plugin#embedded-source
14
+ function withoutEmbeddedSource<Fn extends (...args: never[]) => unknown>(
15
+ minify: Fn,
16
+ ): Fn {
17
+ const copy = (...args: Parameters<Fn>) => minify(...args);
18
+ return Object.assign(copy, minify, {getTypes: undefined}) as unknown as Fn;
19
+ }
20
+
21
+ // Required by module path in the plugin's worker processes
22
+ export const swcMinify = withoutEmbeddedSource(MinimizerPlugin.swcMinify);
23
+
24
+ export const lightningCssMinify = withoutEmbeddedSource(
25
+ MinimizerPlugin.lightningCssMinify,
26
+ );