@modern-js/builder 3.0.0-alpha.1 → 3.0.0-alpha.2

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 (136) hide show
  1. package/dist/cjs/createBuilder.js +96 -0
  2. package/dist/cjs/index.js +59 -0
  3. package/dist/cjs/plugins/devtools.js +47 -0
  4. package/dist/cjs/plugins/emitRouteFile.js +75 -0
  5. package/dist/cjs/plugins/environmentDefaults.js +100 -0
  6. package/dist/cjs/plugins/globalVars.js +55 -0
  7. package/dist/cjs/plugins/htmlMinify.js +115 -0
  8. package/dist/cjs/plugins/manifest.js +52 -0
  9. package/dist/cjs/plugins/postcss.js +118 -0
  10. package/dist/cjs/plugins/runtimeChunk.js +54 -0
  11. package/dist/cjs/rsc/common.js +157 -0
  12. package/dist/cjs/rsc/plugins/rsbuild-rsc-plugin.js +169 -0
  13. package/dist/cjs/rsc/plugins/rspack-rsc-client-plugin.js +187 -0
  14. package/dist/cjs/rsc/plugins/rspack-rsc-server-plugin.js +245 -0
  15. package/dist/cjs/rsc/rsc-client-loader.js +71 -0
  16. package/dist/cjs/rsc/rsc-css-loader.js +42 -0
  17. package/dist/cjs/rsc/rsc-server-loader.js +102 -0
  18. package/dist/cjs/rsc/rsc-ssr-loader.js +60 -0
  19. package/dist/cjs/shared/devServer.js +87 -0
  20. package/dist/cjs/shared/getCssSupport.js +121 -0
  21. package/dist/cjs/shared/manifest.js +46 -0
  22. package/dist/cjs/shared/parseCommonConfig.js +209 -0
  23. package/dist/cjs/shared/rsc/rscClientBrowserFallback.js +64 -0
  24. package/dist/cjs/shared/rsc/rscEmptyModule.js +36 -0
  25. package/dist/cjs/shared/utils.js +115 -0
  26. package/dist/cjs/types.js +18 -0
  27. package/dist/compiled/postcss-load-config/index.d.ts +1 -0
  28. package/dist/compiled/postcss-load-config/index.js +608 -0
  29. package/dist/compiled/postcss-load-config/index.js.LICENSE.txt +13 -0
  30. package/dist/compiled/postcss-load-config/license +20 -0
  31. package/dist/compiled/postcss-load-config/package.json +1 -0
  32. package/dist/esm/createBuilder.mjs +59 -0
  33. package/dist/esm/index.mjs +4 -0
  34. package/dist/esm/plugins/devtools.mjs +13 -0
  35. package/dist/esm/plugins/emitRouteFile.mjs +28 -0
  36. package/dist/esm/plugins/environmentDefaults.mjs +66 -0
  37. package/dist/esm/plugins/globalVars.mjs +21 -0
  38. package/dist/esm/plugins/htmlMinify.mjs +81 -0
  39. package/dist/esm/plugins/manifest.mjs +18 -0
  40. package/dist/esm/plugins/postcss.mjs +81 -0
  41. package/dist/esm/plugins/runtimeChunk.mjs +20 -0
  42. package/dist/esm/rsc/common.mjs +87 -0
  43. package/dist/esm/rsc/plugins/rsbuild-rsc-plugin.mjs +124 -0
  44. package/dist/esm/rsc/plugins/rspack-rsc-client-plugin.mjs +143 -0
  45. package/dist/esm/rsc/plugins/rspack-rsc-server-plugin.mjs +211 -0
  46. package/dist/esm/rsc/rsc-client-loader.mjs +37 -0
  47. package/dist/esm/rsc/rsc-css-loader.mjs +8 -0
  48. package/dist/esm/rsc/rsc-server-loader.mjs +58 -0
  49. package/dist/esm/rsc/rsc-ssr-loader.mjs +26 -0
  50. package/dist/esm/shared/devServer.mjs +53 -0
  51. package/dist/esm/shared/getCssSupport.mjs +77 -0
  52. package/dist/esm/shared/manifest.mjs +12 -0
  53. package/dist/esm/shared/parseCommonConfig.mjs +172 -0
  54. package/dist/esm/shared/rsc/rscClientBrowserFallback.mjs +20 -0
  55. package/dist/esm/shared/rsc/rscEmptyModule.mjs +2 -0
  56. package/dist/esm/shared/utils.mjs +53 -0
  57. package/dist/esm/types.mjs +0 -0
  58. package/dist/esm-node/createBuilder.mjs +61 -0
  59. package/dist/esm-node/index.mjs +6 -0
  60. package/dist/esm-node/plugins/devtools.mjs +15 -0
  61. package/dist/esm-node/plugins/emitRouteFile.mjs +30 -0
  62. package/dist/esm-node/plugins/environmentDefaults.mjs +68 -0
  63. package/dist/esm-node/plugins/globalVars.mjs +23 -0
  64. package/dist/esm-node/plugins/htmlMinify.mjs +83 -0
  65. package/dist/esm-node/plugins/manifest.mjs +20 -0
  66. package/dist/esm-node/plugins/postcss.mjs +83 -0
  67. package/dist/esm-node/plugins/runtimeChunk.mjs +22 -0
  68. package/dist/esm-node/rsc/common.mjs +89 -0
  69. package/dist/esm-node/rsc/plugins/rsbuild-rsc-plugin.mjs +126 -0
  70. package/dist/esm-node/rsc/plugins/rspack-rsc-client-plugin.mjs +145 -0
  71. package/dist/esm-node/rsc/plugins/rspack-rsc-server-plugin.mjs +213 -0
  72. package/dist/esm-node/rsc/rsc-client-loader.mjs +39 -0
  73. package/dist/esm-node/rsc/rsc-css-loader.mjs +10 -0
  74. package/dist/esm-node/rsc/rsc-server-loader.mjs +60 -0
  75. package/dist/esm-node/rsc/rsc-ssr-loader.mjs +28 -0
  76. package/dist/esm-node/shared/devServer.mjs +55 -0
  77. package/dist/esm-node/shared/getCssSupport.mjs +79 -0
  78. package/dist/esm-node/shared/manifest.mjs +14 -0
  79. package/dist/esm-node/shared/parseCommonConfig.mjs +174 -0
  80. package/dist/esm-node/shared/rsc/rscClientBrowserFallback.mjs +25 -0
  81. package/dist/esm-node/shared/rsc/rscEmptyModule.mjs +4 -0
  82. package/dist/esm-node/shared/utils.mjs +55 -0
  83. package/dist/esm-node/types.mjs +2 -0
  84. package/dist/types/shared/rsc/rscClientBrowserFallback.d.ts +2 -0
  85. package/dist/types/shared/rsc/rscEmptyModule.d.ts +2 -0
  86. package/dist/{types.d.ts → types/types.d.ts} +2 -16
  87. package/package.json +35 -30
  88. package/dist/createBuilder.js +0 -153
  89. package/dist/index.js +0 -45
  90. package/dist/plugins/babel-post.d.ts +0 -5
  91. package/dist/plugins/babel-post.js +0 -57
  92. package/dist/plugins/devtools.js +0 -42
  93. package/dist/plugins/emitRouteFile.js +0 -70
  94. package/dist/plugins/environmentDefaults.js +0 -99
  95. package/dist/plugins/globalVars.js +0 -50
  96. package/dist/plugins/htmlMinify.js +0 -126
  97. package/dist/plugins/manifest.js +0 -54
  98. package/dist/plugins/postcss.js +0 -133
  99. package/dist/plugins/runtimeChunk.js +0 -55
  100. package/dist/rsc/common.js +0 -174
  101. package/dist/rsc/plugins/rsbuild-rsc-plugin.js +0 -173
  102. package/dist/rsc/plugins/rspack-rsc-client-plugin.js +0 -215
  103. package/dist/rsc/plugins/rspack-rsc-server-plugin.js +0 -290
  104. package/dist/rsc/rsc-client-loader.js +0 -70
  105. package/dist/rsc/rsc-css-loader.js +0 -30
  106. package/dist/rsc/rsc-server-loader.js +0 -95
  107. package/dist/rsc/rsc-ssr-loader.js +0 -58
  108. package/dist/shared/devServer.js +0 -83
  109. package/dist/shared/getCssSupport.js +0 -113
  110. package/dist/shared/manifest.js +0 -38
  111. package/dist/shared/parseCommonConfig.js +0 -232
  112. package/dist/shared/utils.js +0 -109
  113. package/dist/types.js +0 -16
  114. /package/dist/{createBuilder.d.ts → types/createBuilder.d.ts} +0 -0
  115. /package/dist/{index.d.ts → types/index.d.ts} +0 -0
  116. /package/dist/{plugins → types/plugins}/devtools.d.ts +0 -0
  117. /package/dist/{plugins → types/plugins}/emitRouteFile.d.ts +0 -0
  118. /package/dist/{plugins → types/plugins}/environmentDefaults.d.ts +0 -0
  119. /package/dist/{plugins → types/plugins}/globalVars.d.ts +0 -0
  120. /package/dist/{plugins → types/plugins}/htmlMinify.d.ts +0 -0
  121. /package/dist/{plugins → types/plugins}/manifest.d.ts +0 -0
  122. /package/dist/{plugins → types/plugins}/postcss.d.ts +0 -0
  123. /package/dist/{plugins → types/plugins}/runtimeChunk.d.ts +0 -0
  124. /package/dist/{rsc → types/rsc}/common.d.ts +0 -0
  125. /package/dist/{rsc → types/rsc}/plugins/rsbuild-rsc-plugin.d.ts +0 -0
  126. /package/dist/{rsc → types/rsc}/plugins/rspack-rsc-client-plugin.d.ts +0 -0
  127. /package/dist/{rsc → types/rsc}/plugins/rspack-rsc-server-plugin.d.ts +0 -0
  128. /package/dist/{rsc → types/rsc}/rsc-client-loader.d.ts +0 -0
  129. /package/dist/{rsc → types/rsc}/rsc-css-loader.d.ts +0 -0
  130. /package/dist/{rsc → types/rsc}/rsc-server-loader.d.ts +0 -0
  131. /package/dist/{rsc → types/rsc}/rsc-ssr-loader.d.ts +0 -0
  132. /package/dist/{shared → types/shared}/devServer.d.ts +0 -0
  133. /package/dist/{shared → types/shared}/getCssSupport.d.ts +0 -0
  134. /package/dist/{shared → types/shared}/manifest.d.ts +0 -0
  135. /package/dist/{shared → types/shared}/parseCommonConfig.d.ts +0 -0
  136. /package/dist/{shared → types/shared}/utils.d.ts +0 -0
