@docusaurus/faster 0.0.0-6111 → 0.0.0-6115

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 CHANGED
@@ -7,15 +7,17 @@
7
7
  import Rspack from '@rspack/core';
8
8
  import * as lightningcss from 'lightningcss';
9
9
  import { minify as swcHtmlMinifier } from '@swc/html';
10
- import type { RuleSetRule } from 'webpack';
11
- import type { JsMinifyOptions } from '@swc/core';
10
+ import type { JsMinifyOptions, Options as SwcOptions } from '@swc/core';
11
+ export declare const swcLoader: string;
12
+ export declare const getSwcLoaderOptions: ({ isServer, }: {
13
+ isServer: boolean;
14
+ }) => SwcOptions;
12
15
  export declare const rspack: typeof Rspack;
13
16
  export declare function getSwcHtmlMinifier(): typeof swcHtmlMinifier;
14
- export declare function getSwcJsLoaderFactory({ isServer, }: {
15
- isServer: boolean;
16
- }): RuleSetRule;
17
17
  export declare function getSwcJsMinimizerOptions(): JsMinifyOptions;
18
- export declare function getBrowserslistQueries(): string[];
18
+ export declare function getBrowserslistQueries({ isServer, }: {
19
+ isServer: boolean;
20
+ }): string[];
19
21
  type LightningCssMinimizerOptions = Omit<lightningcss.TransformOptions<never>, 'filename' | 'code'>;
20
22
  export declare function getLightningCssMinimizerOptions(): LightningCssMinimizerOptions;
21
23
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,MAAM,MAAM,cAAc,CAAC;AAClC,OAAO,KAAK,YAAY,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAC,MAAM,IAAI,eAAe,EAAC,MAAM,WAAW,CAAC;AACpD,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,SAAS,CAAC;AACzC,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,WAAW,CAAC;AAE/C,eAAO,MAAM,MAAM,eAAS,CAAC;AAE7B,wBAAgB,kBA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@ -6,9 +6,8 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.rspack = void 0;
9
+ exports.rspack = exports.getSwcLoaderOptions = exports.swcLoader = void 0;
10
10
  exports.getSwcHtmlMinifier = getSwcHtmlMinifier;
11
- exports.getSwcJsLoaderFactory = getSwcJsLoaderFactory;
12
11
  exports.getSwcJsMinimizerOptions = getSwcJsMinimizerOptions;
13
12
  exports.getBrowserslistQueries = getBrowserslistQueries;
14
13
  exports.getLightningCssMinimizerOptions = getLightningCssMinimizerOptions;
@@ -17,31 +16,29 @@ const core_1 = tslib_1.__importDefault(require("@rspack/core"));
17
16
  const lightningcss = tslib_1.__importStar(require("lightningcss"));
18
17
  const browserslist_1 = tslib_1.__importDefault(require("browserslist"));
19
18
  const html_1 = require("@swc/html");
