@docusaurus/bundler 3.5.2 → 3.6.0-canary-6132

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.
Files changed (42) hide show
  1. package/LICENSE +21 -0
  2. package/lib/compiler.d.ts +22 -0
  3. package/lib/compiler.d.ts.map +1 -0
  4. package/lib/compiler.js +66 -0
  5. package/lib/compiler.js.map +1 -0
  6. package/lib/currentBundler.d.ts +33 -0
  7. package/lib/currentBundler.d.ts.map +1 -0
  8. package/lib/currentBundler.js +73 -0
  9. package/lib/currentBundler.js.map +1 -0
  10. package/lib/importFaster.d.ts +17 -0
  11. package/lib/importFaster.d.ts.map +1 -0
  12. package/lib/importFaster.js +57 -0
  13. package/lib/importFaster.js.map +1 -0
  14. package/lib/index.d.ts +6 -22
  15. package/lib/index.d.ts.map +1 -1
  16. package/lib/index.js +18 -52
  17. package/lib/index.js.map +1 -1
  18. package/lib/loaders/jsLoader.d.ts +16 -0
  19. package/lib/loaders/jsLoader.d.ts.map +1 -0
  20. package/lib/loaders/jsLoader.js +67 -0
  21. package/lib/loaders/jsLoader.js.map +1 -0
  22. package/lib/loaders/styleLoader.d.ts +11 -0
  23. package/lib/loaders/styleLoader.d.ts.map +1 -0
  24. package/lib/loaders/styleLoader.js +68 -0
  25. package/lib/loaders/styleLoader.js.map +1 -0
  26. package/lib/minification.d.ts +14 -0
  27. package/lib/minification.d.ts.map +1 -0
  28. package/lib/minification.js +147 -0
  29. package/lib/minification.js.map +1 -0
  30. package/lib/minifyHtml.d.ts +18 -0
  31. package/lib/minifyHtml.d.ts.map +1 -0
  32. package/lib/minifyHtml.js +91 -0
  33. package/lib/minifyHtml.js.map +1 -0
  34. package/package.json +35 -5
  35. package/src/compiler.ts +87 -0
  36. package/src/currentBundler.ts +106 -0
  37. package/src/importFaster.ts +77 -0
  38. package/src/index.ts +17 -82
  39. package/src/loaders/jsLoader.ts +89 -0
  40. package/src/loaders/styleLoader.ts +80 -0
  41. package/src/minification.ts +176 -0
  42. package/src/minifyHtml.ts +111 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Facebook, Inc. and its affiliates.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -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