@@ -1,95 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var rsc_server_loader_exports = {};
30
- __export(rsc_server_loader_exports, {
31
- default: () => rscServerLoader
32
- });
33
- module.exports = __toCommonJS(rsc_server_loader_exports);
34
- var import_path = __toESM(require("path"));
35
- var import_core = require("@swc/core");
36
- var import_common = require("./common");
37
- function extractMetadata(code) {
38
- const metadataRegex = /\/\* @modern-js-rsc-metadata\n([\s\S]*?)\*\//;
39
- const match = code.match(metadataRegex);
40
- if (!match)
41
- return null;
42
- try {
43
- const metadata = JSON.parse(match[1]);
44
- return metadata;
45
- } catch (e) {
46
- console.error("Failed to parse metadata:", e);
47
- return null;
48
- }
49
- }
50
- async function rscServerLoader(source) {
51
- this.cacheable(true);
52
- const callback = this.async();
53
- const { appDir, runtimePath = "@modern-js/runtime/rsc/server" } = this.getOptions();
54
- const result = await (0, import_core.transform)(source, {
55
- filename: this.resourcePath,
56
- jsc: {
57
- target: "es2020",
58
- experimental: {
59
- cacheRoot: import_path.default.resolve(appDir, "node_modules/.swc"),
60
- plugins: [
61
- [
62
- require.resolve("@modern-js/flight-server-transform-plugin"),
63
- {
64
- appDir,
65
- runtimePath
66
- }
67
- ]
68
- ]
69
- }
70
- },
71
- isModule: true
72
- });
73
- const { code, map } = result;
74
- const metadata = extractMetadata(code);
75
- if ((metadata === null || metadata === void 0 ? void 0 : metadata.directive) && metadata.directive === "client") {
76
- const { exportNames } = metadata;
77
- if (exportNames.length > 0) {
78
- (0, import_common.setRscBuildInfo)(this._module, {
79
- type: "client",
80
- resourcePath: this.resourcePath,
81
- clientReferences: exportNames
82
- });
83
- }
84
- } else if (metadata) {
85
- const { exportNames } = metadata;
86
- if (exportNames.length > 0) {
87
- (0, import_common.setRscBuildInfo)(this._module, {
88
- type: "server",
89
- resourcePath: this.resourcePath,
90
- exportNames: exportNames.map((item) => item.exportName)
91
- });
92
- }
93
- }
94
- return callback(null, code, map);
95
- }
@@ -1,58 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var rsc_ssr_loader_exports = {};
20
- __export(rsc_ssr_loader_exports, {
21
- default: () => rscSsrLoader
22
- });
23
- module.exports = __toCommonJS(rsc_ssr_loader_exports);
24
- var import_common = require("./common");
25
- async function rscSsrLoader(source, sourceMap) {
26
- this.cacheable(true);
27
- const callback = this.async();
28
- const ast = await (0, import_common.parseSource)(source);
29
- const hasDeclareServerDirective = await (0, import_common.isServerModule)(ast);
30
- const resourcePath = this.resourcePath;
31
- if (!hasDeclareServerDirective) {
32
- callback(null, source, sourceMap);
33
- return;
34
- }
35
- const exportedNames = await (0, import_common.getExportNames)(ast, true);
36
- const importsCode = `
37
- 'use server';
38
- `;
39
- const exportsCode = exportedNames.map((name) => {
40
- if (name === "default") {
41
- return `export default () => {throw new Error("Server actions must not be called during server-side rendering.")}`;
42
- } else {
43
- return `export const ${name} = () => {
44
- throw new Error("Server actions must not be called during server-side rendering.")
45
- }`;
46
- }
47
- }).join("\n");
48
- if (exportedNames.length > 0) {
49
- (0, import_common.setRscBuildInfo)(this._module, {
50
- type: "server",
51
- resourcePath,
52
- exportNames: exportedNames
53
- });
54
- }
55
- callback(null, `${importsCode}
56
- ${exportsCode}`, sourceMap);
57
- return;
58
- }
@@ -1,83 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var devServer_exports = {};
20
- __export(devServer_exports, {
21
- transformToRsbuildServerOptions: () => transformToRsbuildServerOptions
22
- });
23
- module.exports = __toCommonJS(devServer_exports);
24
- var import_utils = require("@modern-js/utils");
25
- var import_ts_deepmerge = require("ts-deepmerge");
26
- const defaultDevConfig = {
27
- writeToDisk: (file) => !file.includes(".hot-update."),
28
- hmr: true,
29
- liveReload: true,
30
- progressBar: true,
31
- client: {
32
- path: "/webpack-hmr",
33
- overlay: false,
34
- port: "<port>"
35
- }
36
- };
37
- const transformToRsbuildServerOptions = (dev, devServer, server) => {
38
- const { host, https, startUrl, beforeStartUrl, server: devServerConfig, ...devConfig } = dev;
39
- var _server_port;
40
- const port = process.env.PORT ? Number(process.env.PORT) : (_server_port = server === null || server === void 0 ? void 0 : server.port) !== null && _server_port !== void 0 ? _server_port : 8080;
41
- const rsbuildDev = (0, import_ts_deepmerge.merge)(defaultDevConfig, devConfig);
42
- delete rsbuildDev.setupMiddlewares;
43
- const legacyServerConfig = (0, import_utils.applyOptionsChain)({}, devServer, {}, import_ts_deepmerge.merge);
44
- var _devServerConfig_compress, _devServerConfig_headers, _devServerConfig_historyApiFallback, _devServerConfig_proxy;
45
- const serverCofig = {
46
- compress: (_devServerConfig_compress = devServerConfig === null || devServerConfig === void 0 ? void 0 : devServerConfig.compress) !== null && _devServerConfig_compress !== void 0 ? _devServerConfig_compress : legacyServerConfig.compress,
47
- headers: (_devServerConfig_headers = devServerConfig === null || devServerConfig === void 0 ? void 0 : devServerConfig.headers) !== null && _devServerConfig_headers !== void 0 ? _devServerConfig_headers : legacyServerConfig.headers,
48
- historyApiFallback: (_devServerConfig_historyApiFallback = devServerConfig === null || devServerConfig === void 0 ? void 0 : devServerConfig.historyApiFallback) !== null && _devServerConfig_historyApiFallback !== void 0 ? _devServerConfig_historyApiFallback : legacyServerConfig.historyApiFallback,
49
- proxy: (_devServerConfig_proxy = devServerConfig === null || devServerConfig === void 0 ? void 0 : devServerConfig.proxy) !== null && _devServerConfig_proxy !== void 0 ? _devServerConfig_proxy : legacyServerConfig.proxy
50
- };
51
- const rsbuildServer = (0, import_utils.isProd)() ? {
52
- publicDir: false,
53
- htmlFallback: false,
54
- printUrls: false
55
- } : {
56
- publicDir: false,
57
- htmlFallback: false,
58
- printUrls: false,
59
- compress: serverCofig.compress,
60
- headers: serverCofig.headers,
61
- historyApiFallback: serverCofig.historyApiFallback,
62
- proxy: serverCofig.proxy,
63
- host,
64
- port,
65
- https: https ? https : void 0,
66
- middlewareMode: true,
67
- cors: server === null || server === void 0 ? void 0 : server.cors
68
- };
69
- if (!(0, import_utils.isProd)() && startUrl) {
70
- rsbuildServer.open = beforeStartUrl ? {
71
- target: startUrl === true ? "//localhost:<port>" : startUrl,
72
- before: beforeStartUrl
73
- } : startUrl;
74
- }
75
- return {
76
- rsbuildDev,
77
- rsbuildServer
78
- };
79
- };
80
- // Annotate the CommonJS export names for ESM import in node:
81
- 0 && (module.exports = {
82
- transformToRsbuildServerOptions
83
- });
@@ -1,113 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var getCssSupport_exports = {};
30
- __export(getCssSupport_exports, {
31
- getCssSupport: () => getCssSupport
32
- });
33
- module.exports = __toCommonJS(getCssSupport_exports);
34
- var import_browserslist = __toESM(require("browserslist"));
35
- const CSS_FEATURES_BROWSER = {
36
- customProperties: {
37
- and_chr: "49",
38
- and_ff: "31",
39
- android: "50",
40
- chrome: "49",
41
- edge: "15",
42
- firefox: "31",
43
- ios_saf: "9.3",
44
- op_mob: "36",
45
- opera: "36",
46
- safari: "9.1",
47
- samsung: "5.0"
48
- },
49
- initial: {
50
- and_chr: "37",
51
- and_ff: "27",
52
- android: "37",
53
- chrome: "37",
54
- edge: "79",
55
- firefox: "27",
56
- ios_saf: "9.3",
57
- op_mob: "24",
58
- opera: "24",
59
- safari: "9.1",
60
- samsung: "3.0"
61
- },
62
- pageBreak: {
63
- and_chr: "51",
64
- and_ff: "92",
65
- android: "51",
66
- chrome: "51",
67
- edge: "12",
68
- firefox: "92",
69
- ios_saf: "10",
70
- op_mob: "37",
71
- opera: "11.1",
72
- safari: "10",
73
- samsung: "5.0"
74
- },
75
- fontVariant: {
76
- and_chr: "18",
77
- and_ff: "34",
78
- android: "4.4",
79
- chrome: "1",
80
- edge: "12",
81
- firefox: "34",
82
- ios_saf: "9.3",
83
- op_mob: "12",
84
- opera: "10",
85
- safari: "9.1",
86
- samsung: "1.0"
87
- },
88
- mediaMinmax: {
89
- and_chr: "104",
90
- and_ff: "109",
91
- android: "104",
92
- chrome: "104",
93
- edge: "104",
94
- firefox: "63",
95
- opera: "91"
96
- }
97
- };
98
- const getCssFeatureBrowsers = (feature) => {
99
- const featureBrowsers = CSS_FEATURES_BROWSER[feature];
100
- return (0, import_browserslist.default)(Object.entries(featureBrowsers).map(([key, value]) => `${key} >= ${value}`));
101
- };
102
- const isFeatureSupported = (projectBrowsers, featureBrowsers) => projectBrowsers.every((item) => featureBrowsers.includes(item));
103
- function getCssSupport(projectBrowserslist) {
104
- const projectBrowsers = (0, import_browserslist.default)(projectBrowserslist);
105
- return Object.keys(CSS_FEATURES_BROWSER).reduce((acc, key) => {
106
- acc[key] = isFeatureSupported(projectBrowsers, getCssFeatureBrowsers(key));
107
- return acc;
108
- }, {});
109
- }
110
- // Annotate the CommonJS export names for ESM import in node:
111
- 0 && (module.exports = {
112
- getCssSupport
113
- });
@@ -1,38 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var manifest_exports = {};
20
- __export(manifest_exports, {
21
- generateManifest: () => generateManifest
22
- });
23
- module.exports = __toCommonJS(manifest_exports);
24
- const generateManifest = (seed, files, entries) => {
25
- const manifestFiles = files.reduce((manifest, file) => {
26
- manifest[file.name] = file.path;
27
- return manifest;
28
- }, seed);
29
- const entrypointFiles = Object.keys(entries).reduce((previous, name) => previous.concat(entries[name].filter((fileName) => !fileName.endsWith(".map"))), []);
30
- return {
31
- files: manifestFiles,
32
- entrypoints: entrypointFiles
33
- };
34
- };
35
- // Annotate the CommonJS export names for ESM import in node:
36
- 0 && (module.exports = {
37
- generateManifest
38
- });
@@ -1,232 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var parseCommonConfig_exports = {};
30
- __export(parseCommonConfig_exports, {
31
- isLooseCssModules: () => isLooseCssModules,
32
- parseCommonConfig: () => parseCommonConfig
33
- });
34
- module.exports = __toCommonJS(parseCommonConfig_exports);
35
- var import_core = require("@rsbuild/core");
36
- var import_plugin_css_minimizer = require("@rsbuild/plugin-css-minimizer");
37
- var import_plugin_less = require("@rsbuild/plugin-less");
38
- var import_plugin_react = require("@rsbuild/plugin-react");
39
- var import_plugin_sass = require("@rsbuild/plugin-sass");
40
- var import_devtools = require("../plugins/devtools");
41
- var import_emitRouteFile = require("../plugins/emitRouteFile");
42
- var import_environmentDefaults = require("../plugins/environmentDefaults");
43
- var import_globalVars = require("../plugins/globalVars");
44
- var import_htmlMinify = require("../plugins/htmlMinify");
45
- var import_runtimeChunk = require("../plugins/runtimeChunk");
46
- var import_devServer = require("./devServer");
47
- var import_utils = require("./utils");
48
- const CSS_MODULES_REGEX = /\.modules?\.\w+$/i;
49
- const GLOBAL_CSS_REGEX = /\.global\.\w+$/;
50
- const isLooseCssModules = (path) => {
51
- if (import_utils.NODE_MODULES_REGEX.test(path)) {
52
- return CSS_MODULES_REGEX.test(path);
53
- }
54
- return !GLOBAL_CSS_REGEX.test(path);
55
- };
56
- function removeUndefinedKey(obj) {
57
- Object.keys(obj).forEach((key) => {
58
- if (obj[key] === void 0) {
59
- delete obj[key];
60
- }
61
- });
62
- return obj;
63
- }
64
- async function parseCommonConfig(builderConfig, options) {
65
- var _builderConfig_output;
66
- var _rsbuildConfig_tools, _output, _output_distPath, _output1, _extraConfig, _html, _extraConfig1;
67
- const frameworkConfigPath = options === null || options === void 0 ? void 0 : options.frameworkConfigPath;
68
- const { plugins: [...plugins] = [], performance: { ...performanceConfig } = {}, output: { enableCssModuleTSDeclaration, disableCssModuleExtension, disableTsChecker, disableSvgr, svgDefaultExport, assetsRetry, enableAssetManifest, sourceMap, convertToRem, polyfill, dataUriLimit = 1e4, distPath = {}, ...outputConfig } = {}, html: { outputStructure, appIcon, ...htmlConfig } = {}, source: { alias, globalVars, transformImport, ...sourceConfig } = {}, dev = {}, server = {}, security: { checkSyntax, sri, ...securityConfig } = {}, tools: { devServer, tsChecker, minifyCss, less, sass, htmlPlugin, autoprefixer, ...toolsConfig } = {}, environments = {}, resolve = {} } = builderConfig;
69
- const rsbuildConfig = {
70
- plugins,
71
- output: {
72
- polyfill: polyfill === "ua" ? "off" : polyfill,
73
- dataUriLimit,
74
- sourceMap,
75
- ...outputConfig
76
- },
77
- resolve,
78
- source: {
79
- alias,
80
- ...sourceConfig
81
- },
82
- performance: performanceConfig,
83
- html: htmlConfig,
84
- tools: toolsConfig,
85
- security: securityConfig,
86
- environments
87
- };
88
- if (typeof alias === "object" && Object.keys(alias).length === 0) {
89
- var _rsbuildConfig_source;
90
- (_rsbuildConfig_source = rsbuildConfig.source) === null || _rsbuildConfig_source === void 0 ? true : delete _rsbuildConfig_source.alias;
91
- }
92
- rsbuildConfig.tools.htmlPlugin = htmlPlugin;
93
- var _lightningcssLoader;
94
- (_lightningcssLoader = (_rsbuildConfig_tools = rsbuildConfig.tools).lightningcssLoader) !== null && _lightningcssLoader !== void 0 ? _lightningcssLoader : _rsbuildConfig_tools.lightningcssLoader = false;
95
- const { html = {}, output = {}, source = {} } = rsbuildConfig;
96
- source.transformImport = transformImport === false ? () => [] : transformImport;
97
- if (!source.decorators) {
98
- source.decorators = {
99
- version: "legacy"
100
- };
101
- }
102
- var _charset;
103
- (_charset = (_output = output).charset) !== null && _charset !== void 0 ? _charset : _output.charset = "ascii";
104
- if (typeof output.sourceMap !== "boolean") {
105
- var _output2, _output_sourceMap;
106
- (_output2 = output).sourceMap || (_output2.sourceMap = {});
107
- var _css;
108
- (_css = (_output_sourceMap = output.sourceMap).css) !== null && _css !== void 0 ? _css : _output_sourceMap.css = process.env.NODE_ENV !== "production";
109
- }
110
- const { server: _server, worker, ...rsbuildDistPath } = distPath;
111
- output.distPath = rsbuildDistPath;
112
- var _html1;
113
- (_html1 = (_output_distPath = output.distPath).html) !== null && _html1 !== void 0 ? _html1 : _output_distPath.html = "html";
114
- var _polyfill;
115
- (_polyfill = (_output1 = output).polyfill) !== null && _polyfill !== void 0 ? _polyfill : _output1.polyfill = "entry";
116
- if (disableCssModuleExtension) {
117
- var _output3, _output_cssModules;
118
- (_output3 = output).cssModules || (_output3.cssModules = {});
119
- var _auto;
120
- (_auto = (_output_cssModules = output.cssModules).auto) !== null && _auto !== void 0 ? _auto : _output_cssModules.auto = isLooseCssModules;
121
- }
122
- const extraConfig = {};
123
- (_extraConfig = extraConfig).html || (_extraConfig.html = {});
124
- extraConfig.html.outputStructure = outputStructure !== null && outputStructure !== void 0 ? outputStructure : "nested";
125
- var _title;
126
- (_title = (_html = html).title) !== null && _title !== void 0 ? _title : _html.title = "";
127
- html.appIcon = appIcon;
128
- var _tools;
129
- (_tools = (_extraConfig1 = extraConfig).tools) !== null && _tools !== void 0 ? _tools : _extraConfig1.tools = {};
130
- if (htmlPlugin !== false) {
131
- extraConfig.tools.htmlPlugin = (config) => {
132
- if (typeof config.templateParameters === "function") {
133
- const originFn = config.templateParameters;
134
- config.templateParameters = (...args) => {
135
- const res = originFn(...args);
136
- return {
137
- title: config.title,
138
- meta: void 0,
139
- ...res
140
- };
141
- };
142
- }
143
- };
144
- }
145
- if (!dev.lazyCompilation) {
146
- dev.lazyCompilation = false;
147
- }
148
- const { rsbuildDev, rsbuildServer } = (0, import_devServer.transformToRsbuildServerOptions)(dev || {}, devServer || {}, server || {});
149
- rsbuildConfig.server = removeUndefinedKey(rsbuildServer);
150
- rsbuildConfig.dev = removeUndefinedKey(rsbuildDev);
151
- rsbuildConfig.html = html;
152
- rsbuildConfig.output = output;
153
- const rsbuildPlugins = [
154
- (0, import_globalVars.pluginGlobalVars)(globalVars),
155
- (0, import_devtools.pluginDevtool)({
156
- sourceMap
157
- }),
158
- (0, import_emitRouteFile.pluginEmitRouteFile)(),
159
- (0, import_plugin_sass.pluginSass)({
160
- sassLoaderOptions: sass
161
- }),
162
- (0, import_plugin_less.pluginLess)({
163
- lessLoaderOptions: less
164
- }),
165
- (0, import_environmentDefaults.pluginEnvironmentDefaults)(distPath),
166
- (0, import_htmlMinify.pluginHtmlMinifierTerser)()
167
- ];
168
- if (checkSyntax) {
169
- const { pluginCheckSyntax } = await Promise.resolve().then(() => __toESM(require("@rsbuild/plugin-check-syntax")));
170
- rsbuildPlugins.push(pluginCheckSyntax(typeof checkSyntax === "boolean" ? {} : checkSyntax));
171
- }
172
- if (!disableTsChecker) {
173
- const { pluginTypeCheck } = await Promise.resolve().then(() => __toESM(require("@rsbuild/plugin-type-check")));
174
- rsbuildPlugins.push(pluginTypeCheck({
175
- tsCheckerOptions: tsChecker
176
- }));
177
- }
178
- if (convertToRem) {
179
- const { pluginRem } = await Promise.resolve().then(() => __toESM(require("@rsbuild/plugin-rem")));
180
- rsbuildPlugins.push(pluginRem(typeof convertToRem === "boolean" ? {} : convertToRem));
181
- }
182
- if (enableCssModuleTSDeclaration) {
183
- const { pluginTypedCSSModules } = await Promise.resolve().then(() => __toESM(require("@rsbuild/plugin-typed-css-modules")));
184
- rsbuildPlugins.push(pluginTypedCSSModules());
185
- }
186
- rsbuildPlugins.push((0, import_runtimeChunk.pluginRuntimeChunk)((_builderConfig_output = builderConfig.output) === null || _builderConfig_output === void 0 ? void 0 : _builderConfig_output.disableInlineRuntimeChunk));
187
- const { sourceBuild } = builderConfig.experiments || {};
188
- if (sourceBuild) {
189
- const { pluginSourceBuild } = await Promise.resolve().then(() => __toESM(require("@rsbuild/plugin-source-build")));
190
- rsbuildPlugins.push(pluginSourceBuild(sourceBuild === true ? {} : sourceBuild));
191
- }
192
- rsbuildPlugins.push((0, import_plugin_react.pluginReact)());
193
- if (!disableSvgr) {
194
- const { pluginSvgr } = await Promise.resolve().then(() => __toESM(require("@rsbuild/plugin-svgr")));
195
- rsbuildPlugins.push(pluginSvgr({
196
- mixedImport: true,
197
- svgrOptions: {
198
- exportType: svgDefaultExport === "component" ? "default" : "named"
199
- }
200
- }));
201
- }
202
- if (assetsRetry) {
203
- const { pluginAssetsRetry } = await Promise.resolve().then(() => __toESM(require("@rsbuild/plugin-assets-retry")));
204
- rsbuildPlugins.push(pluginAssetsRetry(assetsRetry));
205
- }
206
- if (frameworkConfigPath && performanceConfig.buildCache !== false) {
207
- const buildCache = typeof performanceConfig.buildCache === "object" ? performanceConfig.buildCache : {};
208
- rsbuildConfig.performance.buildCache = {
209
- ...buildCache,
210
- buildDependencies: [
211
- frameworkConfigPath,
212
- ...buildCache.buildDependencies || []
213
- ]
214
- };
215
- }
216
- rsbuildPlugins.push((0, import_plugin_css_minimizer.pluginCssMinimizer)({
217
- pluginOptions: minifyCss
218
- }));
219
- if (enableAssetManifest) {
220
- const { pluginManifest } = await Promise.resolve().then(() => __toESM(require("../plugins/manifest")));
221
- rsbuildPlugins.push(pluginManifest());
222
- }
223
- return {
224
- rsbuildConfig: (0, import_core.mergeRsbuildConfig)(rsbuildConfig, extraConfig),
225
- rsbuildPlugins
226
- };
227
- }
228
- // Annotate the CommonJS export names for ESM import in node:
229
- 0 && (module.exports = {
230
- isLooseCssModules,
231
- parseCommonConfig
232
- });