@docusaurus/faster 4.0.0-canary-6855 → 4.0.0-canary-6859
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.
- package/lib/index.d.ts +1 -4
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +21 -20
- package/lib/index.js.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +27 -27
package/lib/index.d.ts
CHANGED
|
@@ -21,10 +21,7 @@ export declare const rspackDevServer: typeof RspackDevServer;
|
|
|
21
21
|
type SwcHtmlMinifier = (typeof import('@swc/html'))['minify'];
|
|
22
22
|
export declare function getSwcHtmlMinifier(): Promise<SwcHtmlMinifier>;
|
|
23
23
|
export declare function getSwcJsMinimizerOptions(): JsMinifyOptions;
|
|
24
|
-
export declare function getBrowserslistQueries(
|
|
25
|
-
isServer: boolean;
|
|
26
|
-
bundlerName: CurrentBundler['name'];
|
|
27
|
-
}): string[];
|
|
24
|
+
export declare function getBrowserslistQueries(): string[];
|
|
28
25
|
type LightningCssMinimizerOptions = Omit<lightningcss.TransformOptions<never>, 'filename' | 'code'>;
|
|
29
26
|
export declare function getLightningCssMinimizerOptions(): LightningCssMinimizerOptions;
|
|
30
27
|
export {};
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAC,eAAe,EAAC,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,YAAY,MAAM,cAAc,CAAC;AAG7C,OAAO,KAAK,EAAC,eAAe,EAAE,OAAO,IAAI,UAAU,EAAC,MAAM,WAAW,CAAC;AACtE,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAEtD,eAAO,MAAM,SAAS,QAAgC,CAAC;AAEvD,eAAO,MAAM,mBAAmB,+BAG7B;IACD,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;CACrC,KAAG,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAC,eAAe,EAAC,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,YAAY,MAAM,cAAc,CAAC;AAG7C,OAAO,KAAK,EAAC,eAAe,EAAE,OAAO,IAAI,UAAU,EAAC,MAAM,WAAW,CAAC;AACtE,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAEtD,eAAO,MAAM,SAAS,QAAgC,CAAC;AAEvD,eAAO,MAAM,mBAAmB,+BAG7B;IACD,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;CACrC,KAAG,UAwBH,CAAC;AAEF,eAAO,MAAM,MAAM;;;CAAS,CAAC;AAE7B,eAAO,MAAM,eAAe,wBAAkB,CAAC;AAE/C,KAAK,eAAe,GAAG,CAAC,cAAc,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;AAM9D,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,eAAe,CAAC,CAGnE;AAMD,wBAAgB,wBAAwB,IAAI,eAAe,CAe1D;AA2CD,wBAAgB,sBAAsB,IAAI,MAAM,EAAE,CAIjD;AAKD,KAAK,4BAA4B,GAAG,IAAI,CACtC,YAAY,CAAC,gBAAgB,CAAC,KAAK,CAAC,EACpC,UAAU,GAAG,MAAM,CACpB,CAAC;AAEF,wBAAgB,+BAA+B,IAAI,4BAA4B,CAI9E"}
|
package/lib/index.js
CHANGED
|
@@ -21,7 +21,9 @@ exports.swcLoader = require.resolve('swc-loader');
|
|
|
21
21
|
const getSwcLoaderOptions = ({ isServer, bundlerName, }) => {
|
|
22
22
|
return {
|
|
23
23
|
env: {
|
|
24
|
-
targets:
|
|
24
|
+
targets: isServer
|
|
25
|
+
? getServerBrowserslistQueries({ bundlerName })
|
|
26
|
+
: getBrowserslistQueries(),
|
|
25
27
|
},
|
|
26
28
|
jsc: {
|
|
27
29
|
parser: {
|
|
@@ -79,7 +81,7 @@ function getLastBrowserslistKnownNodeVersion(bundlerName) {
|
|
|
79
81
|
if (bundlerName === 'rspack') {
|
|
80
82
|
// TODO hardcoded value until Rspack exposes its Browserslist data
|
|
81
83
|
// see https://github.com/facebook/docusaurus/pull/11496
|
|
82
|
-
return '
|
|
84
|
+
return '26.0.0';
|
|
83
85
|
}
|
|
84
86
|
// browserslist('last 1 node versions')[0]!.replace('node ', '')
|
|
85
87
|
return browserslist_1.default.nodeVersions.at(-1);
|
|
@@ -87,26 +89,25 @@ function getLastBrowserslistKnownNodeVersion(bundlerName) {
|
|
|
87
89
|
function getMinVersion(v1, v2) {
|
|
88
90
|
return semver_1.default.lt(v1, v2) ? v1 : v2;
|
|
89
91
|
}
|
|
90
|
-
//
|
|
91
|
-
// See https://
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
// For server builds, we want to use the current Node version as target
|
|
99
|
-
// But we can't pass a target that Browserslist doesn't know about yet
|
|
100
|
-
const nodeTarget = getMinVersion(process.versions.node, getLastBrowserslistKnownNodeVersion(bundlerName));
|
|
101
|
-
return [`node ${nodeTarget}`];
|
|
92
|
+
// Used when the site doesn't provide its own Browserslist config
|
|
93
|
+
// See https://web.dev/baseline
|
|
94
|
+
const DefaultBrowserslistQueries = ['baseline widely available'];
|
|
95
|
+
function getServerBrowserslistQueries({ bundlerName, }) {
|
|
96
|
+
// Escape hatch env variable
|
|
97
|
+
if (process.env.DOCUSAURUS_SERVER_NODE_TARGET) {
|
|
98
|
+
return [`node ${process.env.DOCUSAURUS_SERVER_NODE_TARGET}`];
|
|
102
99
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
return
|
|
100
|
+
// For server builds, we want to use the current Node version as target
|
|
101
|
+
// But we can't pass a target that Browserslist doesn't know about yet
|
|
102
|
+
const nodeTarget = getMinVersion(process.versions.node, getLastBrowserslistKnownNodeVersion(bundlerName));
|
|
103
|
+
return [`node ${nodeTarget}`];
|
|
104
|
+
}
|
|
105
|
+
function getBrowserslistQueries() {
|
|
106
|
+
return (browserslist_1.default.loadConfig({ path: process.cwd() }) ?? DefaultBrowserslistQueries);
|
|
107
107
|
}
|
|
108
108
|
function getLightningCssMinimizerOptions() {
|
|
109
|
-
const queries = (
|
|
110
|
-
|
|
109
|
+
const queries = getBrowserslistQueries();
|
|
110
|
+
const browsers = (0, browserslist_1.default)(queries);
|
|
111
|
+
return { targets: lightningcss.browserslistToTargets(browsers) };
|
|
111
112
|
}
|
|
112
113
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;AAEH,uCAA8C;AAC9C,mDAAmD;AACnD,MAAY,YAAY,iDAAqB;AAC7C,wEAAwC;AACxC,4DAA4B;AAIf,QAAA,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;AAEhD,MAAM,mBAAmB,GAAG,CAAC,EAClC,QAAQ,EACR,WAAW,GAIZ,EAAc,EAAE;IACf,OAAO;QACL,GAAG,EAAE;YACH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;AAEH,uCAA8C;AAC9C,mDAAmD;AACnD,MAAY,YAAY,iDAAqB;AAC7C,wEAAwC;AACxC,4DAA4B;AAIf,QAAA,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;AAEhD,MAAM,mBAAmB,GAAG,CAAC,EAClC,QAAQ,EACR,WAAW,GAIZ,EAAc,EAAE;IACf,OAAO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
|
3
|
+
"version": "4.0.0-canary-6859",
|
|
4
4
|
"description": "Docusaurus experimental package exposing new modern dependencies to make the build faster.",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@docusaurus/types": "4.0.0-canary-
|
|
21
|
+
"@docusaurus/types": "4.0.0-canary-6859",
|
|
22
22
|
"@rspack/core": "^2.2.3",
|
|
23
23
|
"@rspack/dev-server": "^2.2.1",
|
|
24
24
|
"@swc/core": "^1.16.2",
|
|
25
25
|
"@swc/html": "^1.16.2",
|
|
26
|
-
"browserslist": "^4.
|
|
26
|
+
"browserslist": "^4.29.0",
|
|
27
27
|
"lightningcss": "^1.33.0",
|
|
28
28
|
"semver": "^7.8.5",
|
|
29
29
|
"swc-loader": "^0.2.7",
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@docusaurus/types": "*"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "e3da0b4153190a1001ad0c242a684a3201aff6d1"
|
|
40
40
|
}
|
package/src/index.ts
CHANGED
|
@@ -24,7 +24,9 @@ export const getSwcLoaderOptions = ({
|
|
|
24
24
|
}): SwcOptions => {
|
|
25
25
|
return {
|
|
26
26
|
env: {
|
|
27
|
-
targets:
|
|
27
|
+
targets: isServer
|
|
28
|
+
? getServerBrowserslistQueries({bundlerName})
|
|
29
|
+
: getBrowserslistQueries(),
|
|
28
30
|
},
|
|
29
31
|
jsc: {
|
|
30
32
|
parser: {
|
|
@@ -90,7 +92,7 @@ function getLastBrowserslistKnownNodeVersion(
|
|
|
90
92
|
if (bundlerName === 'rspack') {
|
|
91
93
|
// TODO hardcoded value until Rspack exposes its Browserslist data
|
|
92
94
|
// see https://github.com/facebook/docusaurus/pull/11496
|
|
93
|
-
return '
|
|
95
|
+
return '26.0.0';
|
|
94
96
|
}
|
|
95
97
|
// browserslist('last 1 node versions')[0]!.replace('node ', '')
|
|
96
98
|
return browserslist.nodeVersions.at(-1)!;
|
|
@@ -100,35 +102,32 @@ function getMinVersion(v1: string, v2: string): string {
|
|
|
100
102
|
return semver.lt(v1, v2) ? v1 : v2;
|
|
101
103
|
}
|
|
102
104
|
|
|
103
|
-
//
|
|
104
|
-
// See https://
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
// Used when the site doesn't provide its own Browserslist config
|
|
106
|
+
// See https://web.dev/baseline
|
|
107
|
+
const DefaultBrowserslistQueries = ['baseline widely available'];
|
|
108
|
+
|
|
109
|
+
function getServerBrowserslistQueries({
|
|
107
110
|
bundlerName,
|
|
108
111
|
}: {
|
|
109
|
-
isServer: boolean;
|
|
110
112
|
bundlerName: CurrentBundler['name'];
|
|
111
113
|
}): string[] {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
return [`node ${process.env.DOCUSAURUS_SERVER_NODE_TARGET}`];
|
|
116
|
-
}
|
|
117
|
-
// For server builds, we want to use the current Node version as target
|
|
118
|
-
// But we can't pass a target that Browserslist doesn't know about yet
|
|
119
|
-
const nodeTarget = getMinVersion(
|
|
120
|
-
process.versions.node,
|
|
121
|
-
getLastBrowserslistKnownNodeVersion(bundlerName),
|
|
122
|
-
);
|
|
123
|
-
|
|
124
|
-
return [`node ${nodeTarget}`];
|
|
114
|
+
// Escape hatch env variable
|
|
115
|
+
if (process.env.DOCUSAURUS_SERVER_NODE_TARGET) {
|
|
116
|
+
return [`node ${process.env.DOCUSAURUS_SERVER_NODE_TARGET}`];
|
|
125
117
|
}
|
|
118
|
+
// For server builds, we want to use the current Node version as target
|
|
119
|
+
// But we can't pass a target that Browserslist doesn't know about yet
|
|
120
|
+
const nodeTarget = getMinVersion(
|
|
121
|
+
process.versions.node,
|
|
122
|
+
getLastBrowserslistKnownNodeVersion(bundlerName),
|
|
123
|
+
);
|
|
124
|
+
return [`node ${nodeTarget}`];
|
|
125
|
+
}
|
|
126
126
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
return queries;
|
|
127
|
+
export function getBrowserslistQueries(): string[] {
|
|
128
|
+
return (
|
|
129
|
+
browserslist.loadConfig({path: process.cwd()}) ?? DefaultBrowserslistQueries
|
|
130
|
+
);
|
|
132
131
|
}
|
|
133
132
|
|
|
134
133
|
// LightningCSS doesn't expose any type for css-minimizer-webpack-plugin setup
|
|
@@ -140,6 +139,7 @@ type LightningCssMinimizerOptions = Omit<
|
|
|
140
139
|
>;
|
|
141
140
|
|
|
142
141
|
export function getLightningCssMinimizerOptions(): LightningCssMinimizerOptions {
|
|
143
|
-
const queries =
|
|
144
|
-
|
|
142
|
+
const queries = getBrowserslistQueries();
|
|
143
|
+
const browsers = browserslist(queries);
|
|
144
|
+
return {targets: lightningcss.browserslistToTargets(browsers)};
|
|
145
145
|
}
|