@bleedingdev/modern-js-builder 3.2.0-ultramodern.0

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 (87) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +26 -0
  3. package/dist/cjs/createBuilder.js +94 -0
  4. package/dist/cjs/index.js +59 -0
  5. package/dist/cjs/plugins/devtools.js +47 -0
  6. package/dist/cjs/plugins/emitRouteFile.js +75 -0
  7. package/dist/cjs/plugins/environmentDefaults.js +100 -0
  8. package/dist/cjs/plugins/globalVars.js +55 -0
  9. package/dist/cjs/plugins/htmlMinify.js +115 -0
  10. package/dist/cjs/plugins/manifest.js +52 -0
  11. package/dist/cjs/plugins/postcss.js +162 -0
  12. package/dist/cjs/plugins/rscConfig.js +159 -0
  13. package/dist/cjs/plugins/rsdoctor.js +64 -0
  14. package/dist/cjs/plugins/runtimeChunk.js +55 -0
  15. package/dist/cjs/shared/devServer.js +87 -0
  16. package/dist/cjs/shared/getCssSupport.js +121 -0
  17. package/dist/cjs/shared/manifest.js +46 -0
  18. package/dist/cjs/shared/parseCommonConfig.js +210 -0
  19. package/dist/cjs/shared/rsc/rsc-server-entry-loader.js +41 -0
  20. package/dist/cjs/shared/rsc/rscClientBrowserFallback.js +64 -0
  21. package/dist/cjs/shared/rsc/rscEmptyModule.js +36 -0
  22. package/dist/cjs/shared/utils.js +115 -0
  23. package/dist/cjs/types.js +18 -0
  24. package/dist/esm/createBuilder.mjs +57 -0
  25. package/dist/esm/index.mjs +3 -0
  26. package/dist/esm/plugins/devtools.mjs +13 -0
  27. package/dist/esm/plugins/emitRouteFile.mjs +28 -0
  28. package/dist/esm/plugins/environmentDefaults.mjs +66 -0
  29. package/dist/esm/plugins/globalVars.mjs +21 -0
  30. package/dist/esm/plugins/htmlMinify.mjs +81 -0
  31. package/dist/esm/plugins/manifest.mjs +18 -0
  32. package/dist/esm/plugins/postcss.mjs +115 -0
  33. package/dist/esm/plugins/rscConfig.mjs +112 -0
  34. package/dist/esm/plugins/rsdoctor.mjs +30 -0
  35. package/dist/esm/plugins/runtimeChunk.mjs +21 -0
  36. package/dist/esm/shared/devServer.mjs +53 -0
  37. package/dist/esm/shared/getCssSupport.mjs +77 -0
  38. package/dist/esm/shared/manifest.mjs +12 -0
  39. package/dist/esm/shared/parseCommonConfig.mjs +173 -0
  40. package/dist/esm/shared/rsc/rsc-server-entry-loader.mjs +7 -0
  41. package/dist/esm/shared/rsc/rscClientBrowserFallback.mjs +20 -0
  42. package/dist/esm/shared/rsc/rscEmptyModule.mjs +2 -0
  43. package/dist/esm/shared/utils.mjs +53 -0
  44. package/dist/esm/types.mjs +0 -0
  45. package/dist/esm-node/createBuilder.mjs +58 -0
  46. package/dist/esm-node/index.mjs +4 -0
  47. package/dist/esm-node/plugins/devtools.mjs +14 -0
  48. package/dist/esm-node/plugins/emitRouteFile.mjs +29 -0
  49. package/dist/esm-node/plugins/environmentDefaults.mjs +67 -0
  50. package/dist/esm-node/plugins/globalVars.mjs +22 -0
  51. package/dist/esm-node/plugins/htmlMinify.mjs +82 -0
  52. package/dist/esm-node/plugins/manifest.mjs +19 -0
  53. package/dist/esm-node/plugins/postcss.mjs +116 -0
  54. package/dist/esm-node/plugins/rscConfig.mjs +117 -0
  55. package/dist/esm-node/plugins/rsdoctor.mjs +31 -0
  56. package/dist/esm-node/plugins/runtimeChunk.mjs +22 -0
  57. package/dist/esm-node/shared/devServer.mjs +54 -0
  58. package/dist/esm-node/shared/getCssSupport.mjs +78 -0
  59. package/dist/esm-node/shared/manifest.mjs +13 -0
  60. package/dist/esm-node/shared/parseCommonConfig.mjs +174 -0
  61. package/dist/esm-node/shared/rsc/rsc-server-entry-loader.mjs +8 -0
  62. package/dist/esm-node/shared/rsc/rscClientBrowserFallback.mjs +25 -0
  63. package/dist/esm-node/shared/rsc/rscEmptyModule.mjs +3 -0
  64. package/dist/esm-node/shared/utils.mjs +54 -0
  65. package/dist/esm-node/types.mjs +1 -0
  66. package/dist/types/createBuilder.d.ts +8 -0
  67. package/dist/types/index.d.ts +8 -0
  68. package/dist/types/plugins/devtools.d.ts +4 -0
  69. package/dist/types/plugins/emitRouteFile.d.ts +6 -0
  70. package/dist/types/plugins/environmentDefaults.d.ts +3 -0
  71. package/dist/types/plugins/globalVars.d.ts +3 -0
  72. package/dist/types/plugins/htmlMinify.d.ts +2 -0
  73. package/dist/types/plugins/manifest.d.ts +2 -0
  74. package/dist/types/plugins/postcss.d.ts +6 -0
  75. package/dist/types/plugins/rscConfig.d.ts +18 -0
  76. package/dist/types/plugins/rsdoctor.d.ts +3 -0
  77. package/dist/types/plugins/runtimeChunk.d.ts +2 -0
  78. package/dist/types/shared/devServer.d.ts +6 -0
  79. package/dist/types/shared/getCssSupport.d.ts +1 -0
  80. package/dist/types/shared/manifest.d.ts +2 -0
  81. package/dist/types/shared/parseCommonConfig.d.ts +9 -0
  82. package/dist/types/shared/rsc/rsc-server-entry-loader.d.ts +5 -0
  83. package/dist/types/shared/rsc/rscClientBrowserFallback.d.ts +2 -0
  84. package/dist/types/shared/rsc/rscEmptyModule.d.ts +2 -0
  85. package/dist/types/shared/utils.d.ts +12 -0
  86. package/dist/types/types.d.ts +287 -0
  87. package/package.json +88 -0
