@docusaurus/bundler 4.0.0-canary-7001 → 4.0.0-canary-7002

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.
@@ -5,19 +5,15 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import { type TransformOptions } from 'lightningcss';
8
- import type { CurrentBundler } from '@docusaurus/types';
9
8
  /**
10
9
  * The targets the client or server bundle is compiled for, like
11
10
  * `['chrome 120', 'firefox 115']` or `['node 24.11.1']`
12
11
  */
13
- export declare function getTargets({ isServer, bundlerName, }: {
12
+ export declare function getTargets({ isServer }: {
14
13
  isServer: boolean;
15
- bundlerName: CurrentBundler['name'];
16
14
  }): string[];
17
15
  export declare function getClientQueries(): string[];
18
- export declare function getServerTargets({ bundlerName, }: {
19
- bundlerName: CurrentBundler['name'];
20
- }): string[];
16
+ export declare function getServerTargets(): string[];
21
17
  type LightningCssMinimizerOptions = Omit<TransformOptions<never>, 'filename' | 'code'>;
22
18
  export declare function getLightningCssMinimizerOptions(): LightningCssMinimizerOptions;
23
19
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"browserslist.d.ts","sourceRoot":"","sources":["../src/browserslist.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAwB,KAAK,gBAAgB,EAAC,MAAM,cAAc,CAAC;AAC1E,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAMtD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,EACzB,QAAQ,EACR,WAAW,GACZ,EAAE;IACD,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;CACrC,GAAG,MAAM,EAAE,CAEX;AAED,wBAAgB,gBAAgB,IAAI,MAAM,EAAE,CAI3C;AAUD,wBAAgB,gBAAgB,CAAC,EAC/B,WAAW,GACZ,EAAE;IACD,WAAW,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;CACrC,GAAG,MAAM,EAAE,CAYX;AAwBD,KAAK,4BAA4B,GAAG,IAAI,CACtC,gBAAgB,CAAC,KAAK,CAAC,EACvB,UAAU,GAAG,MAAM,CACpB,CAAC;AAEF,wBAAgB,+BAA+B,IAAI,4BAA4B,CAE9E"}
1
+ {"version":3,"file":"browserslist.d.ts","sourceRoot":"","sources":["../src/browserslist.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAwB,KAAK,gBAAgB,EAAC,MAAM,cAAc,CAAC;AAM1E;;;GAGG;AACH,wBAAgB,UAAU,CAAC,EAAC,QAAQ,EAAC,EAAE;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAC,GAAG,MAAM,EAAE,CAEpE;AAED,wBAAgB,gBAAgB,IAAI,MAAM,EAAE,CAI3C;AAYD,wBAAgB,gBAAgB,IAAI,MAAM,EAAE,CAQ3C;AAKD,KAAK,4BAA4B,GAAG,IAAI,CACtC,gBAAgB,CAAC,KAAK,CAAC,EACvB,UAAU,GAAG,MAAM,CACpB,CAAC;AAEF,wBAAgB,+BAA+B,IAAI,4BAA4B,CAE9E"}
@@ -21,8 +21,8 @@ const DefaultBrowserslistQueries = ['baseline widely available'];
21
21
  * The targets the client or server bundle is compiled for, like
22
22
  * `['chrome 120', 'firefox 115']` or `['node 24.11.1']`
23
23
  */
24
- function getTargets({ isServer, bundlerName, }) {
25
- return isServer ? getServerTargets({ bundlerName }) : getClientTargets();
24
+ function getTargets({ isServer }) {
25
+ return isServer ? getServerTargets() : getClientTargets();
26
26
  }
27
27
  function getClientQueries() {
28
28
  return (browserslist_1.default.loadConfig({ path: process.cwd() }) ?? DefaultBrowserslistQueries);
@@ -34,30 +34,16 @@ function getClientQueries() {
34
34
  function getClientTargets() {
35
35
  return (0, browserslist_1.default)(getClientQueries());
36
36
  }
37
- function getServerTargets({ bundlerName, }) {
37
+ // SWC skips all transforms for Node versions newer than its Browserslist data
38
+ // See https://github.com/swc-project/swc/pull/11457
39
+ function getServerTargets() {
38
40
  // Escape hatch env variable
39
41
  if (process.env.DOCUSAURUS_SERVER_NODE_TARGET) {
40
42
  return [`node ${process.env.DOCUSAURUS_SERVER_NODE_TARGET}`];
41
43
  }
42
- // For server builds, we want to use the current Node version as target
43
- // But we can't pass a target that Browserslist doesn't know about yet
44
- const nodeTarget = getMinVersion(process.versions.node, getLastBrowserslistKnownNodeVersion(bundlerName));
45
- return [`node ${nodeTarget}`];
46
- }
47
- // TODO this is not accurate
48
- // for Rspack we should read from the built-in browserslist data
49
- // see https://github.com/facebook/docusaurus/pull/11496
50
- function getLastBrowserslistKnownNodeVersion(bundlerName) {
51
- if (bundlerName === 'rspack') {
52
- // TODO hardcoded value until Rspack exposes its Browserslist data
53
- // see https://github.com/facebook/docusaurus/pull/11496
54
- return '26.0.0';
55
- }
56
- // browserslist('last 1 node versions')[0]!.replace('node ', '')
57
- return browserslist_1.default.nodeVersions.at(-1);
58
- }
59
- function getMinVersion(v1, v2) {
60
- return semver_1.default.lt(v1, v2) ? v1 : v2;
44
+ // SWC panics on pre-release versions like "27.0.0-rc.1"
45
+ const nodeVersion = semver_1.default.coerce(process.versions.node).version;
46
+ return [`node ${nodeVersion}`];
61
47
  }
62
48
  function getLightningCssMinimizerOptions() {
63
49
  return { targets: (0, lightningcss_1.browserslistToTargets)(getClientTargets()) };
@@ -1 +1 @@
1
- {"version":3,"file":"browserslist.js","sourceRoot":"","sources":["../src/browserslist.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;AAEH,wEAAwC;AACxC,4DAA4B;AAC5B,+CAA0E;AAG1E,iEAAiE;AACjE,+BAA+B;AAC/B,MAAM,0BAA0B,GAAG,CAAC,2BAA2B,CAAC,CAAC;AAEjE;;;GAGG;AACH,oBAA2B,EACzB,QAAQ,EACR,WAAW,GAIZ;IACC,OAAO,QAAQ,CAAC,CAAC,CAAC,gBAAgB,CAAC,EAAC,WAAW,EAAC,CAAC,CAAC,CAAC,CAAC,gBAAgB,EAAE,CAAC;A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slist.js","sourceRoot":"","sources":["../src/browserslist.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;AAEH,wEAAwC;AACxC,4DAA4B;AAC5B,+CAA0E;AAE1E,iEAAiE;AACjE,+BAA+B;AAC/B,MAAM,0BAA0B,GAAG,CAAC,2BAA2B,CAAC,CAAC;AAEjE;;;GAGG;AACH,oBAA2B,EAAC,QAAQ,EAAsB;IACxD,OAAO,QAAQ,CAAC,CAAC,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC,gBAAgB,EAAE,CAAC;AAC5D,CAAC;AAED;IACE,OAAO,CACL,sBAAY,CAAC,UAAU,CAAC,EAAC,IAAI,EAAE,OAAO,CAAC,GAAG,EAAE,EAAC,CAAC,IAAI,0BAA0B,CAC7E,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAS,gBAAgB;IACvB,OAAO,IAAA,sBAAY,EAAC,gBAAgB,EAAE,CAAC,CAAC;AAC1C,CAAC;AAED,8EAA8E;AAC9E,oDAAoD;AACpD;IACE,4BAA4B;IAC5B,IAAI,OAAO,CAAC,GAAG,CAAC,6BAA6B,EAAE,CAAC;QAC9C,OAAO,CAAC,QAAQ,OAAO,CAAC,GAAG,CAAC,6BAA6B,EAAE,CAAC,CAAC;IAC/D,CAAC;IACD,wDAAwD;IACxD,MAAM,WAAW,GAAG,gBAAM,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAE,CAAC,OAAO,CAAC;IAClE,OAAO,CAAC,QAAQ,WAAW,EAAE,CAAC,CAAC;AACjC,CAAC;AAUD;IACE,OAAO,EAAC,OAAO,EAAE,IAAA,oCAAqB,EAAC,gBAAgB,EAAE,CAAC,EAAC,CAAC;AAC9D,CAAC"}
@@ -24,7 +24,7 @@ function createRspackSwcJsLoaderFactory() {
24
24
  return ({ isServer }) => {
25
25
  return {
26
26
  loader,
27
- options: (0, swc_1.getSwcLoaderOptions)({ isServer, bundlerName: 'rspack' }),
27
+ options: (0, swc_1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AAU,CAAC,OAAO,EAAE,QAAQ,IAAI,OAAO,CAAC;IACzD,IAAI,QAAQ,YAAY,QAAQ,EAAE,CAAC;QACjC,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,IAAI,QAAQ,KAAK,OAAO,EAAE,CAAC;QACzB,OAAO,0BAA0B,CAAC,EAAC,OAAO,EAAC,CAAC,CAAC;IAC/C,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,4CAA4C,QAAQ,EAAE,CAAC,CAAC;AAC1E,CAAC"}
package/lib/swc.d.ts CHANGED
@@ -5,9 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import type { SwcLoaderOptions } from '@rspack/core';
8
- import type { CurrentBundler } from '@docusaurus/types';
9
- export declare function getSwcLoaderOptions({ isServer, bundlerName, }: {
8
+ export declare function getSwcLoaderOptions({ isServer, }: {
10
9
  isServer: boolean;
11
- bundlerName: CurrentBundler['name'];
12
10
  }): SwcLoaderOptions;
13
11
  //# sourceMappingURL=swc.d.ts.map
package/lib/swc.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"swc.d.ts","sourceRoot":"","sources":["../src/swc.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAEtD,wBAAgB,mBAAmB,CAAC,EAClC,QAAQ,EACR,WAAW,GACZ,EAAE;IACD,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;CACrC,GAAG,gBAAgB,CAuBnB"}
1
+ {"version":3,"file":"swc.d.ts","sourceRoot":"","sources":["../src/swc.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,cAAc,CAAC;AAEnD,wBAAgB,mBAAmB,CAAC,EAClC,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,OAAO,CAAC;CACnB,GAAG,gBAAgB,CAuBnB"}
package/lib/swc.js CHANGED
@@ -8,11 +8,11 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.getSwcLoaderOptions = getSwcLoaderOptions;
10
10
  const browserslist_1 = require("./browserslist");
11
- function getSwcLoaderOptions({ isServer, bundlerName, }) {
11
+ function getSwcLoaderOptions({ isServer, }) {
12
12
  return {
13
13
  env: {
14
14
  // Rspack resolves the client queries with its own Browserslist data
15
- targets: isServer ? (0, browserslist_1.getServerTargets)({ bundlerName }) : (0, browserslist_1.getClientQueries)(),
15
+ targets: isServer ? (0, browserslist_1.getServerTargets)() : (0, browserslist_1.getClientQueries)(),
16
16
  },
17
17
  jsc: {
18
18
  parser: {
package/lib/swc.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"swc.js","sourceRoot":"","sources":["../src/swc.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,iDAAkE;AAIlE,6BAAoC,EAClC,QAAQ,EACR,WAAW,GAIZ;IACC,OAAO;QACL,GAAG,EAAE;YACH,oEAAoE;YACpE,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,IAAA,+BAAgB,EAAC,EAAC,WAAW,EAAC,CAAC,CAAC,CAAC,CAAC,IAAA,+BAAgB,GAAE;SACzE;QACD,GAAG,EAAE;YACH,MAAM,EAAE;gBACN,MAAM,EAAE,YAAY;gBACpB,GAAG,EAAE,IAAI;aACV;YACD,SAAS,EAAE;gBACT,KAAK,EAAE;oBACL,OAAO,EAAE,WAAW;iBACrB;aACF;YACD,YAAY,EAAE;gBACZ,oDAAoD;gBACpD,kDAAkD;gBAClD,oBAAoB,EAAE,IAAI;aAC3B;SACF;KACF,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"swc.js","sourceRoot":"","sources":["../src/swc.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,iDAAkE;AAGlE,6BAAoC,EAClC,QAAQ,GAGT;IACC,OAAO;QACL,GAAG,EAAE;YACH,oEAAoE;YACpE,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,IAAA,+BAAgB,GAAE,CAAC,CAAC,CAAC,IAAA,+BAAgB,GAAE;SAC5D;QACD,GAAG,EAAE;YACH,MAAM,EAAE;gBACN,MAAM,EAAE,YAAY;gBACpB,GAAG,EAAE,IAAI;aACV;YACD,SAAS,EAAE;gBACT,KAAK,EAAE;oBACL,OAAO,EAAE,WAAW;iBACrB;aACF;YACD,YAAY,EAAE;gBACZ,oDAAoD;gBACpD,kDAAkD;gBAClD,oBAAoB,EAAE,IAAI;aAC3B;SACF;KACF,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/bundler",
3
- "version": "4.0.0-canary-7001",
3
+ "version": "4.0.0-canary-7002",
4
4
  "description": "Docusaurus util package to abstract the current bundler.",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -15,9 +15,9 @@
15
15
  "license": "MIT",
16
16
  "dependencies": {
17
17
  "@babel/core": "^7.29.7",
18
- "@docusaurus/babel": "4.0.0-canary-7001",
19
- "@docusaurus/logger": "4.0.0-canary-7001",
20
- "@docusaurus/types": "4.0.0-canary-7001",
18
+ "@docusaurus/babel": "4.0.0-canary-7002",
19
+ "@docusaurus/logger": "4.0.0-canary-7002",
20
+ "@docusaurus/types": "4.0.0-canary-7002",
21
21
  "@rspack/core": "^2.2.3",
22
22
  "@rspack/dev-server": "^2.2.1",
23
23
  "@swc/html": "^1.16.2",
@@ -8,7 +8,6 @@
8
8
  import browserslist from 'browserslist';
9
9
  import semver from 'semver';
10
10
  import {browserslistToTargets, type TransformOptions} from 'lightningcss';
11
- import type {CurrentBundler} from '@docusaurus/types';
12
11
 
13
12
  // Used when the site doesn't provide its own Browserslist config
14
13
  // See https://web.dev/baseline
@@ -18,14 +17,8 @@ const DefaultBrowserslistQueries = ['baseline widely available'];
18
17
  * The targets the client or server bundle is compiled for, like
19
18
  * `['chrome 120', 'firefox 115']` or `['node 24.11.1']`
20
19
  */
21
- export function getTargets({
22
- isServer,
23
- bundlerName,
24
- }: {
25
- isServer: boolean;
26
- bundlerName: CurrentBundler['name'];
27
- }): string[] {
28
- return isServer ? getServerTargets({bundlerName}) : getClientTargets();
20
+ export function getTargets({isServer}: {isServer: boolean}): string[] {
21
+ return isServer ? getServerTargets() : getClientTargets();
29
22
  }
30
23
 
31
24
  export function getClientQueries(): string[] {
@@ -42,41 +35,16 @@ function getClientTargets(): string[] {
42
35
  return browserslist(getClientQueries());
43
36
  }
44
37
 
45
- export function getServerTargets({
46
- bundlerName,
47
- }: {
48
- bundlerName: CurrentBundler['name'];
49
- }): string[] {
38
+ // SWC skips all transforms for Node versions newer than its Browserslist data
39
+ // See https://github.com/swc-project/swc/pull/11457
40
+ export function getServerTargets(): string[] {
50
41
  // Escape hatch env variable
51
42
  if (process.env.DOCUSAURUS_SERVER_NODE_TARGET) {
52
43
  return [`node ${process.env.DOCUSAURUS_SERVER_NODE_TARGET}`];
53
44
  }
54
- // For server builds, we want to use the current Node version as target
55
- // But we can't pass a target that Browserslist doesn't know about yet
56
- const nodeTarget = getMinVersion(
57
- process.versions.node,
58
- getLastBrowserslistKnownNodeVersion(bundlerName),
59
- );
60
- return [`node ${nodeTarget}`];
61
- }
62
-
63
- // TODO this is not accurate
64
- // for Rspack we should read from the built-in browserslist data
65
- // see https://github.com/facebook/docusaurus/pull/11496
66
- function getLastBrowserslistKnownNodeVersion(
67
- bundlerName: CurrentBundler['name'],
68
- ): string {
69
- if (bundlerName === 'rspack') {
70
- // TODO hardcoded value until Rspack exposes its Browserslist data
71
- // see https://github.com/facebook/docusaurus/pull/11496
72
- return '26.0.0';
73
- }
74
- // browserslist('last 1 node versions')[0]!.replace('node ', '')
75
- return browserslist.nodeVersions.at(-1)!;
76
- }
77
-
78
- function getMinVersion(v1: string, v2: string): string {
79
- return semver.lt(v1, v2) ? v1 : v2;
45
+ // SWC panics on pre-release versions like "27.0.0-rc.1"
46
+ const nodeVersion = semver.coerce(process.versions.node)!.version;
47
+ return [`node ${nodeVersion}`];
80
48
  }
81
49
 
82
50
  // LightningCSS doesn't expose any type for minimizer-webpack-plugin setup
@@ -29,7 +29,7 @@ function createRspackSwcJsLoaderFactory(): ConfigureWebpackUtils['getJSLoader']
29
29
  return ({isServer}) => {
30
30
  return {
31
31
  loader,
32
- options: getSwcLoaderOptions({isServer, bundlerName: 'rspack'}),
32
+ options: getSwcLoaderOptions({isServer}),
33
33
  };
34
34
  };
35
35
  }
package/src/swc.ts CHANGED
@@ -7,19 +7,16 @@
7
7
 
8
8
  import {getClientQueries, getServerTargets} from './browserslist';
9
9
  import type {SwcLoaderOptions} from '@rspack/core';
10
- import type {CurrentBundler} from '@docusaurus/types';
11
10
 
12
11
  export function getSwcLoaderOptions({
13
12
  isServer,
14
- bundlerName,
15
13
  }: {
16
14
  isServer: boolean;
17
- bundlerName: CurrentBundler['name'];
18
15
  }): SwcLoaderOptions {
19
16
  return {
20
17
  env: {
21
18
  // Rspack resolves the client queries with its own Browserslist data
22
- targets: isServer ? getServerTargets({bundlerName}) : getClientQueries(),
19
+ targets: isServer ? getServerTargets() : getClientQueries(),
23
20
  },
24
21
  jsc: {
25
22
  parser: {