+ import { type Configuration } from 'webpack';
8
+ import type webpack from 'webpack';
9
+ import type { CurrentBundler } from '@docusaurus/types';
10
+ export declare function formatStatsErrorMessage(statsJson: ReturnType<webpack.Stats['toJson']> | undefined): string | undefined;
11
+ export declare function printStatsWarnings(statsJson: ReturnType<webpack.Stats['toJson']> | undefined): void;
12
+ declare global {
13
+ interface Error {
14
+ /** @see https://webpack.js.org/api/node/#error-handling */
15
+ details?: unknown;
16
+ }
17
+ }
18
+ export declare function compile({ configs, currentBundler, }: {
19
+ configs: Configuration[];
20
+ currentBundler: CurrentBundler;
21
+ }): Promise<webpack.MultiStats>;
22
+ //# sourceMappingURL=compiler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../src/compiler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,KAAK,aAAa,EAAC,MAAM,SAAS,CAAC;AAG3C,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAEtD,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,SAAS,GACzD,MAAM,GAAG,SAAS,CAWpB;AAED,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,SAAS,GACzD,IAAI,CAMN;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,KAAK;QACb,2DAA2D;QAC3D,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB;CACF;AAED,wBAAgB,OAAO,CAAC,EACtB,OAAO,EACP,cAAc,GACf,EAAE;IACD,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,cAAc,EAAE,cAAc,CAAC;CAChC,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAmC9B"}
@@ -0,0 +1,66 @@
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.formatStatsErrorMessage = formatStatsErrorMessage;
10
+ exports.printStatsWarnings = printStatsWarnings;
11
+ exports.compile = compile;
12
+ const tslib_1 = require("tslib");
13
+ const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
14
+ const formatWebpackMessages_1 = tslib_1.__importDefault(require("react-dev-utils/formatWebpackMessages"));
15
+ function formatStatsErrorMessage(statsJson) {
16
+ if (statsJson?.errors?.length) {
17
+ // TODO formatWebpackMessages does not print stack-traces
18
+ // Also the error causal chain is lost here
19
+ // We log the stacktrace inside serverEntry.tsx for now (not ideal)
20
+ const { errors } = (0, formatWebpackMessages_1.default)(statsJson);
21
+ return errors
22
+ .map((str) => logger_1.default.red(str))
23
+ .join(`\n\n${logger_1.default.yellow('--------------------------')}\n\n`);
24
+ }
25
+ return undefined;
26
+ }
27
+ function printStatsWarnings(statsJson) {
28
+ if (statsJson?.warnings?.length) {
29
+ statsJson.warnings?.forEach((warning) => {
30
+ logger_1.default.warn(warning);
31
+ });
32
+ }
33
+ }
34
+ function compile({ configs, currentBundler, }) {
35
+ return new Promise((resolve, reject) => {
36
+ const compiler = currentBundler.instance(configs);
37
+ compiler.run((err, stats) => {
38
+ if (err) {
39
+ logger_1.default.error(err.stack ?? err);
40
+ if (err.details) {
41
+ logger_1.default.error(err.details);
42
+ }
43
+ reject(err);
44
+ }
45
+ // Let plugins consume all the stats
46
+ const errorsWarnings = stats?.toJson('errors-warnings');
47
+ if (stats?.hasErrors()) {
48
+ const statsErrorMessage = formatStatsErrorMessage(errorsWarnings);
49
+ reject(new Error(`Failed to compile due to Webpack errors.\n${statsErrorMessage}`));
50
+ }
51
+ printStatsWarnings(errorsWarnings);
52
+ // Webpack 5 requires calling close() so that persistent caching works
53
+ // See https://github.com/webpack/webpack.js.org/pull/4775
54
+ compiler.close((errClose) => {
55
+ if (errClose) {
56
+ logger_1.default.error(`Error while closing Webpack compiler: ${errClose}`);
57
+ reject(errClose);
58
+ }
59
+ else {
60
+ resolve(stats);
61
+ }
62
+ });
63
+ });
64
+ });
65
+ }
66
+ //# sourceMappingURL=compiler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compiler.js","sourceRoot":"","sources":["../src/compiler.ts"],"names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AAC,GAAG,CAAC,OAAO,CAAC,CAAC;gBAC5B,CAAC;gBACD,MAAM,CAAC,GAAG,CAAC,CAAC;YACd,CAAC;YACD,oCAAoC;YACpC,MAAM,cAAc,GAAG,KAAK,EAAE,MAAM,CAAC,iBAAiB,CAAC,CAAC;YACxD,IAAI,KAAK,EAAE,SAAS,EAAE,EAAE,CAAC;gBACvB,MAAM,iBAAiB,GAAG,uBAAuB,CAAC,cAAc,CAAC,CAAC;gBAClE,MAAM,CACJ,IAAI,KAAK,CACP,6CAA6C,iBAAiB,EAAE,CACjE,CACF,CAAC;YACJ,CAAC;YACD,kBAAkB,CAAC,cAAc,CAAC,CAAC;YAEnC,sEAAsE;YACtE,0DAA0D;YAC1D,QAAQ,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,EAAE;gBAC1B,IAAI,QAAQ,EAAE,CAAC;oBACb,gBAAM,CAAC,KAAK,CAAC,yCAAyC,QAAQ,EAAE,CAAC,CAAC;oBAClE,MAAM,CAAC,QAAQ,CAAC,CAAC;gBACnB,CAAC;qBAAM,CAAC;oBACN,OAAO,CAAC,KAAM,CAAC,CAAC;gBAClB,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,33 @@
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 WebpackBar from 'webpackbar';
8
+ import MiniCssExtractPlugin from 'mini-css-extract-plugin';
9
+ import CopyWebpackPlugin from 'copy-webpack-plugin';
10
+ import type { FasterModule } from './importFaster';
11
+ import type { CurrentBundler, DocusaurusConfig } from '@docusaurus/types';
12
+ type SiteConfigSlice = {
13
+ future: {
14
+ experimental_faster: Pick<DocusaurusConfig['future']['experimental_faster'], 'rspackBundler'>;
15
+ };
16
+ };
17
+ export declare function getCurrentBundler({ siteConfig, }: {
18
+ siteConfig: SiteConfigSlice;
19
+ }): Promise<CurrentBundler>;
20
+ export declare function getCurrentBundlerAsRspack({ currentBundler, }: {
21
+ currentBundler: CurrentBundler;
22
+ }): FasterModule['rspack'];
23
+ export declare function getCSSExtractPlugin({ currentBundler, }: {
24
+ currentBundler: CurrentBundler;
25
+ }): Promise<typeof MiniCssExtractPlugin>;
26
+ export declare function getCopyPlugin({ currentBundler, }: {
27
+ currentBundler: CurrentBundler;
28
+ }): Promise<typeof CopyWebpackPlugin>;
29
+ export declare function getProgressBarPlugin({ currentBundler, }: {
30
+ currentBundler: CurrentBundler;
31
+ }): Promise<typeof WebpackBar>;
32
+ export {};
33
+ //# sourceMappingURL=currentBundler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"currentBundler.d.ts","sourceRoot":"","sources":["../src/currentBundler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAC3D,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AAEpD,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAC,cAAc,EAAE,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AAGxE,KAAK,eAAe,GAAG;IACrB,MAAM,EAAE;QACN,mBAAmB,EAAE,IAAI,CACvB,gBAAgB,CAAC,QAAQ,CAAC,CAAC,qBAAqB,CAAC,EACjD,eAAe,CAChB,CAAC;KACH,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,YAAY,CAAC,QAAQ,CAAC,CAOzB;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,iBAAiB,CAAC,CAMpC;AAED,wBAAsB,oBAAoB,CAAC,EACzC,cAAc,GACf,EAAE;IACD,cAAc,EAAE,cAAc,CAAC;CAChC,GAAG,OAAO,CAAC,OAAO,UAAU,CAAC,CAkB7B"}
@@ -0,0 +1,73 @@
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.getCurrentBundler = getCurrentBundler;
10
+ exports.getCurrentBundlerAsRspack = getCurrentBundlerAsRspack;
11
+ exports.getCSSExtractPlugin = getCSSExtractPlugin;
12
+ exports.getCopyPlugin = getCopyPlugin;
13
+ exports.getProgressBarPlugin = getProgressBarPlugin;
14
+ const tslib_1 = require("tslib");
15
+ const webpack_1 = tslib_1.__importDefault(require("webpack"));
16
+ const webpackbar_1 = tslib_1.__importDefault(require("webpackbar"));
17
+ const mini_css_extract_plugin_1 = tslib_1.__importDefault(require("mini-css-extract-plugin"));
18
+ const copy_webpack_plugin_1 = tslib_1.__importDefault(require("copy-webpack-plugin"));
19
+ const importFaster_1 = require("./importFaster");
20
+ function isRspack(siteConfig) {
21
+ return siteConfig.future.experimental_faster.rspackBundler;
22
+ }
23
+ async function getCurrentBundler({ siteConfig, }) {
24
+ if (isRspack(siteConfig)) {
25
+ return {
26
+ name: 'rspack',
27
+ instance: (await (0, importFaster_1.importRspack)()),
28
+ };
29
+ }
30
+ return {
31
+ name: 'webpack',
32
+ instance: webpack_1.default,
33
+ };
34
+ }
35
+ function getCurrentBundlerAsRspack({ currentBundler, }) {
36
+ if (currentBundler.name !== 'rspack') {
37
+ throw new Error(`Can't getCurrentBundlerAsRspack() because current bundler is ${currentBundler.name}`);
38
+ }
39
+ return currentBundler.instance;
40
+ }
41
+ async function getCSSExtractPlugin({ currentBundler, }) {
42
+ if (currentBundler.name === 'rspack') {
43
+ // @ts-expect-error: this exists only in Rspack
44
+ return currentBundler.instance.CssExtractRspackPlugin;
45
+ }
46
+ return mini_css_extract_plugin_1.default;
47
+ }
48
+ async function getCopyPlugin({ currentBundler, }) {
49
+ if (currentBundler.name === 'rspack') {
50
+ // @ts-expect-error: this exists only in Rspack
51
+ return currentBundler.instance.CopyRspackPlugin;
52
+ }
53
+ return copy_webpack_plugin_1.default;
54
+ }
55
+ async function getProgressBarPlugin({ currentBundler, }) {
56
+ if (currentBundler.name === 'rspack') {
57
+ const rspack = getCurrentBundlerAsRspack({ currentBundler });
58
+ class CustomRspackProgressPlugin extends rspack.ProgressPlugin {
59
+ constructor({ name, color = 'green' }) {
60
+ // Unfortunately rspack.ProgressPlugin does not have name/color options
61
+ // See https://rspack.dev/plugins/webpack/progress-plugin
62
+ super({
63
+ prefix: name,
64
+ template: `● {prefix:.bold} {bar:50.${color}/white.dim} ({percent}%) {wide_msg:.dim}`,
65
+ progressChars: '■■',
66
+ });
67
+ }
68
+ }
69
+ return CustomRspackProgressPlugin;
70
+ }
71
+ return webpackbar_1.default;
72
+ }
73
+ //# sourceMappingURL=currentBundler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"currentBundler.js","sourceRoot":"","sources":["../src/currentBundler.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAwBH,8CAeC;AAED,8DAWC;AAED,kDAUC;AAED,sCAUC;AAED,oDAsBC;;AAlGD,8DAA8B;AAC9B,oEAAoC;AACpC,8FAA2D;AAC3D,sFAAoD;AACpD,iDAA4C;AAc5C,SAAS,QAAQ,CAAC,UAA2B;IAC3C,OAAO,UAAU,CAAC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AM,CAAC,cAAc;YAC5D,YAAY,EAAC,IAAI,EAAE,KAAK,GAAG,OAAO,EAAkC;gBAClE,uEAAuE;gBACvE,yDAAyD;gBACzD,KAAK,CAAC;oBACJ,MAAM,EAAE,IAAI;oBACZ,QAAQ,EAAE,4BAA4B,KAAK,0CAA0C;oBACrF,aAAa,EAAE,IAAI;iBACpB,CAAC,CAAC;YACL,CAAC;SACF;QACD,OAAO,0BAA0D,CAAC;IACpE,CAAC;IAED,OAAO,oBAAU,CAAC;AACpB,CAAC"}
@@ -0,0 +1,17 @@
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 { MinimizerOptions as JsMinimizerOptions, CustomOptions } from 'terser-webpack-plugin';
8
+ import type { MinimizerOptions as CssMinimizerOptions } from 'css-minimizer-webpack-plugin';
9
+ export type FasterModule = Awaited<typeof import('@docusaurus/faster')>;
10
+ export declare function importRspack(): Promise<FasterModule['rspack']>;
11
+ export declare function importSwcLoader(): Promise<string>;
12
+ export declare function importGetSwcLoaderOptions(): Promise<FasterModule['getSwcLoaderOptions']>;
13
+ export declare function importSwcJsMinimizerOptions(): Promise<JsMinimizerOptions<CustomOptions>>;
14
+ export declare function importSwcHtmlMinifier(): Promise<ReturnType<FasterModule['getSwcHtmlMinifier']>>;
15
+ export declare function importGetBrowserslistQueries(): Promise<FasterModule['getBrowserslistQueries']>;
16
+ export declare function importLightningCssMinimizerOptions(): Promise<CssMinimizerOptions<CustomOptions>>;
17
+ //# sourceMappingURL=importFaster.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"importFaster.d.ts","sourceRoot":"","sources":["../src/importFaster.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EACV,gBAAgB,IAAI,kBAAkB,EACtC,aAAa,EACd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAC,gBAAgB,IAAI,mBAAmB,EAAC,MAAM,8BAA8B,CAAC;AAE1F,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,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC,CAGvD;AAED,wBAAsB,yBAAyB,IAAI,OAAO,CACxD,YAAY,CAAC,qBAAqB,CAAC,CACpC,CAGA;AAED,wBAAsB,2BAA2B,IAAI,OAAO,CAC1D,kBAAkB,CAAC,aAAa,CAAC,CAClC,CAGA;AAED,wBAAsB,qBAAqB,IAAI,OAAO,CACpD,UAAU,CAAC,YAAY,CAAC,oBAAoB,CAAC,CAAC,CAC/C,CAGA;AAED,wBAAsB,4BAA4B,IAAI,OAAO,CAC3D,YAAY,CAAC,wBAAwB,CAAC,CACvC,CAGA;AAED,wBAAsB,kCAAkC,IAAI,OAAO,CACjE,mBAAmB,CAAC,aAAa,CAAC,CACnC,CAGA"}
@@ -0,0 +1,57 @@
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.importSwcLoader = importSwcLoader;
11
+ exports.importGetSwcLoaderOptions = importGetSwcLoaderOptions;
12
+ exports.importSwcJsMinimizerOptions = importSwcJsMinimizerOptions;
13
+ exports.importSwcHtmlMinifier = importSwcHtmlMinifier;
14
+ exports.importGetBrowserslistQueries = importGetBrowserslistQueries;
15
+ exports.importLightningCssMinimizerOptions = importLightningCssMinimizerOptions;
16
+ const tslib_1 = require("tslib");
17
+ const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
18
+ async function importFaster() {
19
+ return import('@docusaurus/faster');
20
+ }
21
+ async function ensureFaster() {
22
+ try {
23
+ return await importFaster();
24
+ }
25
+ catch (error) {
26
+ 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 });
27
+ }
28
+ }
29
+ async function importRspack() {
30
+ const faster = await ensureFaster();
31
+ return faster.rspack;
32
+ }
33
+ async function importSwcLoader() {
34
+ const faster = await ensureFaster();
35
+ return faster.swcLoader;
36
+ }
37
+ async function importGetSwcLoaderOptions() {
38
+ const faster = await ensureFaster();
39
+ return faster.getSwcLoaderOptions;
40
+ }
41
+ async function importSwcJsMinimizerOptions() {
42
+ const faster = await ensureFaster();
43
+ return faster.getSwcJsMinimizerOptions();
44
+ }
45
+ async function importSwcHtmlMinifier() {
46
+ const faster = await ensureFaster();
47
+ return faster.getSwcHtmlMinifier();
48
+ }
49
+ async function importGetBrowserslistQueries() {
50
+ const faster = await ensureFaster();
51
+ return faster.getBrowserslistQueries;
52
+ }
53
+ async function importLightningCssMinimizerOptions() {
54
+ const faster = await ensureFaster();
55
+ return faster.getLightningCssMinimizerOptions();
56
+ }
57
+ //# sourceMappingURL=importFaster.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"importFaster.js","sourceRoot":"","sources":["../src/importFaster.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AA4BH,oCAGC;AAED,0CAGC;AAED,8DAKC;AAED,kEAKC;AAED,sDAKC;AAED,oEAKC;AAED,gFAKC;;AArED,wEAAwC;AASxC,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,UAAU,YAAY;IAChC,MAAM,MAAM,GAAG,MAAM,YAAY,EAAE,CAAC;IACpC,OAAO,MAAM,CAAC,MAAM,CAAC;AACvB,CAAC;AAEM,KAAK,UAAU,eAAe;IACnC,MAAM,MAAM,GAAG,MAAM,YAAY,EAAE,CAAC;IACpC,OAAO,MAAM,CAAC,SAAS,CAAC;AAC1B,CAAC;AAEM,KAAK,UAAU,yBAAyB;IAG7C,MAAM,MAAM,GAAG,MAAM,YAAY,EAAE,CAAC;IACpC,OAAO,MAAM,CAAC,mBAAmB,CAAC;AACpC,CAAC;AAEM,KAAK,UAAU,2BAA2B;IAG/C,MAAM,MAAM,GAAG,MAAM,YAAY,EAAE,CAAC;IACpC,OAAO,MAAM,CAAC,wBAAwB,EAAuC,CAAC;AAChF,CAAC;AAEM,KAAK,UAAU,qBAAqB;IAGzC,MAAM,MAAM,GAAG,MAAM,YAAY,EAAE,CAAC;IACpC,OAAO,MAAM,CAAC,kBAAkB,EAAE,CAAC;AACrC,CAAC;AAEM,KAAK,UAAU,4BAA4B;IAGhD,MAAM,MAAM,GAAG,MAAM,YAAY,EAAE,CAAC;IACpC,OAAO,MAAM,CAAC,sBAAsB,CAAC;AACvC,CAAC;AAEM,KAAK,UAAU,kCAAkC;IAGtD,MAAM,MAAM,GAAG,MAAM,YAAY,EAAE,CAAC;IACpC,OAAO,MAAM,CAAC,+BAA+B,EAAwC,CAAC;AACxF,CAAC"}
package/lib/index.d.ts CHANGED
@@ -4,26 +4,10 @@
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 WebpackBar from 'webpackbar';
8
- import MiniCssExtractPlugin from 'mini-css-extract-plugin';
9
- import CopyWebpackPlugin from 'copy-webpack-plugin';
10
- import type { CurrentBundler, DocusaurusConfig } from '@docusaurus/types';
11
- type SiteConfigSlice = {
12
- future: {
13
- experimental_faster: Pick<DocusaurusConfig['future']['experimental_faster'], 'rspackBundler'>;
14
- };
15
- };
16
- export declare function getCurrentBundler({ siteConfig, }: {
17
- siteConfig: SiteConfigSlice;
18
- }): Promise<CurrentBundler>;
19
- export declare function getCSSExtractPlugin({ currentBundler, }: {
20
- currentBundler: CurrentBundler;
21
- }): Promise<typeof MiniCssExtractPlugin>;
22
- export declare function getCopyPlugin({ currentBundler, }: {
23
- currentBundler: CurrentBundler;
24
- }): Promise<typeof CopyWebpackPlugin>;
25
- export declare function getProgressBarPlugin({ currentBundler, }: {
26
- currentBundler: CurrentBundler;
27
- }): Promise<typeof WebpackBar>;
28
- export {};
7
+ export { printStatsWarnings, formatStatsErrorMessage, compile } from './compiler';
8
+ export { getCurrentBundler, getCSSExtractPlugin, getCopyPlugin, getProgressBarPlugin, } from './currentBundler';
9
+ export { getMinimizers } from './minification';
10
+ export { getHtmlMinifier, type HtmlMinifier, type HtmlMinifierType, } from './minifyHtml';
11
+ export { createJsLoaderFactory } from './loaders/jsLoader';
12
+ export { createStyleLoadersFactory } from './loaders/styleLoader';
29
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAC3D,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AAEpD,OAAO,KAAK,EAAC,cAAc,EAAE,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AAGxE,KAAK,eAAe,GAAG;IACrB,MAAM,EAAE;QACN,mBAAmB,EAAE,IAAI,CACvB,gBAAgB,CAAC,QAAQ,CAAC,CAAC,qBAAqB,CAAC,EACjD,eAAe,CAChB,CAAC;KACH,CAAC;CACH,CAAC;AAMF,wBAAsB,iBAAiB,CAAC,EACtC,UAAU,GACX,EAAE;IACD,UAAU,EAAE,eAAe,CAAC;CAC7B,GAAG,OAAO,CAAC,cAAc,CAAC,CAW1B;AAED,wBAAsB,mBAAmB,CAAC,EACxC,cAAc,GACf,EAAE;IACD,cAAc,EAAE,cAAc,CAAC;CAChC,GAAG,OAAO,CAAC,OAAO,oBAAoB,CAAC,CAKvC;AAED,wBAAsB,aAAa,CAAC,EAClC,cAAc,GACf,EAAE;IACD,cAAc,EAAE,cAAc,CAAC;CAChC,GAAG,OAAO,CAAC,OAAO,iBAAiB,CAAC,CAMpC;AAED,wBAAsB,oBAAoB,CAAC,EACzC,cAAc,GACf,EAAE;IACD,cAAc,EAAE,cAAc,CAAC;CAChC,GAAG,OAAO,CAAC,OAAO,UAAU,CAAC,CAgB7B"}
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,GACrB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAC,aAAa,EAAC,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EACL,eAAe,EACf,KAAK,YAAY,EACjB,KAAK,gBAAgB,GACtB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,qBAAqB,EAAC,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAC,yBAAyB,EAAC,MAAM,uBAAuB,CAAC"}
package/lib/index.js CHANGED
@@ -6,56 +6,22 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.getCurrentBundler = getCurrentBundler;
10
- exports.getCSSExtractPlugin = getCSSExtractPlugin;
11
- exports.getCopyPlugin = getCopyPlugin;
12
- exports.getProgressBarPlugin = getProgressBarPlugin;
13
- const tslib_1 = require("tslib");
14
- const webpack_1 = tslib_1.__importDefault(require("webpack"));
15
- const webpackbar_1 = tslib_1.__importDefault(require("webpackbar"));
16
- const mini_css_extract_plugin_1 = tslib_1.__importDefault(require("mini-css-extract-plugin"));
17
- const copy_webpack_plugin_1 = tslib_1.__importDefault(require("copy-webpack-plugin"));
18
- const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
19
- function isRspack(siteConfig) {
20
- return siteConfig.future.experimental_faster.rspackBundler;
21
- }
22
- async function getCurrentBundler({ siteConfig, }) {
23
- if (isRspack(siteConfig)) {
24
- // TODO add support for Rspack
25
- logger_1.default.error('Rspack bundler is not supported yet, will use Webpack instead');
26
- }
27
- return {
28
- name: 'webpack',
29
- instance: webpack_1.default,
30
- };
31
- }
32
- async function getCSSExtractPlugin({ currentBundler, }) {
33
- if (currentBundler.name === 'rspack') {
34
- throw new Error('Rspack bundler is not supported yet');
35
- }
36
- return mini_css_extract_plugin_1.default;
37
- }
38
- async function getCopyPlugin({ currentBundler, }) {
39
- if (currentBundler.name === 'rspack') {
40
- throw new Error('Rspack bundler is not supported yet');
41
- }
42
- // https://github.com/webpack-contrib/copy-webpack-plugin
43
- return copy_webpack_plugin_1.default;
44
- }
45
- async function getProgressBarPlugin({ currentBundler, }) {
46
- if (currentBundler.name === 'rspack') {
47
- class CustomRspackProgressPlugin extends currentBundler.instance
48
- .ProgressPlugin {
49
- constructor({ name }) {
50
- // TODO add support for color
51
- // Unfortunately the rspack.ProgressPlugin does not have a name option
52
- // See https://rspack.dev/plugins/webpack/progress-plugin
53
- // @ts-expect-error: adapt Rspack ProgressPlugin constructor
54
- super({ prefix: name });
55
- }
56
- }
57
- return CustomRspackProgressPlugin;
58
- }
59
- return webpackbar_1.default;
60
- }
9
+ exports.createStyleLoadersFactory = exports.createJsLoaderFactory = exports.getHtmlMinifier = exports.getMinimizers = exports.getProgressBarPlugin = exports.getCopyPlugin = exports.getCSSExtractPlugin = exports.getCurrentBundler = exports.compile = exports.formatStatsErrorMessage = exports.printStatsWarnings = void 0;
10
+ var compiler_1 = require("./compiler");
11
+ Object.defineProperty(exports, "printStatsWarnings", { enumerable: true, get: function () { return compiler_1.printStatsWarnings; } });
12
+ Object.defineProperty(exports, "formatStatsErrorMessage", { enumerable: true, get: function () { return compiler_1.formatStatsErrorMessage; } });
13
+ Object.defineProperty(exports, "compile", { enumerable: true, get: function () { return compiler_1.compile; } });
14
+ var currentBundler_1 = require("./currentBundler");
15
+ Object.defineProperty(exports, "getCurrentBundler", { enumerable: true, get: function () { return currentBundler_1.getCurrentBundler; } });
16
+ Object.defineProperty(exports, "getCSSExtractPlugin", { enumerable: true, get: function () { return currentBundler_1.getCSSExtractPlugin; } });
17
+ Object.defineProperty(exports, "getCopyPlugin", { enumerable: true, get: function () { return currentBundler_1.getCopyPlugin; } });
18
+ Object.defineProperty(exports, "getProgressBarPlugin", { enumerable: true, get: function () { return currentBundler_1.getProgressBarPlugin; } });
19
+ var minification_1 = require("./minification");
20
+ Object.defineProperty(exports, "getMinimizers", { enumerable: true, get: function () { return minification_1.getMinimizers; } });
21
+ var minifyHtml_1 = require("./minifyHtml");
22
+ Object.defineProperty(exports, "getHtmlMinifier", { enumerable: true, get: function () { return minifyHtml_1.getHtmlMinifier; } });
23
+ var jsLoader_1 = require("./loaders/jsLoader");
24
+ Object.defineProperty(exports, "createJsLoaderFactory", { enumerable: true, get: function () { return jsLoader_1.createJsLoaderFactory; } });
25
+ var styleLoader_1 = require("./loaders/styleLoader");
26
+ Object.defineProperty(exports, "createStyleLoadersFactory", { enumerable: true, get: function () { return styleLoader_1.createStyleLoadersFactory; } });
61
27
  //# 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;;AAuBH,8CAeC;AAED,kDASC;AAED,sCAUC;AAED,oDAoBC;;AAjFD,8DAA8B;AAC9B,oEAAoC;AACpC,8FAA2D;AAC3D,sFAAoD;AACpD,wEAAwC;AAaxC,SAAS,QAAQ,CA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],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,uCAAgF;AAAxE,8GAAA,kBAAkB,OAAA;AAAE,mHAAA,uBAAuB,OAAA;AAAE,mGAAA,OAAO,OAAA;AAE5D,mDAK0B;AAJxB,mHAAA,iBAAiB,OAAA;AACjB,qHAAA,mBAAmB,OAAA;AACnB,+GAAA,aAAa,OAAA;AACb,sHAAA,oBAAoB,OAAA;AAGtB,+CAA6C;AAArC,6GAAA,aAAa,OAAA;AACrB,2CAIsB;AAHpB,6GAAA,eAAe,OAAA;AAIjB,+CAAyD;AAAjD,iHAAA,qBAAqB,OAAA;AAC7B,qDAAgE;AAAxD,wHAAA,yBAAyB,OAAA"}