@@ -0,0 +1,162 @@
1
+ "use strict";
2
+ const __rslib_import_meta_url__ = /*#__PURE__*/ function() {
3
+ return "u" < typeof document ? new (require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
4
+ }();
5
+ var __webpack_require__ = {};
6
+ (()=>{
7
+ __webpack_require__.n = (module)=>{
8
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
9
+ __webpack_require__.d(getter, {
10
+ a: getter
11
+ });
12
+ return getter;
13
+ };
14
+ })();
15
+ (()=>{
16
+ __webpack_require__.d = (exports1, definition)=>{
17
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
18
+ enumerable: true,
19
+ get: definition[key]
20
+ });
21
+ };
22
+ })();
23
+ (()=>{
24
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
25
+ })();
26
+ (()=>{
27
+ __webpack_require__.r = (exports1)=>{
28
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
29
+ value: 'Module'
30
+ });
31
+ Object.defineProperty(exports1, '__esModule', {
32
+ value: true
33
+ });
34
+ };
35
+ })();
36
+ var __webpack_exports__ = {};
37
+ __webpack_require__.r(__webpack_exports__);
38
+ __webpack_require__.d(__webpack_exports__, {
39
+ pluginPostcss: ()=>pluginPostcss
40
+ });
41
+ const external_node_module_namespaceObject = require("node:module");
42
+ const external_node_path_namespaceObject = require("node:path");
43
+ var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
44
+ const external_node_url_namespaceObject = require("node:url");
45
+ const utils_namespaceObject = require("@modern-js/utils");
46
+ const core_namespaceObject = require("@rsbuild/core");
47
+ const getCssSupport_js_namespaceObject = require("../shared/getCssSupport.js");
48
+ const builderRequire = (0, external_node_module_namespaceObject.createRequire)(__rslib_import_meta_url__);
49
+ const createRootRequire = (rootPath)=>(0, external_node_module_namespaceObject.createRequire)((0, external_node_url_namespaceObject.pathToFileURL)(external_node_path_default().join(rootPath, 'package.json')).href);
50
+ const loadByResolver = (resolveWith, name)=>{
51
+ try {
52
+ return resolveWith(name);
53
+ } catch (error) {
54
+ const resolved = resolveWith.resolve(name);
55
+ return resolveWith(resolved);
56
+ }
57
+ };
58
+ const loadPostcssPlugin = (name, appRootPath)=>{
59
+ const resolvers = [
60
+ builderRequire,
61
+ createRootRequire(appRootPath),
62
+ createRootRequire(process.cwd())
63
+ ];
64
+ let firstError = null;
65
+ for (const resolveWith of resolvers)try {
66
+ return loadByResolver(resolveWith, name);
67
+ } catch (error) {
68
+ firstError ??= error;
69
+ }
70
+ throw firstError;
71
+ };
72
+ const importPostcssPlugin = (name, appRootPath)=>Promise.resolve(loadPostcssPlugin(name, appRootPath));
73
+ const clonePostCSSConfig = (config)=>({
74
+ ...config,
75
+ plugins: config.plugins ? [
76
+ ...config.plugins
77
+ ] : void 0
78
+ });
79
+ const postcssLoadConfig = builderRequire('postcss-load-config');
80
+ const userPostcssrcCache = new Map();
81
+ const loadUserPostcssrc = async (root)=>{
82
+ const cached = userPostcssrcCache.get(root);
83
+ if (cached) return clonePostCSSConfig(await cached);
84
+ const promise = postcssLoadConfig({}, root).catch((err)=>{
85
+ if (err?.message?.includes('No PostCSS Config found')) return {};
86
+ throw err;
87
+ });
88
+ userPostcssrcCache.set(root, promise);
89
+ return promise.then((config)=>{
90
+ userPostcssrcCache.set(root, config);
91
+ return clonePostCSSConfig(config);
92
+ });
93
+ };
94
+ const pluginPostcss = (options = {})=>({
95
+ name: 'builder:postcss-plugins',
96
+ pre: [
97
+ 'builder:environment-defaults-plugin'
98
+ ],
99
+ setup (api) {
100
+ const { autoprefixer } = options;
101
+ api.modifyEnvironmentConfig(async (config, { mergeEnvironmentConfig })=>{
102
+ if ('web' !== config.output.target) return config;
103
+ const cssSupport = (0, getCssSupport_js_namespaceObject.getCssSupport)(config.output.overrideBrowserslist);
104
+ const enableExtractCSS = !config.output?.injectStyles;
105
+ const enableCssMinify = !enableExtractCSS && (0, utils_namespaceObject.isProd)();
106
+ const cssnanoOptions = {
107
+ preset: [
108
+ 'default',
109
+ {
110
+ mergeLonghand: false,
111
+ normalizeUrl: false
112
+ }
113
+ ]
114
+ };
115
+ const plugins = await Promise.all([
116
+ importPostcssPlugin('postcss-flexbugs-fixes', api.context.rootPath),
117
+ !cssSupport.customProperties && importPostcssPlugin('postcss-custom-properties', api.context.rootPath),
118
+ !cssSupport.initial && importPostcssPlugin('postcss-initial', api.context.rootPath),
119
+ !cssSupport.pageBreak && importPostcssPlugin('postcss-page-break', api.context.rootPath),
120
+ !cssSupport.fontVariant && importPostcssPlugin('postcss-font-variant', api.context.rootPath),
121
+ !cssSupport.mediaMinmax && importPostcssPlugin('postcss-media-minmax', api.context.rootPath),
122
+ importPostcssPlugin('postcss-nesting', api.context.rootPath),
123
+ enableCssMinify && importPostcssPlugin('cssnano', api.context.rootPath).then((cssnano)=>cssnano(cssnanoOptions)),
124
+ importPostcssPlugin('autoprefixer', api.context.rootPath).then((autoprefixerPlugin)=>autoprefixerPlugin((0, utils_namespaceObject.applyOptionsChain)({
125
+ flexbox: 'no-2009',
126
+ overrideBrowserslist: config.output.overrideBrowserslist
127
+ }, autoprefixer)))
128
+ ]).then((results)=>results.filter(Boolean));
129
+ const userOptions = await loadUserPostcssrc(api.context.rootPath);
130
+ return mergeEnvironmentConfig({
131
+ tools: {
132
+ postcss: (opts)=>{
133
+ if ('function' == typeof opts.postcssOptions) {
134
+ core_namespaceObject.logger.warn('unexpected function type postcssOptions, the default postcss plugins will not be applied.');
135
+ return opts;
136
+ }
137
+ const existingOptions = opts.postcssOptions ?? {};
138
+ const mergedOptions = {
139
+ ...userOptions,
140
+ ...existingOptions
141
+ };
142
+ const userPlugins = userOptions.plugins ?? [];
143
+ const existingPlugins = existingOptions.plugins ?? [];
144
+ mergedOptions.plugins = [
145
+ ...userPlugins,
146
+ ...existingPlugins,
147
+ ...plugins
148
+ ];
149
+ opts.postcssOptions = mergedOptions;
150
+ }
151
+ }
152
+ }, config);
153
+ });
154
+ }
155
+ });
156
+ exports.pluginPostcss = __webpack_exports__.pluginPostcss;
157
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
158
+ "pluginPostcss"
159
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
160
+ Object.defineProperty(exports, '__esModule', {
161
+ value: true
162
+ });
@@ -0,0 +1,159 @@
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
+ getRscPlugins: ()=>getRscPlugins,
37
+ pluginRscConfig: ()=>pluginRscConfig
38
+ });
39
+ const external_path_namespaceObject = require("path");
40
+ var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
41
+ const ASYNC_STORAGE_PATTERN = /universal[/\\]async_storage/;
42
+ const RSC_COMMON_LAYER = 'rsc-common';
43
+ const ENTRY_NAME_VAR = '__MODERN_JS_ENTRY_NAME';
44
+ const createVirtualModule = (content)=>`data:text/javascript,${encodeURIComponent(content)}`;
45
+ const isAsyncStorageExclude = (exclude)=>{
46
+ if ('string' == typeof exclude) return ASYNC_STORAGE_PATTERN.test(exclude);
47
+ if (exclude instanceof RegExp) return exclude.test('universal/async_storage') || exclude.test('universal\\async_storage');
48
+ return false;
49
+ };
50
+ function pluginRscConfig() {
51
+ return {
52
+ name: 'builder:rsc-config',
53
+ setup (api) {
54
+ let layersCache = null;
55
+ const getLayers = async ()=>{
56
+ if (!layersCache) {
57
+ const { Layers } = await import("rsbuild-plugin-rsc");
58
+ layersCache = Layers;
59
+ }
60
+ return layersCache;
61
+ };
62
+ api.modifyBundlerChain({
63
+ handler: (chain, { isServer })=>{
64
+ if (isServer) {
65
+ const routeFilePattern = /[/\\]routes[/\\](?:.*[/\\])?(?:layout|page|\$)\.[tj]sx?$/;
66
+ const appFilePattern = /[/\\]App\.[tj]sx?$/;
67
+ const combinedPattern = new RegExp(`(${routeFilePattern.source}|${appFilePattern.source})`);
68
+ let loaderPath;
69
+ try {
70
+ loaderPath = require.resolve('../shared/rsc/rsc-server-entry-loader');
71
+ } catch {
72
+ loaderPath = external_path_default().resolve(__dirname, '../shared/rsc/rsc-server-entry-loader');
73
+ }
74
+ chain.module.rule('rsc-server-entry').test(/\.(tsx?|jsx?)$/).resource(combinedPattern).exclude.add(/node_modules/).end().use('rsc-server-entry-loader').loader(loaderPath).end();
75
+ }
76
+ },
77
+ order: 'pre'
78
+ });
79
+ api.modifyRspackConfig(async (config, utils)=>{
80
+ const isServer = 'node' === config.target || 'node' === utils.target || utils.environment?.name === 'server';
81
+ if (!isServer) return;
82
+ const Layers = await getLayers();
83
+ if (config.entry) {
84
+ const entries = config.entry;
85
+ const newEntries = {};
86
+ for (const [entryName, entryValue] of Object.entries(entries))if ('string' == typeof entryValue) newEntries[entryName] = {
87
+ import: entryValue,
88
+ layer: Layers.ssr
89
+ };
90
+ else if (Array.isArray(entryValue)) newEntries[entryName] = {
91
+ import: entryValue,
92
+ layer: Layers.ssr
93
+ };
94
+ else if ('object' == typeof entryValue && null !== entryValue) newEntries[entryName] = {
95
+ ...entryValue,
96
+ layer: Layers.ssr
97
+ };
98
+ else newEntries[entryName] = entryValue;
99
+ config.entry = newEntries;
100
+ }
101
+ if (config.module?.rules) {
102
+ const rules = config.module.rules;
103
+ for (const rule of rules)if (rule.layer === Layers.rsc) {
104
+ if (rule.exclude) {
105
+ if (!Array.isArray(rule.exclude)) rule.exclude = [
106
+ rule.exclude
107
+ ];
108
+ } else rule.exclude = [];
109
+ const hasExclude = rule.exclude.some(isAsyncStorageExclude);
110
+ if (!hasExclude) rule.exclude.push(ASYNC_STORAGE_PATTERN);
111
+ }
112
+ if (!Array.isArray(config.module.rules)) config.module.rules = [];
113
+ config.module.rules.push({
114
+ resource: ASYNC_STORAGE_PATTERN,
115
+ layer: RSC_COMMON_LAYER
116
+ });
117
+ }
118
+ });
119
+ api.modifyBundlerChain((chain, { isServer, isWebWorker })=>{
120
+ if (!isServer && !isWebWorker) {
121
+ const entries = chain.entryPoints.entries();
122
+ if (entries && 'object' == typeof entries) for (const entryName of Object.keys(entries)){
123
+ const entryPoint = chain.entry(entryName);
124
+ const code = `window.${ENTRY_NAME_VAR}="${entryName}";`;
125
+ entryPoint.add(createVirtualModule(code));
126
+ }
127
+ }
128
+ });
129
+ }
130
+ };
131
+ }
132
+ async function getRscPlugins(enableRsc, internalDirectory) {
133
+ if (enableRsc) {
134
+ const routesFileReg = new RegExp(`${internalDirectory.replace(/[/\\]/g, '[/\\\\]')}[/\\\\][^/\\\\]*[/\\\\]routes`);
135
+ const { pluginRSC } = await import("rsbuild-plugin-rsc");
136
+ return [
137
+ pluginRSC({
138
+ layers: {
139
+ rsc: [
140
+ /render[/\\].*[/\\]server[/\\]rsc/,
141
+ /AppProxy/,
142
+ routesFileReg
143
+ ]
144
+ }
145
+ }),
146
+ pluginRscConfig()
147
+ ];
148
+ }
149
+ return [];
150
+ }
151
+ exports.getRscPlugins = __webpack_exports__.getRscPlugins;
152
+ exports.pluginRscConfig = __webpack_exports__.pluginRscConfig;
153
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
154
+ "getRscPlugins",
155
+ "pluginRscConfig"
156
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
157
+ Object.defineProperty(exports, '__esModule', {
158
+ value: true
159
+ });
@@ -0,0 +1,64 @@
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
+ pluginRsdoctor: ()=>pluginRsdoctor
28
+ });
29
+ const isRsdoctorEnabled = (config)=>{
30
+ if (void 0 === config) return false;
31
+ if ('boolean' == typeof config) return config;
32
+ if ('boolean' == typeof config?.enabled) return config.enabled;
33
+ return true;
34
+ };
35
+ const getRsdoctorPluginOptions = (config)=>{
36
+ if (config && 'object' == typeof config) return {
37
+ disableClientServer: config.disableClientServer ?? true
38
+ };
39
+ return {
40
+ disableClientServer: true
41
+ };
42
+ };
43
+ const pluginRsdoctor = (config)=>{
44
+ if (!isRsdoctorEnabled(config)) return null;
45
+ const pluginOptions = getRsdoctorPluginOptions(config);
46
+ return {
47
+ name: 'builder:rsdoctor',
48
+ setup (api) {
49
+ api.modifyBundlerChain(async (chain)=>{
50
+ const { RsdoctorRspackPlugin } = await import("@rsdoctor/rspack-plugin");
51
+ chain.plugin('rsdoctor').use(RsdoctorRspackPlugin, [
52
+ pluginOptions
53
+ ]);
54
+ });
55
+ }
56
+ };
57
+ };
58
+ exports.pluginRsdoctor = __webpack_exports__.pluginRsdoctor;
59
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
60
+ "pluginRsdoctor"
61
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
62
+ Object.defineProperty(exports, '__esModule', {
63
+ value: true
64
+ });
@@ -0,0 +1,55 @@
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
+ pluginRuntimeChunk: ()=>pluginRuntimeChunk
28
+ });
29
+ const utils_js_namespaceObject = require("../shared/utils.js");
30
+ const pluginRuntimeChunk = (disableInlineRuntimeChunk)=>({
31
+ name: 'builder:runtime-chunk',
32
+ setup (api) {
33
+ api.modifyBundlerChain(async (chain, { target, environment })=>{
34
+ if ('web' !== target) return;
35
+ const { config } = environment;
36
+ const { chunkSplit } = config.performance;
37
+ if (chunkSplit?.strategy !== 'all-in-one' && false !== config.splitChunks) chain.optimization.runtimeChunk({
38
+ name: utils_js_namespaceObject.RUNTIME_CHUNK_NAME
39
+ });
40
+ });
41
+ api.modifyRsbuildConfig((config)=>{
42
+ config.output ||= {};
43
+ if (disableInlineRuntimeChunk) return;
44
+ const originalConfig = api.getRsbuildConfig('original');
45
+ if (originalConfig.output?.inlineScripts === void 0) config.output.inlineScripts = utils_js_namespaceObject.RUNTIME_CHUNK_REGEX;
46
+ });
47
+ }
48
+ });
49
+ exports.pluginRuntimeChunk = __webpack_exports__.pluginRuntimeChunk;
50
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
51
+ "pluginRuntimeChunk"
52
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
53
+ Object.defineProperty(exports, '__esModule', {
54
+ value: true
55
+ });
@@ -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
+ });