@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.
- package/LICENSE +21 -0
- package/README.md +26 -0
- package/dist/cjs/createBuilder.js +94 -0
- package/dist/cjs/index.js +59 -0
- package/dist/cjs/plugins/devtools.js +47 -0
- package/dist/cjs/plugins/emitRouteFile.js +75 -0
- package/dist/cjs/plugins/environmentDefaults.js +100 -0
- package/dist/cjs/plugins/globalVars.js +55 -0
- package/dist/cjs/plugins/htmlMinify.js +115 -0
- package/dist/cjs/plugins/manifest.js +52 -0
- package/dist/cjs/plugins/postcss.js +162 -0
- package/dist/cjs/plugins/rscConfig.js +159 -0
- package/dist/cjs/plugins/rsdoctor.js +64 -0
- package/dist/cjs/plugins/runtimeChunk.js +55 -0
- package/dist/cjs/shared/devServer.js +87 -0
- package/dist/cjs/shared/getCssSupport.js +121 -0
- package/dist/cjs/shared/manifest.js +46 -0
- package/dist/cjs/shared/parseCommonConfig.js +210 -0
- package/dist/cjs/shared/rsc/rsc-server-entry-loader.js +41 -0
- package/dist/cjs/shared/rsc/rscClientBrowserFallback.js +64 -0
- package/dist/cjs/shared/rsc/rscEmptyModule.js +36 -0
- package/dist/cjs/shared/utils.js +115 -0
- package/dist/cjs/types.js +18 -0
- package/dist/esm/createBuilder.mjs +57 -0
- package/dist/esm/index.mjs +3 -0
- package/dist/esm/plugins/devtools.mjs +13 -0
- package/dist/esm/plugins/emitRouteFile.mjs +28 -0
- package/dist/esm/plugins/environmentDefaults.mjs +66 -0
- package/dist/esm/plugins/globalVars.mjs +21 -0
- package/dist/esm/plugins/htmlMinify.mjs +81 -0
- package/dist/esm/plugins/manifest.mjs +18 -0
- package/dist/esm/plugins/postcss.mjs +115 -0
- package/dist/esm/plugins/rscConfig.mjs +112 -0
- package/dist/esm/plugins/rsdoctor.mjs +30 -0
- package/dist/esm/plugins/runtimeChunk.mjs +21 -0
- package/dist/esm/shared/devServer.mjs +53 -0
- package/dist/esm/shared/getCssSupport.mjs +77 -0
- package/dist/esm/shared/manifest.mjs +12 -0
- package/dist/esm/shared/parseCommonConfig.mjs +173 -0
- package/dist/esm/shared/rsc/rsc-server-entry-loader.mjs +7 -0
- package/dist/esm/shared/rsc/rscClientBrowserFallback.mjs +20 -0
- package/dist/esm/shared/rsc/rscEmptyModule.mjs +2 -0
- package/dist/esm/shared/utils.mjs +53 -0
- package/dist/esm/types.mjs +0 -0
- package/dist/esm-node/createBuilder.mjs +58 -0
- package/dist/esm-node/index.mjs +4 -0
- package/dist/esm-node/plugins/devtools.mjs +14 -0
- package/dist/esm-node/plugins/emitRouteFile.mjs +29 -0
- package/dist/esm-node/plugins/environmentDefaults.mjs +67 -0
- package/dist/esm-node/plugins/globalVars.mjs +22 -0
- package/dist/esm-node/plugins/htmlMinify.mjs +82 -0
- package/dist/esm-node/plugins/manifest.mjs +19 -0
- package/dist/esm-node/plugins/postcss.mjs +116 -0
- package/dist/esm-node/plugins/rscConfig.mjs +117 -0
- package/dist/esm-node/plugins/rsdoctor.mjs +31 -0
- package/dist/esm-node/plugins/runtimeChunk.mjs +22 -0
- package/dist/esm-node/shared/devServer.mjs +54 -0
- package/dist/esm-node/shared/getCssSupport.mjs +78 -0
- package/dist/esm-node/shared/manifest.mjs +13 -0
- package/dist/esm-node/shared/parseCommonConfig.mjs +174 -0
- package/dist/esm-node/shared/rsc/rsc-server-entry-loader.mjs +8 -0
- package/dist/esm-node/shared/rsc/rscClientBrowserFallback.mjs +25 -0
- package/dist/esm-node/shared/rsc/rscEmptyModule.mjs +3 -0
- package/dist/esm-node/shared/utils.mjs +54 -0
- package/dist/esm-node/types.mjs +1 -0
- package/dist/types/createBuilder.d.ts +8 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/plugins/devtools.d.ts +4 -0
- package/dist/types/plugins/emitRouteFile.d.ts +6 -0
- package/dist/types/plugins/environmentDefaults.d.ts +3 -0
- package/dist/types/plugins/globalVars.d.ts +3 -0
- package/dist/types/plugins/htmlMinify.d.ts +2 -0
- package/dist/types/plugins/manifest.d.ts +2 -0
- package/dist/types/plugins/postcss.d.ts +6 -0
- package/dist/types/plugins/rscConfig.d.ts +18 -0
- package/dist/types/plugins/rsdoctor.d.ts +3 -0
- package/dist/types/plugins/runtimeChunk.d.ts +2 -0
- package/dist/types/shared/devServer.d.ts +6 -0
- package/dist/types/shared/getCssSupport.d.ts +1 -0
- package/dist/types/shared/manifest.d.ts +2 -0
- package/dist/types/shared/parseCommonConfig.d.ts +9 -0
- package/dist/types/shared/rsc/rsc-server-entry-loader.d.ts +5 -0
- package/dist/types/shared/rsc/rscClientBrowserFallback.d.ts +2 -0
- package/dist/types/shared/rsc/rscEmptyModule.d.ts +2 -0
- package/dist/types/shared/utils.d.ts +12 -0
- package/dist/types/types.d.ts +287 -0
- package/package.json +88 -0
|
@@ -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,210 @@
|
|
|
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: { rsdoctor: rsdoctorConfig, ...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
|
+
rsdoctorConfig
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
exports.isLooseCssModules = __webpack_exports__.isLooseCssModules;
|
|
203
|
+
exports.parseCommonConfig = __webpack_exports__.parseCommonConfig;
|
|
204
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
205
|
+
"isLooseCssModules",
|
|
206
|
+
"parseCommonConfig"
|
|
207
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
208
|
+
Object.defineProperty(exports, '__esModule', {
|
|
209
|
+
value: true
|
|
210
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
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: ()=>rscServerEntryLoader
|
|
28
|
+
});
|
|
29
|
+
function rscServerEntryLoader(source) {
|
|
30
|
+
this.cacheable(true);
|
|
31
|
+
const hasServerEntryDirective = source.includes("'use server-entry'") || source.includes('"use server-entry"') || source.includes('`use server-entry`');
|
|
32
|
+
if (hasServerEntryDirective) return source;
|
|
33
|
+
return `'use server-entry';\n${source}`;
|
|
34
|
+
}
|
|
35
|
+
exports["default"] = __webpack_exports__["default"];
|
|
36
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
37
|
+
"default"
|
|
38
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
39
|
+
Object.defineProperty(exports, '__esModule', {
|
|
40
|
+
value: true
|
|
41
|
+
});
|
|
@@ -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-rspack/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
|
+
});
|
|
@@ -0,0 +1,115 @@
|
|
|
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
|
+
NODE_MODULES_REGEX: ()=>NODE_MODULES_REGEX,
|
|
37
|
+
RUNTIME_CHUNK_NAME: ()=>RUNTIME_CHUNK_NAME,
|
|
38
|
+
RUNTIME_CHUNK_REGEX: ()=>RUNTIME_CHUNK_REGEX,
|
|
39
|
+
SERVICE_WORKER_ENVIRONMENT_NAME: ()=>SERVICE_WORKER_ENVIRONMENT_NAME,
|
|
40
|
+
castArray: ()=>castArray,
|
|
41
|
+
getBrowserslistWithDefault: ()=>getBrowserslistWithDefault,
|
|
42
|
+
isHtmlDisabled: ()=>isHtmlDisabled
|
|
43
|
+
});
|
|
44
|
+
const external_browserslist_namespaceObject = require("browserslist");
|
|
45
|
+
var external_browserslist_default = /*#__PURE__*/ __webpack_require__.n(external_browserslist_namespaceObject);
|
|
46
|
+
const RUNTIME_CHUNK_NAME = 'builder-runtime';
|
|
47
|
+
const RUNTIME_CHUNK_REGEX = new RegExp(`${RUNTIME_CHUNK_NAME}([.].+)?\\.js$`);
|
|
48
|
+
const SERVICE_WORKER_ENVIRONMENT_NAME = 'workerSSR';
|
|
49
|
+
const NODE_MODULES_REGEX = /[\\/]node_modules[\\/]/;
|
|
50
|
+
const castArray = (arr)=>{
|
|
51
|
+
if (void 0 === arr) return [];
|
|
52
|
+
return Array.isArray(arr) ? arr : [
|
|
53
|
+
arr
|
|
54
|
+
];
|
|
55
|
+
};
|
|
56
|
+
const browsersListCache = new Map();
|
|
57
|
+
async function getBrowserslist(path) {
|
|
58
|
+
const env = process.env.NODE_ENV;
|
|
59
|
+
const cacheKey = `${path}${env}`;
|
|
60
|
+
if (browsersListCache.has(cacheKey)) return browsersListCache.get(cacheKey);
|
|
61
|
+
const result = external_browserslist_default().loadConfig({
|
|
62
|
+
path,
|
|
63
|
+
env
|
|
64
|
+
});
|
|
65
|
+
if (result) {
|
|
66
|
+
browsersListCache.set(cacheKey, result);
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
const isHtmlDisabled = (config, target)=>{
|
|
72
|
+
const { htmlPlugin } = config.tools;
|
|
73
|
+
return false === htmlPlugin || Array.isArray(htmlPlugin) && htmlPlugin.includes(false) || 'web' !== target;
|
|
74
|
+
};
|
|
75
|
+
const DEFAULT_WEB_BROWSERSLIST = [
|
|
76
|
+
'chrome >= 87',
|
|
77
|
+
'edge >= 88',
|
|
78
|
+
'firefox >= 78',
|
|
79
|
+
'safari >= 14'
|
|
80
|
+
];
|
|
81
|
+
const DEFAULT_BROWSERSLIST = {
|
|
82
|
+
web: DEFAULT_WEB_BROWSERSLIST,
|
|
83
|
+
node: [
|
|
84
|
+
'node >= 16'
|
|
85
|
+
],
|
|
86
|
+
'web-worker': DEFAULT_WEB_BROWSERSLIST
|
|
87
|
+
};
|
|
88
|
+
async function getBrowserslistWithDefault(path, config, target) {
|
|
89
|
+
const { overrideBrowserslist: overrides } = config?.output || {};
|
|
90
|
+
if ('web' === target || 'web-worker' === target) {
|
|
91
|
+
if (overrides) return overrides;
|
|
92
|
+
const browserslistrc = await getBrowserslist(path);
|
|
93
|
+
if (browserslistrc) return browserslistrc;
|
|
94
|
+
}
|
|
95
|
+
return DEFAULT_BROWSERSLIST[target];
|
|
96
|
+
}
|
|
97
|
+
exports.NODE_MODULES_REGEX = __webpack_exports__.NODE_MODULES_REGEX;
|
|
98
|
+
exports.RUNTIME_CHUNK_NAME = __webpack_exports__.RUNTIME_CHUNK_NAME;
|
|
99
|
+
exports.RUNTIME_CHUNK_REGEX = __webpack_exports__.RUNTIME_CHUNK_REGEX;
|
|
100
|
+
exports.SERVICE_WORKER_ENVIRONMENT_NAME = __webpack_exports__.SERVICE_WORKER_ENVIRONMENT_NAME;
|
|
101
|
+
exports.castArray = __webpack_exports__.castArray;
|
|
102
|
+
exports.getBrowserslistWithDefault = __webpack_exports__.getBrowserslistWithDefault;
|
|
103
|
+
exports.isHtmlDisabled = __webpack_exports__.isHtmlDisabled;
|
|
104
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
105
|
+
"NODE_MODULES_REGEX",
|
|
106
|
+
"RUNTIME_CHUNK_NAME",
|
|
107
|
+
"RUNTIME_CHUNK_REGEX",
|
|
108
|
+
"SERVICE_WORKER_ENVIRONMENT_NAME",
|
|
109
|
+
"castArray",
|
|
110
|
+
"getBrowserslistWithDefault",
|
|
111
|
+
"isHtmlDisabled"
|
|
112
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
113
|
+
Object.defineProperty(exports, '__esModule', {
|
|
114
|
+
value: true
|
|
115
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.r = (exports1)=>{
|
|
5
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
6
|
+
value: 'Module'
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
9
|
+
value: true
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
})();
|
|
13
|
+
var __webpack_exports__ = {};
|
|
14
|
+
__webpack_require__.r(__webpack_exports__);
|
|
15
|
+
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
16
|
+
Object.defineProperty(exports, '__esModule', {
|
|
17
|
+
value: true
|
|
18
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { createRsbuild } from "@rsbuild/core";
|
|
2
|
+
import { getRscPlugins } from "./plugins/rscConfig.mjs";
|
|
3
|
+
import { pluginRsdoctor } from "./plugins/rsdoctor.mjs";
|
|
4
|
+
import { parseCommonConfig } from "./shared/parseCommonConfig.mjs";
|
|
5
|
+
import { rscClientBrowserFallbackPlugin } from "./shared/rsc/rscClientBrowserFallback.mjs";
|
|
6
|
+
async function parseConfig(builderConfig, options) {
|
|
7
|
+
builderConfig.performance ??= {};
|
|
8
|
+
builderConfig.performance.buildCache ??= true;
|
|
9
|
+
const { rsbuildConfig, rsbuildPlugins, rsdoctorConfig } = await parseCommonConfig(builderConfig, options);
|
|
10
|
+
const { sri } = builderConfig.security || {};
|
|
11
|
+
if (sri) if (true === sri) rsbuildConfig.security.sri = {
|
|
12
|
+
enable: 'auto'
|
|
13
|
+
};
|
|
14
|
+
else {
|
|
15
|
+
const algorithm = Array.isArray(sri.hashFuncNames) ? sri.hashFuncNames[0] : void 0;
|
|
16
|
+
rsbuildConfig.security.sri = {
|
|
17
|
+
enable: sri.enabled,
|
|
18
|
+
algorithm
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
if (false === Boolean(rsbuildConfig.tools.lightningcssLoader)) {
|
|
22
|
+
const { pluginPostcss } = await import("./plugins/postcss.mjs");
|
|
23
|
+
rsbuildPlugins.push(pluginPostcss({
|
|
24
|
+
autoprefixer: builderConfig.tools?.autoprefixer
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
const enableRsc = builderConfig.server?.rsc ?? false;
|
|
28
|
+
if (enableRsc) {
|
|
29
|
+
const rscPlugins = await getRscPlugins(enableRsc, options.internalDirectory);
|
|
30
|
+
rsbuildPlugins.push(...rscPlugins);
|
|
31
|
+
} else rsbuildPlugins.push(rscClientBrowserFallbackPlugin());
|
|
32
|
+
const rsdoctorPlugin = pluginRsdoctor(rsdoctorConfig);
|
|
33
|
+
if (rsdoctorPlugin) rsbuildPlugins.push(rsdoctorPlugin);
|
|
34
|
+
return {
|
|
35
|
+
rsbuildConfig,
|
|
36
|
+
rsbuildPlugins
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
async function createRspackBuilder(options) {
|
|
40
|
+
const { cwd = process.cwd(), config, ...rest } = options;
|
|
41
|
+
const { rsbuildConfig, rsbuildPlugins } = await parseConfig(config, {
|
|
42
|
+
...rest,
|
|
43
|
+
cwd
|
|
44
|
+
});
|
|
45
|
+
rsbuildConfig.plugins = [
|
|
46
|
+
...rsbuildPlugins,
|
|
47
|
+
...rsbuildConfig.plugins || []
|
|
48
|
+
];
|
|
49
|
+
const rsbuild = await createRsbuild({
|
|
50
|
+
cwd,
|
|
51
|
+
rsbuildConfig
|
|
52
|
+
});
|
|
53
|
+
return {
|
|
54
|
+
...rsbuild
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export { createRspackBuilder, parseConfig };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { createRspackBuilder as createBuilder, parseConfig as parseRspackConfig } from "./createBuilder.mjs";
|
|
2
|
+
export { logger } from "@rsbuild/core";
|
|
3
|
+
export { RUNTIME_CHUNK_NAME, RUNTIME_CHUNK_REGEX, SERVICE_WORKER_ENVIRONMENT_NAME, castArray, isHtmlDisabled } from "./shared/utils.mjs";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const pluginDevtool = (options)=>({
|
|
2
|
+
name: 'builder:devtool',
|
|
3
|
+
setup (api) {
|
|
4
|
+
const devtoolJs = 'boolean' == typeof options.sourceMap || options.sourceMap?.js !== void 0;
|
|
5
|
+
if (devtoolJs) return;
|
|
6
|
+
api.modifyBundlerChain((chain, { isProd, isServer })=>{
|
|
7
|
+
const prodDevTool = isServer ? 'source-map' : 'hidden-source-map';
|
|
8
|
+
const devtool = isProd ? prodDevTool : 'cheap-module-source-map';
|
|
9
|
+
chain.devtool(devtool);
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
export { pluginDevtool };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import node_fs from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
async function isFileExists(file) {
|
|
4
|
+
return node_fs.promises.access(file, node_fs.constants.F_OK).then(()=>true).catch(()=>false);
|
|
5
|
+
}
|
|
6
|
+
const pluginEmitRouteFile = ()=>({
|
|
7
|
+
name: 'builder:emit-route-file',
|
|
8
|
+
setup (api) {
|
|
9
|
+
api.onBeforeStartDevServer(async ({ environments })=>{
|
|
10
|
+
const { fs, ROUTE_SPEC_FILE } = await import("@modern-js/utils");
|
|
11
|
+
const routeFilePath = join(api.context.distPath, ROUTE_SPEC_FILE);
|
|
12
|
+
const htmlPaths = Object.values(environments).reduce((prev, curr)=>({
|
|
13
|
+
...prev,
|
|
14
|
+
...curr.htmlPaths
|
|
15
|
+
}), {});
|
|
16
|
+
const routesInfo = Object.entries(htmlPaths).map(([entryName, filename], index)=>({
|
|
17
|
+
urlPath: 0 === index ? '/' : `/${entryName}`,
|
|
18
|
+
entryName,
|
|
19
|
+
entryPath: filename,
|
|
20
|
+
isSPA: true
|
|
21
|
+
}));
|
|
22
|
+
if (!await isFileExists(routeFilePath) && routesInfo.length) await fs.outputFile(routeFilePath, JSON.stringify({
|
|
23
|
+
routes: routesInfo
|
|
24
|
+
}, null, 2));
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
export { isFileExists, pluginEmitRouteFile };
|