@@ -0,0 +1,16 @@
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 { ConfigureWebpackUtils, DocusaurusConfig } from '@docusaurus/types';
8
+ export declare function createJsLoaderFactory({ siteConfig, }: {
9
+ siteConfig: {
10
+ webpack?: DocusaurusConfig['webpack'];
11
+ future: {
12
+ experimental_faster: DocusaurusConfig['future']['experimental_faster'];
13
+ };
14
+ };
15
+ }): Promise<ConfigureWebpackUtils['getJSLoader']>;
16
+ //# sourceMappingURL=jsLoader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsLoader.d.ts","sourceRoot":"","sources":["../../src/loaders/jsLoader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAC,qBAAqB,EAAE,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AA0C/E,wBAAsB,qBAAqB,CAAC,EAC1C,UAAU,GACX,EAAE;IACD,UAAU,EAAE;QACV,OAAO,CAAC,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAC;QACtC,MAAM,EAAE;YACN,mBAAmB,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC,qBAAqB,CAAC,CAAC;SACxE,CAAC;KACH,CAAC;CACH,GAAG,OAAO,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAC,CA2BhD"}
@@ -0,0 +1,67 @@
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.createJsLoaderFactory = createJsLoaderFactory;
10
+ const babel_1 = require("@docusaurus/babel");
11
+ const importFaster_1 = require("../importFaster");
12
+ const currentBundler_1 = require("../currentBundler");
13
+ const BabelJsLoaderFactory = ({ isServer, babelOptions, }) => {
14
+ return {
15
+ loader: require.resolve('babel-loader'),
16
+ options: (0, babel_1.getBabelOptions)({ isServer, babelOptions }),
17
+ };
18
+ };
19
+ async function createSwcJsLoaderFactory() {
20
+ const loader = await (0, importFaster_1.importSwcLoader)();
21
+ const getOptions = await (0, importFaster_1.importGetSwcLoaderOptions)();
22
+ return ({ isServer }) => {
23
+ return {
24
+ loader,
25
+ options: getOptions({ isServer }),
26
+ };
27
+ };
28
+ }
29
+ // Same as swcLoader, except we use the built-in SWC loader
30
+ async function createRspackSwcJsLoaderFactory() {
31
+ const loader = 'builtin:swc-loader';
32
+ const getOptions = await (0, importFaster_1.importGetSwcLoaderOptions)();
33
+ return ({ isServer }) => {
34
+ return {
35
+ loader,
36
+ options: getOptions({ isServer }),
37
+ };
38
+ };
39
+ }
40
+ // Confusing: function that creates a function that creates actual js loaders
41
+ // This is done on purpose because the js loader factory is a public API
42
+ // It is injected in configureWebpack plugin lifecycle for plugin authors
43
+ async function createJsLoaderFactory({ siteConfig, }) {
44
+ const currentBundler = await (0, currentBundler_1.getCurrentBundler)({ siteConfig });
45
+ const isSWCLoader = siteConfig.future.experimental_faster.swcJsLoader;
46
+ if (currentBundler.name === 'rspack') {
47
+ return isSWCLoader
48
+ ? createRspackSwcJsLoaderFactory()
49
+ : BabelJsLoaderFactory;
50
+ }
51
+ const jsLoader = siteConfig.webpack?.jsLoader ?? 'babel';
52
+ if (jsLoader instanceof Function &&
53
+ siteConfig.future?.experimental_faster.swcJsLoader) {
54
+ throw new Error("You can't use a custom webpack.jsLoader and experimental_faster.swcJsLoader at the same time");
55
+ }
56
+ if (jsLoader instanceof Function) {
57
+ return ({ isServer }) => jsLoader(isServer);
58
+ }
59
+ if (siteConfig.future?.experimental_faster.swcJsLoader) {
60
+ return createSwcJsLoaderFactory();
61
+ }
62
+ if (jsLoader === 'babel') {
63
+ return BabelJsLoaderFactory;
64
+ }
65
+ throw new Error(`Docusaurus bug: unexpected jsLoader value${jsLoader}`);
66
+ }
67
+ //# sourceMappingURL=jsLoader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsLoader.js","sourceRoot":"","sources":["../../src/loaders/jsLoader.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AA+CH,sDAoCC;AAjFD,6CAAkD;AAClD,kDAA2E;AAC3E,sDAAoD;AAGpD,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,KAAK,UAAU,wBAAwB;IAGrC,MAAM,MAAM,GAAG,MAAM,IAAA,8BAAe,GAAE,CAAC;IACvC,MAAM,UAAU,GAAG,MAAM,IAAA,wCAAyB,GAAE,CAAC;IACrD,OAAO,CAAC,EAAC,QAAQ,EAAC,EAAE,EAAE;QACpB,OAAO;YACL,MAAM;YACN,OAAO,EAAE,UAAU,CAAC,EAAC,QAAQ,EAAC,CAAC;SAChC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED,2DAA2D;AAC3D,KAAK,UAAU,8BAA8B;IAG3C,MAAM,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IAAI,KAAK,CAAC,4CAA4C,QAAQ,EAAE,CAAC,CAAC;AAC1E,CAAC"}
@@ -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
+ import type { ConfigureWebpackUtils, CurrentBundler } from '@docusaurus/types';
8
+ export declare function createStyleLoadersFactory({ currentBundler, }: {
9
+ currentBundler: CurrentBundler;
10
+ }): Promise<ConfigureWebpackUtils['getStyleLoaders']>;
11
+ //# sourceMappingURL=styleLoader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styleLoader.d.ts","sourceRoot":"","sources":["../../src/loaders/styleLoader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAC,qBAAqB,EAAE,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAE7E,wBAAsB,yBAAyB,CAAC,EAC9C,cAAc,GACf,EAAE;IACD,cAAc,EAAE,cAAc,CAAC;CAChC,GAAG,OAAO,CAAC,qBAAqB,CAAC,iBAAiB,CAAC,CAAC,CAiEpD"}
@@ -0,0 +1,68 @@
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.createStyleLoadersFactory = createStyleLoadersFactory;
10
+ const currentBundler_1 = require("../currentBundler");
11
+ async function createStyleLoadersFactory({ currentBundler, }) {
12
+ const CssExtractPlugin = await (0, currentBundler_1.getCSSExtractPlugin)({ currentBundler });
13
+ return function getStyleLoaders(isServer, cssOptionsArg = {}) {
14
+ const cssOptions = {
15
+ // TODO turn esModule on later, see https://github.com/facebook/docusaurus/pull/6424
16
+ esModule: false,
17
+ ...cssOptionsArg,
18
+ };
19
+ // On the server we don't really need to extract/emit CSS
20
+ // We only need to transform CSS module imports to a styles object
21
+ if (isServer) {
22
+ return cssOptions.modules
23
+ ? [
24
+ {
25
+ loader: require.resolve('css-loader'),
26
+ options: cssOptions,
27
+ },
28
+ ]
29
+ : // Ignore regular CSS files
30
+ [{ loader: require.resolve('null-loader') }];
31
+ }
32
+ return [
33
+ {
34
+ loader: CssExtractPlugin.loader,
35
+ options: {
36
+ esModule: true,
37
+ },
38
+ },
39
+ {
40
+ loader: require.resolve('css-loader'),
41
+ options: cssOptions,
42
+ },
43
+ // TODO apart for configurePostCss(), do we really need this loader?
44
+ // Note: using postcss here looks inefficient/duplicate
45
+ // But in practice, it's not a big deal because css-loader also uses postcss
46
+ // and is able to reuse the parsed AST from postcss-loader
47
+ // See https://github.com/webpack-contrib/css-loader/blob/master/src/index.js#L159
48
+ {
49
+ // Options for PostCSS as we reference these options twice
50
+ // Adds vendor prefixing based on your specified browser support in
51
+ // package.json
52
+ loader: require.resolve('postcss-loader'),
53
+ options: {
54
+ postcssOptions: {
55
+ // Necessary for external CSS imports to work
56
+ // https://github.com/facebook/create-react-app/issues/2677
57
+ ident: 'postcss',
58
+ plugins: [
59
+ // eslint-disable-next-line global-require
60
+ require('autoprefixer'),
61
+ ],
62
+ },
63
+ },
64
+ },
65
+ ];
66
+ };
67
+ }
68
+ //# sourceMappingURL=styleLoader.js.map