20
- exports.rspack = core_1.default;
21
- function getSwcHtmlMinifier() {
22
- return html_1.minify;
23
- }
24
- function getSwcJsLoaderFactory({ isServer, }) {
19
+ exports.swcLoader = require.resolve('swc-loader');
20
+ const getSwcLoaderOptions = ({ isServer, }) => {
25
21
  return {
26
- loader: require.resolve('swc-loader'),
27
- options: {
28
- jsc: {
29
- parser: {
30
- syntax: 'typescript',
31
- tsx: true,
32
- },
33
- transform: {
34
- react: {
35
- runtime: 'automatic',
36
- },
37
- },
38
- target: 'es2017',
22
+ env: {
23
+ targets: getBrowserslistQueries({ isServer }),
24
+ },
25
+ jsc: {
26
+ parser: {
27
+ syntax: 'typescript',
28
+ tsx: true,
39
29
  },
40
- module: {
41
- type: isServer ? 'commonjs' : 'es6',
30
+ transform: {
31
+ react: {
32
+ runtime: 'automatic',
33
+ },
42
34
  },
43
35
  },
44
36
  };
37
+ };
38
+ exports.getSwcLoaderOptions = getSwcLoaderOptions;
39
+ exports.rspack = core_1.default;
40
+ function getSwcHtmlMinifier() {
41
+ return html_1.minify;
45
42
  }
46
43
  // Note: these options are similar to what we use in core
47
44
  // They should rather be kept in sync for now to avoid any unexpected behavior
@@ -65,7 +62,10 @@ function getSwcJsMinimizerOptions() {
65
62
  }
66
63
  // We need this because of Rspack built-in LightningCSS integration
67
64
  // See https://github.com/orgs/browserslist/discussions/846
68
- function getBrowserslistQueries() {
65
+ function getBrowserslistQueries({ isServer, }) {
66
+ if (isServer) {
67
+ return [`node ${process.versions.node}`];
68
+ }
69
69
  const queries = browserslist_1.default.loadConfig({ path: process.cwd() }) ?? [
70
70
  ...browserslist_1.default.defaults,
71
71
  ];
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAWH,gDAEC;AAED,sDAyBC;AAMD,4DAeC;AAID,wDAKC;AAUD,0EAGC;;AAjFD,gEAAkC;AAClC,mEAA6C;AAC7C,wEAAwC;AACxC,oCAAoD;AAIvC,QAAA,MAAM,GAAG,cAAM,CAAC;AAE7B,SAAgB,kBAAkB;IAChC,OAAO,aAAe,CAAC;AACzB,CAAC;AAED,SAAgB,qBAAqB,CAAC,EACpC,QAAQ,GAGT;IACC,OAAO;QACL,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC;QACrC,OAAO,EAAE;YACP,GAAG,EAAE;gBACH,MAAM,EAAE;oBACN,MAAM,EAAE,YAAY;oBACpB,GAAG,EAAE,IAAI;iBACV;gBACD,SAAS,EAAE;oBACT,KAAK,EAAE;wBACL,OAAO,EAAE,WAAW;qBACrB;iBACF;gBACD,MAAM,EAAE,QAAQ;aACjB;YACD,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK;aACpC;SACF;KACF,CAAC;AACJ,CAAC;AAED,yDAAyD;AACzD,8EAA8E;AAC9E,gFAAgF;AAChF,2BAA2B;AAC3B,SAAgB,wBAAwB;IACtC,OAAO;QACL,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE;YACR,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BW,QAAA,mBAAmB,uBAqB9B;AAEW,QAAA,MAAM,GAAG,cAAM,CAAC;AAE7B,SAAgB,kBAAkB;IAChC,OAAO,aAAe,CAAC;AACzB,CAAC;AAED,yDAAyD;AACzD,8EAA8E;AAC9E,gFAAgF;AAChF,2BAA2B;AAC3B,SAAgB,wBAAwB;IACtC,OAAO;QACL,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE;YACR,IAAI,EAAE,CAAC;SACR;QACD,MAAM,EAAE,IAAI;QACZ,MAAM,EAAE,IAAI;QACZ,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE;YACN,IAAI,EAAE,CAAC;YACP,QAAQ,EAAE,KAAK;YACf,UAAU,EAAE,IAAI;SACjB;KACF,CAAC;AACJ,CAAC;AAED,mEAAmE;AACnE,2DAA2D;AAC3D,SAAgB,sBAAsB,CAAC,EACrC,QAAQ,GAGT;IACC,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,CAAC,QAAQ,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED,MAAM,OAAO,GAAG,sBAAY,CAAC,UAAU,CAAC,EAAC,IAAI,EAAE,OAAO,CAAC,GAAG,EAAE,EAAC,CAAC,IAAI;QAChE,GAAG,sBAAY,CAAC,QAAQ;KACzB,CAAC;IACF,OAAO,OAAO,CAAC;AACjB,CAAC;AAUD,SAAgB,+BAA+B;IAC7C,MAAM,OAAO,GAAG,IAAA,sBAAY,GAAE,CAAC;IAC/B,OAAO,EAAC,OAAO,EAAE,YAAY,CAAC,qBAAqB,CAAC,OAAO,CAAC,EAAC,CAAC;AAChE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/faster",
3
- "version": "0.0.0-6111",
3
+ "version": "0.0.0-6115",
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",
@@ -32,5 +32,5 @@
32
32
  "peerDependencies": {
33
33
  "@docusaurus/types": "*"
34
34
  },
35
- "gitHead": "d55731cf6fb644eab1a129d60d7f31c12adc81bd"
35
+ "gitHead": "6ce8454eb6aa13b24a5c5f9a95cbb0bf4a177bd7"
36
36
  }
package/src/index.ts CHANGED
@@ -9,40 +9,37 @@ import Rspack from '@rspack/core';
9
9
  import * as lightningcss from 'lightningcss';
10
10
  import browserslist from 'browserslist';
11
11
  import {minify as swcHtmlMinifier} from '@swc/html';
12
- import type {RuleSetRule} from 'webpack';
13
- import type {JsMinifyOptions} from '@swc/core';
12
+ import type {JsMinifyOptions, Options as SwcOptions} from '@swc/core';
14
13
 
15
- export const rspack = Rspack;
16
-
17
- export function getSwcHtmlMinifier(): typeof swcHtmlMinifier {
18
- return swcHtmlMinifier;
19
- }
14
+ export const swcLoader = require.resolve('swc-loader');
20
15
 
21
- export function getSwcJsLoaderFactory({
16
+ export const getSwcLoaderOptions = ({
22
17
  isServer,
23
18
  }: {
24
19
  isServer: boolean;
25
- }): RuleSetRule {
20
+ }): SwcOptions => {
26
21
  return {
27
- loader: require.resolve('swc-loader'),
28
- options: {
29
- jsc: {
30
- parser: {
31
- syntax: 'typescript',
32
- tsx: true,
33
- },
34
- transform: {
35
- react: {
36
- runtime: 'automatic',
37
- },
38
- },
39
- target: 'es2017',
22
+ env: {
23
+ targets: getBrowserslistQueries({isServer}),
24
+ },
25
+ jsc: {
26
+ parser: {
27
+ syntax: 'typescript',
28
+ tsx: true,
40
29
  },
41
- module: {
42
- type: isServer ? 'commonjs' : 'es6',
30
+ transform: {
31
+ react: {
32
+ runtime: 'automatic',
33
+ },
43
34
  },
44
35
  },
45
36
  };
37
+ };
38
+
39
+ export const rspack = Rspack;
40
+
41
+ export function getSwcHtmlMinifier(): typeof swcHtmlMinifier {
42
+ return swcHtmlMinifier;
46
43
  }
47
44
 
48
45
  // Note: these options are similar to what we use in core
@@ -68,7 +65,15 @@ export function getSwcJsMinimizerOptions(): JsMinifyOptions {
68
65
 
69
66
  // We need this because of Rspack built-in LightningCSS integration
70
67
  // See https://github.com/orgs/browserslist/discussions/846
71
- export function getBrowserslistQueries(): string[] {
68
+ export function getBrowserslistQueries({
69
+ isServer,
70
+ }: {
71
+ isServer: boolean;
72
+ }): string[] {
73
+ if (isServer) {
74
+ return [`node ${process.versions.node}`];
75
+ }
76
+
72
77
  const queries = browserslist.loadConfig({path: process.cwd()}) ?? [
73
78
  ...browserslist.defaults,
74
79
  ];