@modern-js/builder 3.0.0-alpha.0 → 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 +36 -31
  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 -166
  102. package/dist/rsc/plugins/rspack-rsc-client-plugin.js +0 -233
  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
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ default: ()=>rscSsrLoader
28
+ });
29
+ const external_common_js_namespaceObject = require("./common.js");
30
+ async function rscSsrLoader(source, sourceMap) {
31
+ this.cacheable(true);
32
+ const callback = this.async();
33
+ const ast = await (0, external_common_js_namespaceObject.parseSource)(source);
34
+ const hasDeclareServerDirective = await (0, external_common_js_namespaceObject.isServerModule)(ast);
35
+ const resourcePath = this.resourcePath;
36
+ if (!hasDeclareServerDirective) return void callback(null, source, sourceMap);
37
+ const exportedNames = await (0, external_common_js_namespaceObject.getExportNames)(ast, true);
38
+ const importsCode = `
39
+ 'use server';
40
+ `;
41
+ const exportsCode = exportedNames.map((name)=>{
42
+ if ('default' === name) return 'export default () => {throw new Error("Server actions must not be called during server-side rendering.")}';
43
+ return `export const ${name} = () => {
44
+ throw new Error("Server actions must not be called during server-side rendering.")
45
+ }`;
46
+ }).join('\n');
47
+ if (exportedNames.length > 0) (0, external_common_js_namespaceObject.setRscBuildInfo)(this._module, {
48
+ type: 'server',
49
+ resourcePath,
50
+ exportNames: exportedNames
51
+ });
52
+ callback(null, `${importsCode}\n${exportsCode}`, sourceMap);
53
+ }
54
+ exports["default"] = __webpack_exports__["default"];
55
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
56
+ "default"
57
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
58
+ Object.defineProperty(exports, '__esModule', {
59
+ value: true
60
+ });
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ transformToRsbuildServerOptions: ()=>transformToRsbuildServerOptions
28
+ });
29
+ const utils_namespaceObject = require("@modern-js/utils");
30
+ const external_ts_deepmerge_namespaceObject = require("ts-deepmerge");
31
+ const defaultDevConfig = {
32
+ writeToDisk: (file)=>!file.includes('.hot-update.'),
33
+ hmr: true,
34
+ liveReload: true,
35
+ progressBar: true,
36
+ client: {
37
+ path: '/webpack-hmr',
38
+ overlay: false,
39
+ port: '<port>'
40
+ }
41
+ };
42
+ const transformToRsbuildServerOptions = (dev, devServer, server)=>{
43
+ const { host = '0.0.0.0', https, startUrl, beforeStartUrl, server: devServerConfig, ...devConfig } = dev;
44
+ const port = process.env.PORT ? Number(process.env.PORT) : server?.port ?? 8080;
45
+ const rsbuildDev = (0, external_ts_deepmerge_namespaceObject.merge)(defaultDevConfig, devConfig);
46
+ delete rsbuildDev.setupMiddlewares;
47
+ const legacyServerConfig = (0, utils_namespaceObject.applyOptionsChain)({}, devServer, {}, external_ts_deepmerge_namespaceObject.merge);
48
+ const serverCofig = {
49
+ compress: devServerConfig?.compress ?? legacyServerConfig.compress,
50
+ headers: devServerConfig?.headers ?? legacyServerConfig.headers,
51
+ historyApiFallback: devServerConfig?.historyApiFallback ?? legacyServerConfig.historyApiFallback,
52
+ proxy: devServerConfig?.proxy ?? legacyServerConfig.proxy
53
+ };
54
+ const rsbuildServer = (0, utils_namespaceObject.isProd)() ? {
55
+ publicDir: false,
56
+ htmlFallback: false,
57
+ printUrls: false
58
+ } : {
59
+ publicDir: false,
60
+ htmlFallback: false,
61
+ printUrls: false,
62
+ compress: serverCofig.compress,
63
+ headers: serverCofig.headers,
64
+ historyApiFallback: serverCofig.historyApiFallback,
65
+ proxy: serverCofig.proxy,
66
+ host,
67
+ port,
68
+ https: https ? https : void 0,
69
+ middlewareMode: true,
70
+ cors: server?.cors
71
+ };
72
+ if (!(0, utils_namespaceObject.isProd)() && startUrl) rsbuildServer.open = beforeStartUrl ? {
73
+ target: true === startUrl ? '//localhost:<port>' : startUrl,
74
+ before: beforeStartUrl
75
+ } : startUrl;
76
+ return {
77
+ rsbuildDev,
78
+ rsbuildServer
79
+ };
80
+ };
81
+ exports.transformToRsbuildServerOptions = __webpack_exports__.transformToRsbuildServerOptions;
82
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
83
+ "transformToRsbuildServerOptions"
84
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
85
+ Object.defineProperty(exports, '__esModule', {
86
+ value: true
87
+ });
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = (module)=>{
5
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
+ __webpack_require__.d(getter, {
7
+ a: getter
8
+ });
9
+ return getter;
10
+ };
11
+ })();
12
+ (()=>{
13
+ __webpack_require__.d = (exports1, definition)=>{
14
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
+ enumerable: true,
16
+ get: definition[key]
17
+ });
18
+ };
19
+ })();
20
+ (()=>{
21
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
+ })();
23
+ (()=>{
24
+ __webpack_require__.r = (exports1)=>{
25
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
26
+ value: 'Module'
27
+ });
28
+ Object.defineProperty(exports1, '__esModule', {
29
+ value: true
30
+ });
31
+ };
32
+ })();
33
+ var __webpack_exports__ = {};
34
+ __webpack_require__.r(__webpack_exports__);
35
+ __webpack_require__.d(__webpack_exports__, {
36
+ getCssSupport: ()=>getCssSupport
37
+ });
38
+ const external_browserslist_namespaceObject = require("browserslist");
39
+ var external_browserslist_default = /*#__PURE__*/ __webpack_require__.n(external_browserslist_namespaceObject);
40
+ const CSS_FEATURES_BROWSER = {
41
+ customProperties: {
42
+ and_chr: '49',
43
+ and_ff: '31',
44
+ android: '50',
45
+ chrome: '49',
46
+ edge: '15',
47
+ firefox: '31',
48
+ ios_saf: '9.3',
49
+ op_mob: '36',
50
+ opera: '36',
51
+ safari: '9.1',
52
+ samsung: '5.0'
53
+ },
54
+ initial: {
55
+ and_chr: '37',
56
+ and_ff: '27',
57
+ android: '37',
58
+ chrome: '37',
59
+ edge: '79',
60
+ firefox: '27',
61
+ ios_saf: '9.3',
62
+ op_mob: '24',
63
+ opera: '24',
64
+ safari: '9.1',
65
+ samsung: '3.0'
66
+ },
67
+ pageBreak: {
68
+ and_chr: '51',
69
+ and_ff: '92',
70
+ android: '51',
71
+ chrome: '51',
72
+ edge: '12',
73
+ firefox: '92',
74
+ ios_saf: '10',
75
+ op_mob: '37',
76
+ opera: '11.1',
77
+ safari: '10',
78
+ samsung: '5.0'
79
+ },
80
+ fontVariant: {
81
+ and_chr: '18',
82
+ and_ff: '34',
83
+ android: '4.4',
84
+ chrome: '1',
85
+ edge: '12',
86
+ firefox: '34',
87
+ ios_saf: '9.3',
88
+ op_mob: '12',
89
+ opera: '10',
90
+ safari: '9.1',
91
+ samsung: '1.0'
92
+ },
93
+ mediaMinmax: {
94
+ and_chr: '104',
95
+ and_ff: '109',
96
+ android: '104',
97
+ chrome: '104',
98
+ edge: '104',
99
+ firefox: '63',
100
+ opera: '91'
101
+ }
102
+ };
103
+ const getCssFeatureBrowsers = (feature)=>{
104
+ const featureBrowsers = CSS_FEATURES_BROWSER[feature];
105
+ return external_browserslist_default()(Object.entries(featureBrowsers).map(([key, value])=>`${key} >= ${value}`));
106
+ };
107
+ const isFeatureSupported = (projectBrowsers, featureBrowsers)=>projectBrowsers.every((item)=>featureBrowsers.includes(item));
108
+ function getCssSupport(projectBrowserslist) {
109
+ const projectBrowsers = external_browserslist_default()(projectBrowserslist);
110
+ return Object.keys(CSS_FEATURES_BROWSER).reduce((acc, key)=>{
111
+ acc[key] = isFeatureSupported(projectBrowsers, getCssFeatureBrowsers(key));
112
+ return acc;
113
+ }, {});
114
+ }
115
+ exports.getCssSupport = __webpack_exports__.getCssSupport;
116
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
117
+ "getCssSupport"
118
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
119
+ Object.defineProperty(exports, '__esModule', {
120
+ value: true
121
+ });
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ generateManifest: ()=>generateManifest
28
+ });
29
+ const generateManifest = (seed, files, entries)=>{
30
+ const manifestFiles = files.reduce((manifest, file)=>{
31
+ manifest[file.name] = file.path;
32
+ return manifest;
33
+ }, seed);
34
+ const entrypointFiles = Object.keys(entries).reduce((previous, name)=>previous.concat(entries[name].filter((fileName)=>!fileName.endsWith('.map'))), []);
35
+ return {
36
+ files: manifestFiles,
37
+ entrypoints: entrypointFiles
38
+ };
39
+ };
40
+ exports.generateManifest = __webpack_exports__.generateManifest;
41
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
42
+ "generateManifest"
43
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
44
+ Object.defineProperty(exports, '__esModule', {
45
+ value: true
46
+ });
@@ -0,0 +1,209 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ isLooseCssModules: ()=>isLooseCssModules,
28
+ parseCommonConfig: ()=>parseCommonConfig
29
+ });
30
+ const core_namespaceObject = require("@rsbuild/core");
31
+ const plugin_css_minimizer_namespaceObject = require("@rsbuild/plugin-css-minimizer");
32
+ const plugin_less_namespaceObject = require("@rsbuild/plugin-less");
33
+ const plugin_react_namespaceObject = require("@rsbuild/plugin-react");
34
+ const plugin_sass_namespaceObject = require("@rsbuild/plugin-sass");
35
+ const devtools_js_namespaceObject = require("../plugins/devtools.js");
36
+ const emitRouteFile_js_namespaceObject = require("../plugins/emitRouteFile.js");
37
+ const environmentDefaults_js_namespaceObject = require("../plugins/environmentDefaults.js");
38
+ const globalVars_js_namespaceObject = require("../plugins/globalVars.js");
39
+ const htmlMinify_js_namespaceObject = require("../plugins/htmlMinify.js");
40
+ const runtimeChunk_js_namespaceObject = require("../plugins/runtimeChunk.js");
41
+ const external_devServer_js_namespaceObject = require("./devServer.js");
42
+ const external_utils_js_namespaceObject = require("./utils.js");
43
+ const CSS_MODULES_REGEX = /\.modules?\.\w+$/i;
44
+ const GLOBAL_CSS_REGEX = /\.global\.\w+$/;
45
+ const isLooseCssModules = (path)=>{
46
+ if (external_utils_js_namespaceObject.NODE_MODULES_REGEX.test(path)) return CSS_MODULES_REGEX.test(path);
47
+ return !GLOBAL_CSS_REGEX.test(path);
48
+ };
49
+ function removeUndefinedKey(obj) {
50
+ Object.keys(obj).forEach((key)=>{
51
+ if (void 0 === obj[key]) delete obj[key];
52
+ });
53
+ return obj;
54
+ }
55
+ async function parseCommonConfig(builderConfig, options) {
56
+ const frameworkConfigPath = options?.frameworkConfigPath;
57
+ const { plugins: [...plugins] = [], splitChunks, performance: { ...performanceConfig } = {}, output: { module = false, enableCssModuleTSDeclaration, disableCssModuleExtension, disableTsChecker, disableSvgr, svgDefaultExport, assetsRetry, enableAssetManifest, sourceMap, convertToRem, polyfill, dataUriLimit = 10000, 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;
58
+ let combinedAlias;
59
+ if (alias || resolve.alias) combinedAlias = [].concat(alias ?? []).concat(resolve.alias ?? []);
60
+ const rsbuildConfig = {
61
+ plugins,
62
+ splitChunks,
63
+ output: {
64
+ polyfill: 'ua' === polyfill ? 'off' : polyfill,
65
+ dataUriLimit,
66
+ sourceMap,
67
+ module,
68
+ ...outputConfig
69
+ },
70
+ resolve: {
71
+ ...resolve,
72
+ alias: combinedAlias
73
+ },
74
+ source: sourceConfig,
75
+ performance: performanceConfig,
76
+ html: htmlConfig,
77
+ tools: toolsConfig,
78
+ security: securityConfig,
79
+ environments
80
+ };
81
+ rsbuildConfig.tools.htmlPlugin = htmlPlugin;
82
+ rsbuildConfig.tools.lightningcssLoader ??= false;
83
+ const { html = {}, output = {}, source = {} } = rsbuildConfig;
84
+ source.transformImport = false === transformImport ? ()=>[] : transformImport;
85
+ if (!source.decorators) source.decorators = {
86
+ version: 'legacy'
87
+ };
88
+ output.charset ??= 'ascii';
89
+ if ('boolean' != typeof output.sourceMap) {
90
+ output.sourceMap ||= {};
91
+ output.sourceMap.css ??= 'production' !== process.env.NODE_ENV;
92
+ }
93
+ const { server: _server, worker, ...rsbuildDistPath } = distPath;
94
+ output.distPath = rsbuildDistPath;
95
+ output.distPath.html ??= 'html';
96
+ output.polyfill ??= 'entry';
97
+ if (disableCssModuleExtension) {
98
+ output.cssModules ||= {};
99
+ output.cssModules.auto ??= isLooseCssModules;
100
+ }
101
+ const extraConfig = {};
102
+ extraConfig.html ||= {};
103
+ extraConfig.html.outputStructure = outputStructure ?? 'nested';
104
+ html.title ??= '';
105
+ html.appIcon = appIcon;
106
+ extraConfig.tools ??= {};
107
+ if (false !== htmlPlugin) extraConfig.tools.htmlPlugin = (config)=>{
108
+ if ('function' == typeof config.templateParameters) {
109
+ const originFn = config.templateParameters;
110
+ config.templateParameters = (...args)=>{
111
+ const res = originFn(...args);
112
+ return {
113
+ title: config.title,
114
+ meta: void 0,
115
+ ...res
116
+ };
117
+ };
118
+ }
119
+ };
120
+ if (!dev.lazyCompilation) dev.lazyCompilation = false;
121
+ const { rsbuildDev, rsbuildServer } = (0, external_devServer_js_namespaceObject.transformToRsbuildServerOptions)(dev || {}, devServer || {}, server || {});
122
+ rsbuildConfig.server = removeUndefinedKey(rsbuildServer);
123
+ rsbuildConfig.dev = removeUndefinedKey(rsbuildDev);
124
+ rsbuildConfig.html = html;
125
+ rsbuildConfig.output = output;
126
+ const rsbuildPlugins = [
127
+ (0, globalVars_js_namespaceObject.pluginGlobalVars)(globalVars),
128
+ (0, devtools_js_namespaceObject.pluginDevtool)({
129
+ sourceMap
130
+ }),
131
+ (0, emitRouteFile_js_namespaceObject.pluginEmitRouteFile)(),
132
+ (0, plugin_sass_namespaceObject.pluginSass)({
133
+ sassLoaderOptions: sass
134
+ }),
135
+ (0, plugin_less_namespaceObject.pluginLess)({
136
+ lessLoaderOptions: less
137
+ }),
138
+ (0, environmentDefaults_js_namespaceObject.pluginEnvironmentDefaults)(distPath),
139
+ (0, htmlMinify_js_namespaceObject.pluginHtmlMinifierTerser)()
140
+ ];
141
+ if (checkSyntax) {
142
+ const { pluginCheckSyntax } = await import("@rsbuild/plugin-check-syntax");
143
+ rsbuildPlugins.push(pluginCheckSyntax('boolean' == typeof checkSyntax ? {} : checkSyntax));
144
+ }
145
+ if (!disableTsChecker) {
146
+ const { pluginTypeCheck } = await import("@rsbuild/plugin-type-check");
147
+ rsbuildPlugins.push(pluginTypeCheck({
148
+ tsCheckerOptions: tsChecker
149
+ }));
150
+ }
151
+ if (convertToRem) {
152
+ const { pluginRem } = await import("@rsbuild/plugin-rem");
153
+ rsbuildPlugins.push(pluginRem('boolean' == typeof convertToRem ? {} : convertToRem));
154
+ }
155
+ if (enableCssModuleTSDeclaration) {
156
+ const { pluginTypedCSSModules } = await import("@rsbuild/plugin-typed-css-modules");
157
+ rsbuildPlugins.push(pluginTypedCSSModules());
158
+ }
159
+ rsbuildPlugins.push((0, runtimeChunk_js_namespaceObject.pluginRuntimeChunk)(builderConfig.output?.disableInlineRuntimeChunk));
160
+ const { sourceBuild } = builderConfig.experiments || {};
161
+ if (sourceBuild) {
162
+ const { pluginSourceBuild } = await import("@rsbuild/plugin-source-build");
163
+ rsbuildPlugins.push(pluginSourceBuild(true === sourceBuild ? {} : sourceBuild));
164
+ }
165
+ rsbuildPlugins.push((0, plugin_react_namespaceObject.pluginReact)());
166
+ if (!disableSvgr) {
167
+ const { pluginSvgr } = await import("@rsbuild/plugin-svgr");
168
+ rsbuildPlugins.push(pluginSvgr({
169
+ mixedImport: true,
170
+ svgrOptions: {
171
+ exportType: 'component' === svgDefaultExport ? 'default' : 'named'
172
+ }
173
+ }));
174
+ }
175
+ if (assetsRetry) {
176
+ const { pluginAssetsRetry } = await import("@rsbuild/plugin-assets-retry");
177
+ rsbuildPlugins.push(pluginAssetsRetry(assetsRetry));
178
+ }
179
+ if (frameworkConfigPath && false !== performanceConfig.buildCache) {
180
+ const buildCache = 'object' == typeof performanceConfig.buildCache ? performanceConfig.buildCache : {};
181
+ rsbuildConfig.performance.buildCache = {
182
+ ...buildCache,
183
+ buildDependencies: [
184
+ frameworkConfigPath,
185
+ ...buildCache.buildDependencies || []
186
+ ]
187
+ };
188
+ }
189
+ rsbuildPlugins.push((0, plugin_css_minimizer_namespaceObject.pluginCssMinimizer)({
190
+ pluginOptions: minifyCss
191
+ }));
192
+ if (enableAssetManifest) {
193
+ const { pluginManifest } = await import("../plugins/manifest.js");
194
+ rsbuildPlugins.push(pluginManifest());
195
+ }
196
+ return {
197
+ rsbuildConfig: (0, core_namespaceObject.mergeRsbuildConfig)(rsbuildConfig, extraConfig),
198
+ rsbuildPlugins
199
+ };
200
+ }
201
+ exports.isLooseCssModules = __webpack_exports__.isLooseCssModules;
202
+ exports.parseCommonConfig = __webpack_exports__.parseCommonConfig;
203
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
204
+ "isLooseCssModules",
205
+ "parseCommonConfig"
206
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
207
+ Object.defineProperty(exports, '__esModule', {
208
+ value: true
209
+ });
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = (module)=>{
5
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
+ __webpack_require__.d(getter, {
7
+ a: getter
8
+ });
9
+ return getter;
10
+ };
11
+ })();
12
+ (()=>{
13
+ __webpack_require__.d = (exports1, definition)=>{
14
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
+ enumerable: true,
16
+ get: definition[key]
17
+ });
18
+ };
19
+ })();
20
+ (()=>{
21
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
+ })();
23
+ (()=>{
24
+ __webpack_require__.r = (exports1)=>{
25
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
26
+ value: 'Module'
27
+ });
28
+ Object.defineProperty(exports1, '__esModule', {
29
+ value: true
30
+ });
31
+ };
32
+ })();
33
+ var __webpack_exports__ = {};
34
+ __webpack_require__.r(__webpack_exports__);
35
+ __webpack_require__.d(__webpack_exports__, {
36
+ rscClientBrowserFallbackPlugin: ()=>rscClientBrowserFallbackPlugin
37
+ });
38
+ const external_path_namespaceObject = require("path");
39
+ var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
40
+ function rscClientBrowserFallbackPlugin() {
41
+ return {
42
+ name: 'builder:rsc-client-browser-fallback',
43
+ setup (api) {
44
+ let emptyModulePath;
45
+ try {
46
+ emptyModulePath = require.resolve('./rscEmptyModule');
47
+ } catch {
48
+ emptyModulePath = external_path_default().resolve(__dirname, 'rscEmptyModule');
49
+ }
50
+ api.modifyRspackConfig((config)=>{
51
+ config.resolve ??= {};
52
+ config.resolve.fallback ??= {};
53
+ config.resolve.fallback['react-server-dom-webpack/client.browser'] = emptyModulePath;
54
+ });
55
+ }
56
+ };
57
+ }
58
+ exports.rscClientBrowserFallbackPlugin = __webpack_exports__.rscClientBrowserFallbackPlugin;
59
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
60
+ "rscClientBrowserFallbackPlugin"
61
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
62
+ Object.defineProperty(exports, '__esModule', {
63
+ value: true
64
+ });
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ default: ()=>__rspack_default_export
28
+ });
29
+ const __rspack_default_export = {};
30
+ exports["default"] = __webpack_exports__["default"];
31
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
32
+ "default"
33
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
34
+ Object.defineProperty(exports, '__esModule', {
35
+ value: true
36
+ });