@docusaurus/bundler 4.0.0-canary-6903 → 4.0.0-canary-6905
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/currentBundler.d.ts +2 -2
- package/lib/currentBundler.d.ts.map +1 -1
- package/lib/currentBundler.js +3 -3
- package/lib/currentBundler.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/loaders/jsLoader.d.ts.map +1 -1
- package/lib/loaders/jsLoader.js +3 -4
- package/lib/loaders/jsLoader.js.map +1 -1
- package/lib/rspack.d.ts +11 -0
- package/lib/rspack.d.ts.map +1 -0
- package/lib/rspack.js +19 -0
- package/lib/rspack.js.map +1 -0
- package/lib/swc.d.ts +14 -0
- package/lib/swc.d.ts.map +1 -0
- package/lib/swc.js +63 -0
- package/lib/swc.js.map +1 -0
- package/package.json +8 -13
- package/src/currentBundler.ts +4 -4
- package/src/index.ts +1 -1
- package/src/loaders/jsLoader.ts +3 -6
- package/src/rspack.ts +22 -0
- package/src/swc.ts +82 -0
- package/lib/importFaster.d.ts +0 -11
- package/lib/importFaster.d.ts.map +0 -1
- package/lib/importFaster.js +0 -37
- package/lib/importFaster.js.map +0 -1
- package/src/importFaster.ts +0 -46
package/lib/currentBundler.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import webpack from 'webpack';
|
|
8
8
|
import WebpackBar from 'webpackbar';
|
|
9
9
|
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
|
10
|
-
import type {
|
|
10
|
+
import type { Rspack } from './rspack';
|
|
11
11
|
import type { CurrentBundler, DocusaurusConfig } from '@docusaurus/types';
|
|
12
12
|
type SiteConfigSlice = {
|
|
13
13
|
future: {
|
|
@@ -19,7 +19,7 @@ export declare function getCurrentBundler({ siteConfig, }: {
|
|
|
19
19
|
}): Promise<CurrentBundler>;
|
|
20
20
|
export declare function getCurrentBundlerAsRspack({ currentBundler, }: {
|
|
21
21
|
currentBundler: CurrentBundler;
|
|
22
|
-
}):
|
|
22
|
+
}): Rspack;
|
|
23
23
|
export declare function getCSSExtractPlugin({ currentBundler, }: {
|
|
24
24
|
currentBundler: CurrentBundler;
|
|
25
25
|
}): Promise<typeof MiniCssExtractPlugin>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"currentBundler.d.ts","sourceRoot":"","sources":["../src/currentBundler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAE3D,OAAO,KAAK,EAAC,
|
|
1
|
+
{"version":3,"file":"currentBundler.d.ts","sourceRoot":"","sources":["../src/currentBundler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAE3D,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AACrC,OAAO,KAAK,EAAC,cAAc,EAAE,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AAGxE,KAAK,eAAe,GAAG;IACrB,MAAM,EAAE;QACN,MAAM,EAAE,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,EAAE,eAAe,CAAC,CAAC;KACrE,CAAC;CACH,CAAC;AAMF,wBAAsB,iBAAiB,CAAC,EACtC,UAAU,GACX,EAAE;IACD,UAAU,EAAE,eAAe,CAAC;CAC7B,GAAG,OAAO,CAAC,cAAc,CAAC,CAW1B;AAED,wBAAgB,yBAAyB,CAAC,EACxC,cAAc,GACf,EAAE;IACD,cAAc,EAAE,cAAc,CAAC;CAChC,GAAG,MAAM,CAOT;AAED,wBAAsB,mBAAmB,CAAC,EACxC,cAAc,GACf,EAAE;IACD,cAAc,EAAE,cAAc,CAAC;CAChC,GAAG,OAAO,CAAC,OAAO,oBAAoB,CAAC,CAMvC;AAED,wBAAsB,aAAa,CAAC,EAClC,cAAc,GACf,EAAE;IACD,cAAc,EAAE,cAAc,CAAC;CAChC,GAAG,OAAO,CAAC,OAAO,OAAO,CAAC,UAAU,CAAC,CAMrC;AAED,wBAAsB,oBAAoB,CAAC,EACzC,cAAc,GACf,EAAE;IACD,cAAc,EAAE,cAAc,CAAC;CAChC,GAAG,OAAO,CAAC,OAAO,UAAU,CAAC,CAkB7B;AAED,wBAAsB,sBAAsB,CAAC,EAC3C,cAAc,GACf,EAAE;IACD,cAAc,EAAE,cAAc,CAAC;CAChC,GAAG,OAAO,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,CAqC/B"}
|
package/lib/currentBundler.js
CHANGED
|
@@ -16,7 +16,7 @@ const tslib_1 = require("tslib");
|
|
|
16
16
|
const webpack_1 = tslib_1.__importDefault(require("webpack"));
|
|
17
17
|
const webpackbar_1 = tslib_1.__importDefault(require("webpackbar"));
|
|
18
18
|
const mini_css_extract_plugin_1 = tslib_1.__importDefault(require("mini-css-extract-plugin"));
|
|
19
|
-
const
|
|
19
|
+
const rspack_1 = require("./rspack");
|
|
20
20
|
function isRspack(siteConfig) {
|
|
21
21
|
return siteConfig.future.faster.rspackBundler;
|
|
22
22
|
}
|
|
@@ -24,7 +24,7 @@ async function getCurrentBundler({ siteConfig, }) {
|
|
|
24
24
|
if (isRspack(siteConfig)) {
|
|
25
25
|
return {
|
|
26
26
|
name: 'rspack',
|
|
27
|
-
instance: (await (0,
|
|
27
|
+
instance: (await (0, rspack_1.importRspack)()),
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
return {
|
|
@@ -72,7 +72,7 @@ async function getProgressBarPlugin({ currentBundler, }) {
|
|
|
72
72
|
}
|
|
73
73
|
async function registerBundlerTracing({ currentBundler, }) {
|
|
74
74
|
if (currentBundler.name === 'rspack') {
|
|
75
|
-
const Rspack = await (0,
|
|
75
|
+
const Rspack = await (0, rspack_1.importRspack)();
|
|
76
76
|
// See https://rspack.dev/contribute/development/profiling
|
|
77
77
|
// File can be opened with https://ui.perfetto.dev/
|
|
78
78
|
if (process.env.DOCUSAURUS_RSPACK_TRACE) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"currentBundler.js","sourceRoot":"","sources":["../src/currentBundler.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;AAEH,8DAA8B;AAC9B,oEAAoC;AACpC,8FAA2D;AAC3D,
|
|
1
|
+
{"version":3,"file":"currentBundler.js","sourceRoot":"","sources":["../src/currentBundler.ts"],"names":[],"mappings":"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"}
|
package/lib/index.d.ts
CHANGED
|
@@ -10,5 +10,5 @@ export { getMinimizers } from './minification';
|
|
|
10
10
|
export { getHtmlMinifier, type HtmlMinifier } from './minifyHtml';
|
|
11
11
|
export { createJsLoaderFactory } from './loaders/jsLoader';
|
|
12
12
|
export { createStyleLoadersFactory } from './loaders/styleLoader';
|
|
13
|
-
export { importRspackDevServer } from './
|
|
13
|
+
export { importRspackDevServer } from './rspack';
|
|
14
14
|
//# sourceMappingURL=index.d.ts.map
|
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;AAEH,OAAO,EAAC,kBAAkB,EAAE,uBAAuB,EAAE,OAAO,EAAC,MAAM,YAAY,CAAC;AAEhF,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,aAAa,EACb,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAC,aAAa,EAAC,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAC,eAAe,EAAE,KAAK,YAAY,EAAC,MAAM,cAAc,CAAC;AAChE,OAAO,EAAC,qBAAqB,EAAC,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAC,yBAAyB,EAAC,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAC,qBAAqB,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,kBAAkB,EAAE,uBAAuB,EAAE,OAAO,EAAC,MAAM,YAAY,CAAC;AAEhF,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,aAAa,EACb,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAC,aAAa,EAAC,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAC,eAAe,EAAE,KAAK,YAAY,EAAC,MAAM,cAAc,CAAC;AAChE,OAAO,EAAC,qBAAqB,EAAC,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAC,yBAAyB,EAAC,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAC,qBAAqB,EAAC,MAAM,UAAU,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -25,6 +25,6 @@ var jsLoader_1 = require("./loaders/jsLoader");
|
|
|
25
25
|
Object.defineProperty(exports, "createJsLoaderFactory", { enumerable: true, get: function () { return jsLoader_1.createJsLoaderFactory; } });
|
|
26
26
|
var styleLoader_1 = require("./loaders/styleLoader");
|
|
27
27
|
Object.defineProperty(exports, "createStyleLoadersFactory", { enumerable: true, get: function () { return styleLoader_1.createStyleLoadersFactory; } });
|
|
28
|
-
var
|
|
29
|
-
Object.defineProperty(exports, "importRspackDevServer", { enumerable: true, get: function () { return
|
|
28
|
+
var rspack_1 = require("./rspack");
|
|
29
|
+
Object.defineProperty(exports, "importRspackDevServer", { enumerable: true, get: function () { return rspack_1.importRspackDevServer; } });
|
|
30
30
|
//# 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,uCAAgF;AAAxE,8GAAA,kBAAkB,OAAA;AAAE,mHAAA,uBAAuB,OAAA;AAAE,mGAAA,OAAO,OAAA;AAE5D,mDAM0B;AALxB,mHAAA,iBAAiB,OAAA;AACjB,qHAAA,mBAAmB,OAAA;AACnB,+GAAA,aAAa,OAAA;AACb,sHAAA,oBAAoB,OAAA;AACpB,wHAAA,sBAAsB,OAAA;AAGxB,+CAA6C;AAArC,6GAAA,aAAa,OAAA;AACrB,2CAAgE;AAAxD,6GAAA,eAAe,OAAA;AACvB,+CAAyD;AAAjD,iHAAA,qBAAqB,OAAA;AAC7B,qDAAgE;AAAxD,wHAAA,yBAAyB,OAAA;AACjC,+
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,uCAAgF;AAAxE,8GAAA,kBAAkB,OAAA;AAAE,mHAAA,uBAAuB,OAAA;AAAE,mGAAA,OAAO,OAAA;AAE5D,mDAM0B;AALxB,mHAAA,iBAAiB,OAAA;AACjB,qHAAA,mBAAmB,OAAA;AACnB,+GAAA,aAAa,OAAA;AACb,sHAAA,oBAAoB,OAAA;AACpB,wHAAA,sBAAsB,OAAA;AAGxB,+CAA6C;AAArC,6GAAA,aAAa,OAAA;AACrB,2CAAgE;AAAxD,6GAAA,eAAe,OAAA;AACvB,+CAAyD;AAAjD,iHAAA,qBAAqB,OAAA;AAC7B,qDAAgE;AAAxD,wHAAA,yBAAyB,OAAA;AACjC,mCAA+C;AAAvC,+GAAA,qBAAqB,OAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsLoader.d.ts","sourceRoot":"","sources":["../../src/loaders/jsLoader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EAAC,qBAAqB,EAAE,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"jsLoader.d.ts","sourceRoot":"","sources":["../../src/loaders/jsLoader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EAAC,qBAAqB,EAAE,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AA8B/E,wBAAsB,qBAAqB,CAAC,EAC1C,UAAU,GACX,EAAE;IACD,UAAU,EAAE;QACV,OAAO,CAAC,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAC;QACtC,MAAM,EAAE;YACN,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAC;SAC9C,CAAC;KACH,CAAC;CACH,GAAG,OAAO,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAC,CAoBhD"}
|
package/lib/loaders/jsLoader.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.createJsLoaderFactory = createJsLoaderFactory;
|
|
10
10
|
const babel_1 = require("@docusaurus/babel");
|
|
11
|
-
const
|
|
11
|
+
const swc_1 = require("../swc");
|
|
12
12
|
const currentBundler_1 = require("../currentBundler");
|
|
13
13
|
const browserslist_1 = require("../browserslist");
|
|
14
14
|
const BabelJsLoaderFactory = ({ isServer, babelOptions, }) => {
|
|
@@ -17,14 +17,13 @@ const BabelJsLoaderFactory = ({ isServer, babelOptions, }) => {
|
|
|
17
17
|
options: (0, babel_1.getBabelOptions)({ isServer, babelOptions }),
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
|
-
|
|
20
|
+
function createRspackSwcJsLoaderFactory() {
|
|
21
21
|
const loader = 'builtin:swc-loader';
|
|
22
|
-
const getOptions = await (0, importFaster_1.importGetSwcLoaderOptions)();
|
|
23
22
|
const clientBrowserslistQueries = (0, browserslist_1.getBrowserslistQueries)();
|
|
24
23
|
return ({ isServer }) => {
|
|
25
24
|
return {
|
|
26
25
|
loader,
|
|
27
|
-
options:
|
|
26
|
+
options: (0, swc_1.getSwcLoaderOptions)({
|
|
28
27
|
isServer,
|
|
29
28
|
bundlerName: 'rspack',
|
|
30
29
|
clientBrowserslistQueries,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsLoader.js","sourceRoot":"","sources":["../../src/loaders/jsLoader.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,6CAAkD;AAClD,
|
|
1
|
+
{"version":3,"file":"jsLoader.js","sourceRoot":"","sources":["../../src/loaders/jsLoader.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,6CAAkD;AAClD,gCAA2C;AAC3C,sDAAoD;AACpD,kDAAuD;AAGvD,MAAM,oBAAoB,GAAyC,CAAC,EAClE,QAAQ,EACR,YAAY,GACb,EAAE,EAAE;IACH,OAAO;QACL,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC;QACvC,OAAO,EAAE,IAAA,uBAAe,EAAC,EAAC,QAAQ,EAAE,YAAY,EAAC,CAAC;KACnD,CAAC;AACJ,CAAC,CAAC;AAEF,SAAS,8BAA8B;IACrC,MAAM,MAAM,GAAG,oBAAoB,CAAC;IACpC,MAAM,yBAAyB,GAAG,IAAA,qCAAsB,GAAE,CAAC;IAC3D,OAAO,CAAC,EAAC,QAAQ,EAAC,EAAE,EAAE;QACpB,OAAO;YACL,MAAM;YACN,OAAO,EAAE,IAAA,yBAAmB,EAAC;gBAC3B,QAAQ;gBACR,WAAW,EAAE,QAAQ;gBACrB,yBAAyB;aAC1B,CAAC;SACH,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED,6EAA6E;AAC7E,wEAAwE;AACxE,yEAAyE;AAClE,KAAK,gCAAgC,EAC1C,UAAU,GAQX;IACC,MAAM,cAAc,GAAG,MAAM,IAAA,kCAAiB,EAAC,EAAC,UAAU,EAAC,CAAC,CAAC;IAC7D,IAAI,cAAc,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QACrC,IAAI,UAAU,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CACb;uFAC+E,CAChF,CAAC;QACJ,CAAC;QACD,OAAO,8BAA8B,EAAE,CAAC;IAC1C,CAAC;IAED,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO,EAAE,QAAQ,IAAI,OAAO,CAAC;IACzD,IAAI,QAAQ,YAAY,QAAQ,EAAE,CAAC;QACjC,OAAO,CAAC,EAAC,QAAQ,EAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC5C,CAAC;IACD,IAAI,QAAQ,KAAK,OAAO,EAAE,CAAC;QACzB,OAAO,oBAAoB,CAAC;IAC9B,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,4CAA4C,QAAQ,EAAE,CAAC,CAAC;AAC1E,CAAC"}
|
package/lib/rspack.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
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 type Rspack = (typeof import('@rspack/core'))['rspack'];
|
|
8
|
+
export type RspackDevServer = (typeof import('@rspack/dev-server'))['RspackDevServer'];
|
|
9
|
+
export declare function importRspack(): Promise<Rspack>;
|
|
10
|
+
export declare function importRspackDevServer(): Promise<RspackDevServer>;
|
|
11
|
+
//# sourceMappingURL=rspack.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rspack.d.ts","sourceRoot":"","sources":["../src/rspack.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,MAAM,MAAM,MAAM,GAAG,CAAC,cAAc,cAAc,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;AAE/D,MAAM,MAAM,eAAe,GACzB,CAAC,cAAc,oBAAoB,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC;AAE3D,wBAAsB,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC,CAGpD;AAED,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,eAAe,CAAC,CAGtE"}
|
package/lib/rspack.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
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.importRspack = importRspack;
|
|
10
|
+
exports.importRspackDevServer = importRspackDevServer;
|
|
11
|
+
async function importRspack() {
|
|
12
|
+
const { rspack } = await import('@rspack/core');
|
|
13
|
+
return rspack;
|
|
14
|
+
}
|
|
15
|
+
async function importRspackDevServer() {
|
|
16
|
+
const { RspackDevServer } = await import('@rspack/dev-server');
|
|
17
|
+
return RspackDevServer;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=rspack.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rspack.js","sourceRoot":"","sources":["../src/rspack.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAQI,KAAK;IACV,MAAM,EAAC,MAAM,EAAC,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,CAAC;IAC9C,OAAO,MAAM,CAAC;AAChB,CAAC;AAEM,KAAK;IACV,MAAM,EAAC,eAAe,EAAC,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,CAAC;IAC7D,OAAO,eAAe,CAAC;AACzB,CAAC"}
|
package/lib/swc.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
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 { Options as SwcOptions } from '@swc/core';
|
|
8
|
+
import type { CurrentBundler } from '@docusaurus/types';
|
|
9
|
+
export declare function getSwcLoaderOptions({ isServer, bundlerName, clientBrowserslistQueries, }: {
|
|
10
|
+
isServer: boolean;
|
|
11
|
+
bundlerName: CurrentBundler['name'];
|
|
12
|
+
clientBrowserslistQueries: string[];
|
|
13
|
+
}): SwcOptions;
|
|
14
|
+
//# sourceMappingURL=swc.d.ts.map
|
package/lib/swc.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swc.d.ts","sourceRoot":"","sources":["../src/swc.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAC,OAAO,IAAI,UAAU,EAAC,MAAM,WAAW,CAAC;AACrD,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAEtD,wBAAgB,mBAAmB,CAAC,EAClC,QAAQ,EACR,WAAW,EACX,yBAAyB,GAC1B,EAAE;IACD,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IACpC,yBAAyB,EAAE,MAAM,EAAE,CAAC;CACrC,GAAG,UAAU,CAwBb"}
|
package/lib/swc.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
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.getSwcLoaderOptions = getSwcLoaderOptions;
|
|
10
|
+
const tslib_1 = require("tslib");
|
|
11
|
+
const browserslist_1 = tslib_1.__importDefault(require("browserslist"));
|
|
12
|
+
const semver_1 = tslib_1.__importDefault(require("semver"));
|
|
13
|
+
function getSwcLoaderOptions({ isServer, bundlerName, clientBrowserslistQueries, }) {
|
|
14
|
+
return {
|
|
15
|
+
env: {
|
|
16
|
+
targets: isServer
|
|
17
|
+
? getServerBrowserslistQueries({ bundlerName })
|
|
18
|
+
: clientBrowserslistQueries,
|
|
19
|
+
},
|
|
20
|
+
jsc: {
|
|
21
|
+
parser: {
|
|
22
|
+
syntax: 'typescript',
|
|
23
|
+
tsx: true,
|
|
24
|
+
},
|
|
25
|
+
transform: {
|
|
26
|
+
react: {
|
|
27
|
+
runtime: 'automatic',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
experimental: {
|
|
31
|
+
// Required to match import attributes in rules, see
|
|
32
|
+
// https://rspack.rs/config/module-rules#ruleswith
|
|
33
|
+
keepImportAttributes: true,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
// TODO this is not accurate
|
|
39
|
+
// for Rspack we should read from the built-in browserslist data
|
|
40
|
+
// see https://github.com/facebook/docusaurus/pull/11496
|
|
41
|
+
function getLastBrowserslistKnownNodeVersion(bundlerName) {
|
|
42
|
+
if (bundlerName === 'rspack') {
|
|
43
|
+
// TODO hardcoded value until Rspack exposes its Browserslist data
|
|
44
|
+
// see https://github.com/facebook/docusaurus/pull/11496
|
|
45
|
+
return '26.0.0';
|
|
46
|
+
}
|
|
47
|
+
// browserslist('last 1 node versions')[0]!.replace('node ', '')
|
|
48
|
+
return browserslist_1.default.nodeVersions.at(-1);
|
|
49
|
+
}
|
|
50
|
+
function getMinVersion(v1, v2) {
|
|
51
|
+
return semver_1.default.lt(v1, v2) ? v1 : v2;
|
|
52
|
+
}
|
|
53
|
+
function getServerBrowserslistQueries({ bundlerName, }) {
|
|
54
|
+
// Escape hatch env variable
|
|
55
|
+
if (process.env.DOCUSAURUS_SERVER_NODE_TARGET) {
|
|
56
|
+
return [`node ${process.env.DOCUSAURUS_SERVER_NODE_TARGET}`];
|
|
57
|
+
}
|
|
58
|
+
// For server builds, we want to use the current Node version as target
|
|
59
|
+
// But we can't pass a target that Browserslist doesn't know about yet
|
|
60
|
+
const nodeTarget = getMinVersion(process.versions.node, getLastBrowserslistKnownNodeVersion(bundlerName));
|
|
61
|
+
return [`node ${nodeTarget}`];
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=swc.js.map
|
package/lib/swc.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swc.js","sourceRoot":"","sources":["../src/swc.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,wEAAwC;AACxC,4DAA4B;AAI5B,6BAAoC,EAClC,QAAQ,EACR,WAAW,EACX,yBAAyB,GAK1B;IACC,OAAO;QACL,GAAG,EAAE;YACH,OAAO,EAAE,QAAQ;gBACf,CAAC,CAAC,4BAA4B,CAAC,EAAC,WAAW,EAAC,CAAC;gBAC7C,CAAC,CAAC,yBAAyB;SAC9B;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;AAED,4BAA4B;AAC5B,iEAAiE;AACjE,yDAAyD;AACzD,SAAS,mCAAmC,CAC1C,WAAmC;IAEnC,IAAI,WAAW,KAAK,QAAQ,EAAE,CAAC;QAC7B,kEAAkE;QAClE,yDAAyD;QACzD,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,gEAAgE;IAChE,OAAO,sBAAY,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,CAAC,CAAE,CAAC;AAC3C,CAAC;AAED,SAAS,aAAa,CAAC,EAAU,EAAE,EAAU;IAC3C,OAAO,gBAAM,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AACrC,CAAC;AAED,SAAS,4BAA4B,CAAC,EACpC,WAAW,GAGZ;IACC,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,uEAAuE;IACvE,sEAAsE;IACtE,MAAM,UAAU,GAAG,aAAa,CAC9B,OAAO,CAAC,QAAQ,CAAC,IAAI,EACrB,mCAAmC,CAAC,WAAW,CAAC,CACjD,CAAC;IACF,OAAO,CAAC,QAAQ,UAAU,EAAE,CAAC,CAAC;AAChC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/bundler",
|
|
3
|
-
"version": "4.0.0-canary-
|
|
3
|
+
"version": "4.0.0-canary-6905",
|
|
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,11 @@
|
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@babel/core": "^7.29.7",
|
|
22
|
-
"@docusaurus/babel": "4.0.0-canary-
|
|
23
|
-
"@docusaurus/logger": "4.0.0-canary-
|
|
24
|
-
"@docusaurus/types": "4.0.0-canary-
|
|
22
|
+
"@docusaurus/babel": "4.0.0-canary-6905",
|
|
23
|
+
"@docusaurus/logger": "4.0.0-canary-6905",
|
|
24
|
+
"@docusaurus/types": "4.0.0-canary-6905",
|
|
25
|
+
"@rspack/core": "^2.2.3",
|
|
26
|
+
"@rspack/dev-server": "^2.2.1",
|
|
25
27
|
"@swc/core": "^1.16.2",
|
|
26
28
|
"@swc/html": "^1.16.2",
|
|
27
29
|
"babel-loader": "^10.1.1",
|
|
@@ -33,24 +35,17 @@
|
|
|
33
35
|
"postcss": "^8.5.28",
|
|
34
36
|
"postcss-loader": "^8.2.1",
|
|
35
37
|
"postcss-preset-env": "^11.5.2",
|
|
38
|
+
"semver": "^7.8.5",
|
|
36
39
|
"terser-webpack-plugin": "^5.6.1",
|
|
37
40
|
"tslib": "^2.8.1",
|
|
38
41
|
"webpack": "^5.111.0",
|
|
39
42
|
"webpackbar": "^7.0.0"
|
|
40
43
|
},
|
|
41
|
-
"peerDependencies": {
|
|
42
|
-
"@docusaurus/faster": "4.0.0-canary-6903"
|
|
43
|
-
},
|
|
44
|
-
"peerDependenciesMeta": {
|
|
45
|
-
"@docusaurus/faster": {
|
|
46
|
-
"optional": true
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
44
|
"devDependencies": {
|
|
50
45
|
"@total-typescript/shoehorn": "^0.1.2"
|
|
51
46
|
},
|
|
52
47
|
"engines": {
|
|
53
48
|
"node": ">=24.21"
|
|
54
49
|
},
|
|
55
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "470671a4afe0ffd3cc7baf99475ba2370145f3b1"
|
|
56
51
|
}
|
package/src/currentBundler.ts
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
import webpack from 'webpack';
|
|
9
9
|
import WebpackBar from 'webpackbar';
|
|
10
10
|
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
|
11
|
-
import {importRspack} from './
|
|
12
|
-
import type {
|
|
11
|
+
import {importRspack} from './rspack';
|
|
12
|
+
import type {Rspack} from './rspack';
|
|
13
13
|
import type {CurrentBundler, DocusaurusConfig} from '@docusaurus/types';
|
|
14
14
|
|
|
15
15
|
// We inject a site config slice because the Rspack flag might change place
|
|
@@ -44,13 +44,13 @@ export function getCurrentBundlerAsRspack({
|
|
|
44
44
|
currentBundler,
|
|
45
45
|
}: {
|
|
46
46
|
currentBundler: CurrentBundler;
|
|
47
|
-
}):
|
|
47
|
+
}): Rspack {
|
|
48
48
|
if (currentBundler.name !== 'rspack') {
|
|
49
49
|
throw new Error(
|
|
50
50
|
`Can't getCurrentBundlerAsRspack() because current bundler is ${currentBundler.name}`,
|
|
51
51
|
);
|
|
52
52
|
}
|
|
53
|
-
return currentBundler.instance as unknown as
|
|
53
|
+
return currentBundler.instance as unknown as Rspack;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
export async function getCSSExtractPlugin({
|
package/src/index.ts
CHANGED
|
@@ -19,4 +19,4 @@ export {getMinimizers} from './minification';
|
|
|
19
19
|
export {getHtmlMinifier, type HtmlMinifier} from './minifyHtml';
|
|
20
20
|
export {createJsLoaderFactory} from './loaders/jsLoader';
|
|
21
21
|
export {createStyleLoadersFactory} from './loaders/styleLoader';
|
|
22
|
-
export {importRspackDevServer} from './
|
|
22
|
+
export {importRspackDevServer} from './rspack';
|
package/src/loaders/jsLoader.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import {getBabelOptions} from '@docusaurus/babel';
|
|
9
|
-
import {
|
|
9
|
+
import {getSwcLoaderOptions} from '../swc';
|
|
10
10
|
import {getCurrentBundler} from '../currentBundler';
|
|
11
11
|
import {getBrowserslistQueries} from '../browserslist';
|
|
12
12
|
import type {ConfigureWebpackUtils, DocusaurusConfig} from '@docusaurus/types';
|
|
@@ -21,16 +21,13 @@ const BabelJsLoaderFactory: ConfigureWebpackUtils['getJSLoader'] = ({
|
|
|
21
21
|
};
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
ConfigureWebpackUtils['getJSLoader']
|
|
26
|
-
> {
|
|
24
|
+
function createRspackSwcJsLoaderFactory(): ConfigureWebpackUtils['getJSLoader'] {
|
|
27
25
|
const loader = 'builtin:swc-loader';
|
|
28
|
-
const getOptions = await importGetSwcLoaderOptions();
|
|
29
26
|
const clientBrowserslistQueries = getBrowserslistQueries();
|
|
30
27
|
return ({isServer}) => {
|
|
31
28
|
return {
|
|
32
29
|
loader,
|
|
33
|
-
options:
|
|
30
|
+
options: getSwcLoaderOptions({
|
|
34
31
|
isServer,
|
|
35
32
|
bundlerName: 'rspack',
|
|
36
33
|
clientBrowserslistQueries,
|
package/src/rspack.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
// Rspack is imported lazily: sites using webpack shouldn't pay its load cost
|
|
9
|
+
export type Rspack = (typeof import('@rspack/core'))['rspack'];
|
|
10
|
+
|
|
11
|
+
export type RspackDevServer =
|
|
12
|
+
(typeof import('@rspack/dev-server'))['RspackDevServer'];
|
|
13
|
+
|
|
14
|
+
export async function importRspack(): Promise<Rspack> {
|
|
15
|
+
const {rspack} = await import('@rspack/core');
|
|
16
|
+
return rspack;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export async function importRspackDevServer(): Promise<RspackDevServer> {
|
|
20
|
+
const {RspackDevServer} = await import('@rspack/dev-server');
|
|
21
|
+
return RspackDevServer;
|
|
22
|
+
}
|
package/src/swc.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
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 browserslist from 'browserslist';
|
|
9
|
+
import semver from 'semver';
|
|
10
|
+
import type {Options as SwcOptions} from '@swc/core';
|
|
11
|
+
import type {CurrentBundler} from '@docusaurus/types';
|
|
12
|
+
|
|
13
|
+
export function getSwcLoaderOptions({
|
|
14
|
+
isServer,
|
|
15
|
+
bundlerName,
|
|
16
|
+
clientBrowserslistQueries,
|
|
17
|
+
}: {
|
|
18
|
+
isServer: boolean;
|
|
19
|
+
bundlerName: CurrentBundler['name'];
|
|
20
|
+
clientBrowserslistQueries: string[];
|
|
21
|
+
}): SwcOptions {
|
|
22
|
+
return {
|
|
23
|
+
env: {
|
|
24
|
+
targets: isServer
|
|
25
|
+
? getServerBrowserslistQueries({bundlerName})
|
|
26
|
+
: clientBrowserslistQueries,
|
|
27
|
+
},
|
|
28
|
+
jsc: {
|
|
29
|
+
parser: {
|
|
30
|
+
syntax: 'typescript',
|
|
31
|
+
tsx: true,
|
|
32
|
+
},
|
|
33
|
+
transform: {
|
|
34
|
+
react: {
|
|
35
|
+
runtime: 'automatic',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
experimental: {
|
|
39
|
+
// Required to match import attributes in rules, see
|
|
40
|
+
// https://rspack.rs/config/module-rules#ruleswith
|
|
41
|
+
keepImportAttributes: true,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
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(
|
|
51
|
+
bundlerName: CurrentBundler['name'],
|
|
52
|
+
): string {
|
|
53
|
+
if (bundlerName === 'rspack') {
|
|
54
|
+
// TODO hardcoded value until Rspack exposes its Browserslist data
|
|
55
|
+
// see https://github.com/facebook/docusaurus/pull/11496
|
|
56
|
+
return '26.0.0';
|
|
57
|
+
}
|
|
58
|
+
// browserslist('last 1 node versions')[0]!.replace('node ', '')
|
|
59
|
+
return browserslist.nodeVersions.at(-1)!;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function getMinVersion(v1: string, v2: string): string {
|
|
63
|
+
return semver.lt(v1, v2) ? v1 : v2;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function getServerBrowserslistQueries({
|
|
67
|
+
bundlerName,
|
|
68
|
+
}: {
|
|
69
|
+
bundlerName: CurrentBundler['name'];
|
|
70
|
+
}): string[] {
|
|
71
|
+
// Escape hatch env variable
|
|
72
|
+
if (process.env.DOCUSAURUS_SERVER_NODE_TARGET) {
|
|
73
|
+
return [`node ${process.env.DOCUSAURUS_SERVER_NODE_TARGET}`];
|
|
74
|
+
}
|
|
75
|
+
// For server builds, we want to use the current Node version as target
|
|
76
|
+
// But we can't pass a target that Browserslist doesn't know about yet
|
|
77
|
+
const nodeTarget = getMinVersion(
|
|
78
|
+
process.versions.node,
|
|
79
|
+
getLastBrowserslistKnownNodeVersion(bundlerName),
|
|
80
|
+
);
|
|
81
|
+
return [`node ${nodeTarget}`];
|
|
82
|
+
}
|
package/lib/importFaster.d.ts
DELETED
|
@@ -1,11 +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 type FasterModule = Awaited<typeof import('@docusaurus/faster')>;
|
|
8
|
-
export declare function importRspack(): Promise<FasterModule['rspack']>;
|
|
9
|
-
export declare function importRspackDevServer(): Promise<FasterModule['rspackDevServer']>;
|
|
10
|
-
export declare function importGetSwcLoaderOptions(): Promise<FasterModule['getSwcLoaderOptions']>;
|
|
11
|
-
//# sourceMappingURL=importFaster.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"importFaster.d.ts","sourceRoot":"","sources":["../src/importFaster.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,MAAM,YAAY,GAAG,OAAO,CAAC,cAAc,oBAAoB,CAAC,CAAC,CAAC;AAmBxE,wBAAsB,YAAY,IAAI,OAAO,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAGpE;AAED,wBAAsB,qBAAqB,IAAI,OAAO,CACpD,YAAY,CAAC,iBAAiB,CAAC,CAChC,CAGA;AAED,wBAAsB,yBAAyB,IAAI,OAAO,CACxD,YAAY,CAAC,qBAAqB,CAAC,CACpC,CAGA"}
|
package/lib/importFaster.js
DELETED
|
@@ -1,37 +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.importRspack = importRspack;
|
|
10
|
-
exports.importRspackDevServer = importRspackDevServer;
|
|
11
|
-
exports.importGetSwcLoaderOptions = importGetSwcLoaderOptions;
|
|
12
|
-
const tslib_1 = require("tslib");
|
|
13
|
-
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
14
|
-
async function importFaster() {
|
|
15
|
-
return import('@docusaurus/faster');
|
|
16
|
-
}
|
|
17
|
-
async function ensureFaster() {
|
|
18
|
-
try {
|
|
19
|
-
return await importFaster();
|
|
20
|
-
}
|
|
21
|
-
catch (error) {
|
|
22
|
-
throw new Error(`To enable Docusaurus Faster options, your site must add the ${logger_1.default.name('@docusaurus/faster')} package as a dependency.`, { cause: error });
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
async function importRspack() {
|
|
26
|
-
const faster = await ensureFaster();
|
|
27
|
-
return faster.rspack;
|
|
28
|
-
}
|
|
29
|
-
async function importRspackDevServer() {
|
|
30
|
-
const faster = await ensureFaster();
|
|
31
|
-
return faster.rspackDevServer;
|
|
32
|
-
}
|
|
33
|
-
async function importGetSwcLoaderOptions() {
|
|
34
|
-
const faster = await ensureFaster();
|
|
35
|
-
return faster.getSwcLoaderOptions;
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=importFaster.js.map
|
package/lib/importFaster.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"importFaster.js","sourceRoot":"","sources":["../src/importFaster.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;AAEH,wEAAwC;AAIxC,KAAK,UAAU,YAAY;IACzB,OAAO,MAAM,CAAC,oBAAoB,CAAC,CAAC;AACtC,CAAC;AAED,KAAK,UAAU,YAAY;IACzB,IAAI,CAAC;QACH,OAAO,MAAM,YAAY,EAAE,CAAC;IAC9B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,+DAA+D,gBAAM,CAAC,IAAI,CACxE,oBAAoB,CACrB,2BAA2B,EAC5B,EAAC,KAAK,EAAE,KAAK,EAAC,CACf,CAAC;IACJ,CAAC;AACH,CAAC;AAEM,KAAK;IACV,MAAM,MAAM,GAAG,MAAM,YAAY,EAAE,CAAC;IACpC,OAAO,MAAM,CAAC,MAAM,CAAC;AACvB,CAAC;AAEM,KAAK;IAGV,MAAM,MAAM,GAAG,MAAM,YAAY,EAAE,CAAC;IACpC,OAAO,MAAM,CAAC,eAAe,CAAC;AAChC,CAAC;AAEM,KAAK;IAGV,MAAM,MAAM,GAAG,MAAM,YAAY,EAAE,CAAC;IACpC,OAAO,MAAM,CAAC,mBAAmB,CAAC;AACpC,CAAC"}
|
package/src/importFaster.ts
DELETED
|
@@ -1,46 +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
|
-
|
|
8
|
-
import logger from '@docusaurus/logger';
|
|
9
|
-
|
|
10
|
-
export type FasterModule = Awaited<typeof import('@docusaurus/faster')>;
|
|
11
|
-
|
|
12
|
-
async function importFaster(): Promise<FasterModule> {
|
|
13
|
-
return import('@docusaurus/faster');
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
async function ensureFaster(): Promise<FasterModule> {
|
|
17
|
-
try {
|
|
18
|
-
return await importFaster();
|
|
19
|
-
} catch (error) {
|
|
20
|
-
throw new Error(
|
|
21
|
-
`To enable Docusaurus Faster options, your site must add the ${logger.name(
|
|
22
|
-
'@docusaurus/faster',
|
|
23
|
-
)} package as a dependency.`,
|
|
24
|
-
{cause: error},
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export async function importRspack(): Promise<FasterModule['rspack']> {
|
|
30
|
-
const faster = await ensureFaster();
|
|
31
|
-
return faster.rspack;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export async function importRspackDevServer(): Promise<
|
|
35
|
-
FasterModule['rspackDevServer']
|
|
36
|
-
> {
|
|
37
|
-
const faster = await ensureFaster();
|
|
38
|
-
return faster.rspackDevServer;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export async function importGetSwcLoaderOptions(): Promise<
|
|
42
|
-
FasterModule['getSwcLoaderOptions']
|
|
43
|
-
> {
|
|
44
|
-
const faster = await ensureFaster();
|
|
45
|
-
return faster.getSwcLoaderOptions;
|
|
46
|
-
}
|