@rsbuild/core 1.3.0-beta.3 → 1.3.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/compiled/css-loader/index.js +18 -18
- package/compiled/html-rspack-plugin/index.js +14 -14
- package/compiled/postcss-loader/index.js +6 -6
- package/compiled/rspack-manifest-plugin/index.js +4 -4
- package/dist/index.cjs +261 -283
- package/dist/index.js +189 -214
- package/dist/transformLoader.mjs +3 -1
- package/dist/transformRawLoader.mjs +3 -1
- package/dist-types/config.d.ts +7 -0
- package/dist-types/types/config.d.ts +2 -2
- package/dist-types/types/plugin.d.ts +13 -0
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -33,21 +33,19 @@ var EsmMode, __webpack_modules__ = {
|
|
|
33
33
|
module.exports = function cloneDeep(val, instanceClone) {
|
|
34
34
|
switch(typeOf(val)){
|
|
35
35
|
case 'object':
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return res;
|
|
42
|
-
}
|
|
43
|
-
return val;
|
|
44
|
-
}(val, instanceClone);
|
|
45
|
-
case 'array':
|
|
46
|
-
return function(val, instanceClone) {
|
|
47
|
-
let res = new val.constructor(val.length);
|
|
48
|
-
for(let i = 0; i < val.length; i++)res[i] = cloneDeep(val[i], instanceClone);
|
|
36
|
+
var val1 = val, instanceClone1 = instanceClone;
|
|
37
|
+
if ('function' == typeof instanceClone1) return instanceClone1(val1);
|
|
38
|
+
if (instanceClone1 || isPlainObject(val1)) {
|
|
39
|
+
let res = new val1.constructor();
|
|
40
|
+
for(let key in val1)res[key] = cloneDeep(val1[key], instanceClone1);
|
|
49
41
|
return res;
|
|
50
|
-
}
|
|
42
|
+
}
|
|
43
|
+
return val1;
|
|
44
|
+
case 'array':
|
|
45
|
+
var val2 = val, instanceClone2 = instanceClone;
|
|
46
|
+
let res = new val2.constructor(val2.length);
|
|
47
|
+
for(let i = 0; i < val2.length; i++)res[i] = cloneDeep(val2[i], instanceClone2);
|
|
48
|
+
return res;
|
|
51
49
|
default:
|
|
52
50
|
return clone(val);
|
|
53
51
|
}
|
|
@@ -84,7 +82,7 @@ var EsmMode, __webpack_modules__ = {
|
|
|
84
82
|
return sourceIsArray !== Array.isArray(target) ? cloneUnlessOtherwiseSpecified(source, options) : sourceIsArray ? options.arrayMerge(target, source, options) : (destination = {}, (options1 = options).isMergeableObject(target) && getKeys(target).forEach(function(key) {
|
|
85
83
|
destination[key] = cloneUnlessOtherwiseSpecified(target[key], options1);
|
|
86
84
|
}), getKeys(source).forEach(function(key) {
|
|
87
|
-
|
|
85
|
+
propertyIsOnObject(target, key) && !(Object.hasOwnProperty.call(target, key) && Object.propertyIsEnumerable.call(target, key)) || (propertyIsOnObject(target, key) && options1.isMergeableObject(source[key]) ? destination[key] = (function(key, options) {
|
|
88
86
|
if (!options.customMerge) return deepmerge;
|
|
89
87
|
var customMerge = options.customMerge(key);
|
|
90
88
|
return 'function' == typeof customMerge ? customMerge : deepmerge;
|
|
@@ -107,8 +105,7 @@ var EsmMode, __webpack_modules__ = {
|
|
|
107
105
|
for(let key in options && null != options.processEnv && (processEnv = options.processEnv), options.parsed){
|
|
108
106
|
let value = options.parsed[key];
|
|
109
107
|
value = processEnv[key] && processEnv[key] !== value ? processEnv[key] : function(value, processEnv, runningParsed) {
|
|
110
|
-
let match
|
|
111
|
-
let env = {
|
|
108
|
+
let match, env = {
|
|
112
109
|
...runningParsed,
|
|
113
110
|
...processEnv
|
|
114
111
|
}, regex = /(?<!\\)\${([^{}]+)}|(?<!\\)\$([A-Za-z_][A-Za-z0-9_]*)/g, result = value, seen = new Set();
|
|
@@ -139,10 +136,9 @@ var EsmMode, __webpack_modules__ = {
|
|
|
139
136
|
}
|
|
140
137
|
function _vaultPath(options) {
|
|
141
138
|
let possibleVaultPath = null;
|
|
142
|
-
if (options && options.path && options.path.length > 0) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
} else possibleVaultPath = path.resolve(process.cwd(), '.env.vault');
|
|
139
|
+
if (options && options.path && options.path.length > 0) if (Array.isArray(options.path)) for (let filepath of options.path)fs.existsSync(filepath) && (possibleVaultPath = filepath.endsWith('.vault') ? filepath : `${filepath}.vault`);
|
|
140
|
+
else possibleVaultPath = options.path.endsWith('.vault') ? options.path : `${options.path}.vault`;
|
|
141
|
+
else possibleVaultPath = path.resolve(process.cwd(), '.env.vault');
|
|
146
142
|
return fs.existsSync(possibleVaultPath) ? possibleVaultPath : null;
|
|
147
143
|
}
|
|
148
144
|
function _resolveHome(envPath) {
|
|
@@ -150,18 +146,15 @@ var EsmMode, __webpack_modules__ = {
|
|
|
150
146
|
}
|
|
151
147
|
let DotenvModule = {
|
|
152
148
|
configDotenv: function(options) {
|
|
153
|
-
let lastError;
|
|
154
|
-
let dotenvPath = path.resolve(process.cwd(), '.env'), encoding = 'utf8', debug = !!(options && options.debug);
|
|
149
|
+
let lastError, dotenvPath = path.resolve(process.cwd(), '.env'), encoding = 'utf8', debug = !!(options && options.debug);
|
|
155
150
|
options && options.encoding ? encoding = options.encoding : debug && _debug('No encoding is specified. UTF-8 is used by default');
|
|
156
151
|
let optionPaths = [
|
|
157
152
|
dotenvPath
|
|
158
153
|
];
|
|
159
|
-
if (options && options.path)
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
];
|
|
164
|
-
}
|
|
154
|
+
if (options && options.path) if (Array.isArray(options.path)) for (let filepath of (optionPaths = [], options.path))optionPaths.push(_resolveHome(filepath));
|
|
155
|
+
else optionPaths = [
|
|
156
|
+
_resolveHome(options.path)
|
|
157
|
+
];
|
|
165
158
|
let parsedAll = {};
|
|
166
159
|
for (let path of optionPaths)try {
|
|
167
160
|
let parsed = DotenvModule.parse(fs.readFileSync(path, {
|
|
@@ -187,8 +180,7 @@ var EsmMode, __webpack_modules__ = {
|
|
|
187
180
|
};
|
|
188
181
|
},
|
|
189
182
|
_parseVault: function(options) {
|
|
190
|
-
let decrypted
|
|
191
|
-
let vaultPath = _vaultPath(options), result = DotenvModule.configDotenv({
|
|
183
|
+
let decrypted, vaultPath = _vaultPath(options), result = DotenvModule.configDotenv({
|
|
192
184
|
path: vaultPath
|
|
193
185
|
});
|
|
194
186
|
if (!result.parsed) {
|
|
@@ -264,8 +256,7 @@ var EsmMode, __webpack_modules__ = {
|
|
|
264
256
|
}
|
|
265
257
|
},
|
|
266
258
|
parse: function(src) {
|
|
267
|
-
let match;
|
|
268
|
-
let obj = {}, lines = src.toString();
|
|
259
|
+
let match, obj = {}, lines = src.toString();
|
|
269
260
|
for(lines = lines.replace(/\r\n?/mg, '\n'); null != (match = LINE.exec(lines));){
|
|
270
261
|
let key = match[1], value = match[2] || '', maybeQuote = (value = value.trim())[0];
|
|
271
262
|
value = value.replace(/^(['"`])([\s\S]*)\1$/mg, '$2'), '"' === maybeQuote && (value = (value = value.replace(/\\n/g, '\n')).replace(/\\r/g, '\r')), obj[key] = value;
|
|
@@ -423,7 +414,6 @@ var EsmMode, __webpack_modules__ = {
|
|
|
423
414
|
"../../node_modules/.pnpm/shallow-clone@3.0.1/node_modules/shallow-clone/index.js": function(module, __unused_webpack_exports, __webpack_require__) {
|
|
424
415
|
let valueOf = Symbol.prototype.valueOf, typeOf = __webpack_require__("../../node_modules/.pnpm/kind-of@6.0.3/node_modules/kind-of/index.js");
|
|
425
416
|
module.exports = function(val, deep) {
|
|
426
|
-
var val1, val2, deep1;
|
|
427
417
|
switch(typeOf(val)){
|
|
428
418
|
case 'array':
|
|
429
419
|
return val.slice();
|
|
@@ -436,17 +426,15 @@ var EsmMode, __webpack_modules__ = {
|
|
|
436
426
|
case 'set':
|
|
437
427
|
return new Set(val);
|
|
438
428
|
case 'buffer':
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
}(val);
|
|
429
|
+
var val1, val2, deep1, val3 = val;
|
|
430
|
+
let len = val3.length, buf = Buffer.allocUnsafe ? Buffer.allocUnsafe(len) : Buffer.from(len);
|
|
431
|
+
return val3.copy(buf), buf;
|
|
443
432
|
case 'symbol':
|
|
444
433
|
return val1 = val, valueOf ? Object(valueOf.call(val1)) : {};
|
|
445
434
|
case 'arraybuffer':
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
}(val);
|
|
435
|
+
var val4 = val;
|
|
436
|
+
let res = new val4.constructor(val4.byteLength);
|
|
437
|
+
return new Uint8Array(res).set(new Uint8Array(val4)), res;
|
|
450
438
|
case 'float32array':
|
|
451
439
|
case 'float64array':
|
|
452
440
|
case 'int16array':
|
|
@@ -458,10 +446,9 @@ var EsmMode, __webpack_modules__ = {
|
|
|
458
446
|
case 'uint8array':
|
|
459
447
|
return new (val2 = val).constructor(val2.buffer, val2.byteOffset, val2.length);
|
|
460
448
|
case 'regexp':
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
}(val);
|
|
449
|
+
var val5 = val;
|
|
450
|
+
let flags = void 0 !== val5.flags ? val5.flags : /\w+$/.exec(val5) || void 0, re = new val5.constructor(val5.source, flags);
|
|
451
|
+
return re.lastIndex = val5.lastIndex, re;
|
|
465
452
|
case 'error':
|
|
466
453
|
return Object.create(val);
|
|
467
454
|
default:
|
|
@@ -499,8 +486,8 @@ var EsmMode, __webpack_modules__ = {
|
|
|
499
486
|
Object.defineProperty(exports, "__esModule", {
|
|
500
487
|
value: !0
|
|
501
488
|
}), exports.unique = exports.mergeWithRules = exports.mergeWithCustomize = exports.default = exports.merge = exports.CustomizeRule = exports.customizeObject = exports.customizeArray = void 0;
|
|
502
|
-
var wildcard_1 = __importDefault(__webpack_require__("../../node_modules/.pnpm/wildcard@2.0.1/node_modules/wildcard/index.js")), merge_with_1 = __importDefault(__webpack_require__("../../node_modules/.pnpm/webpack-merge@6.0.1/node_modules/webpack-merge/dist/merge-with.js")), join_arrays_1 = __importDefault(__webpack_require__("../../node_modules/.pnpm/webpack-merge@6.0.1/node_modules/webpack-merge/dist/join-arrays.js"))
|
|
503
|
-
exports.unique =
|
|
489
|
+
var wildcard_1 = __importDefault(__webpack_require__("../../node_modules/.pnpm/wildcard@2.0.1/node_modules/wildcard/index.js")), merge_with_1 = __importDefault(__webpack_require__("../../node_modules/.pnpm/webpack-merge@6.0.1/node_modules/webpack-merge/dist/merge-with.js")), join_arrays_1 = __importDefault(__webpack_require__("../../node_modules/.pnpm/webpack-merge@6.0.1/node_modules/webpack-merge/dist/join-arrays.js"));
|
|
490
|
+
exports.unique = __importDefault(__webpack_require__("../../node_modules/.pnpm/webpack-merge@6.0.1/node_modules/webpack-merge/dist/unique.js")).default;
|
|
504
491
|
var types_1 = __webpack_require__("../../node_modules/.pnpm/webpack-merge@6.0.1/node_modules/webpack-merge/dist/types.js");
|
|
505
492
|
Object.defineProperty(exports, "CustomizeRule", {
|
|
506
493
|
enumerable: !0,
|
|
@@ -877,12 +864,12 @@ var EsmMode, __webpack_modules__ = {
|
|
|
877
864
|
}
|
|
878
865
|
WildcardMatcher.prototype.match = function(input) {
|
|
879
866
|
var ii, testParts, matches = !0, parts = this.parts, partsCount = parts.length;
|
|
880
|
-
if ('string' == typeof input || input instanceof String) {
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
867
|
+
if ('string' == typeof input || input instanceof String) if (this.hasWild || this.text == input) {
|
|
868
|
+
for(ii = 0, testParts = (input || '').split(this.separator); matches && ii < partsCount; ii++)if ('*' === parts[ii]) continue;
|
|
869
|
+
else matches = ii < testParts.length && (parts[ii] instanceof RegExp ? parts[ii].test(testParts[ii]) : parts[ii] === testParts[ii]);
|
|
870
|
+
matches = matches && testParts;
|
|
871
|
+
} else matches = !1;
|
|
872
|
+
else if ('function' == typeof input.splice) for(matches = [], ii = input.length; ii--;)this.match(input[ii]) && (matches[matches.length] = input[ii]);
|
|
886
873
|
else if ('object' == typeof input) for(var key in matches = {}, input)this.match(key) && (matches[key] = input[key]);
|
|
887
874
|
return matches;
|
|
888
875
|
}, WildcardMatcher.prototype.classifyPart = function(part) {
|
|
@@ -1370,12 +1357,13 @@ function parsePackage(file) {
|
|
|
1370
1357
|
let list = config.browserslist;
|
|
1371
1358
|
for(let i in Array.isArray(list) && (list = {
|
|
1372
1359
|
defaults: list
|
|
1373
|
-
}), 'string' == typeof list && (list = parseConfig(list)), list)
|
|
1360
|
+
}), 'string' == typeof list && (list = parseConfig(list)), list){
|
|
1361
|
+
var section = list[i];
|
|
1374
1362
|
let FORMAT = 'Browserslist config should be a string or an array of strings with browser queries';
|
|
1375
1363
|
if (Array.isArray(section)) {
|
|
1376
1364
|
for(let i = 0; i < section.length; i++)if ('string' != typeof section[i]) throw new BrowserslistError(FORMAT);
|
|
1377
1365
|
} else if ('string' != typeof section) throw new BrowserslistError(FORMAT);
|
|
1378
|
-
}
|
|
1366
|
+
}
|
|
1379
1367
|
return list;
|
|
1380
1368
|
}
|
|
1381
1369
|
let IS_SECTION = /^\s*\[(.+)]\s*$/;
|
|
@@ -1396,10 +1384,9 @@ function parseConfig(string) {
|
|
|
1396
1384
|
}), result;
|
|
1397
1385
|
}
|
|
1398
1386
|
function parsePackageOrReadConfig(file) {
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
}(file);
|
|
1387
|
+
if ('package.json' === __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.basename(file)) return parsePackage(file);
|
|
1388
|
+
if (!isFile(file)) throw new BrowserslistError(`Can't read ${file} config`);
|
|
1389
|
+
return parseConfig(__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.readFileSync(file, 'utf-8'));
|
|
1403
1390
|
}
|
|
1404
1391
|
function pickEnv(config, opts) {
|
|
1405
1392
|
let name;
|
|
@@ -1469,7 +1456,7 @@ let configCache = {}, OVERRIDE_PATHS = [
|
|
|
1469
1456
|
overlay: !0,
|
|
1470
1457
|
reconnect: 100
|
|
1471
1458
|
}
|
|
1472
|
-
}), getDefaultServerConfig = ()=>({
|
|
1459
|
+
}), LOCAL_ORIGINS_REGEX = /^https?:\/\/(?:(?:[^:]+\.)?localhost|127\.0\.0\.1|\[::1\])(?::\d+)?$/, getDefaultServerConfig = ()=>({
|
|
1473
1460
|
port: 3000,
|
|
1474
1461
|
host: DEFAULT_DEV_HOST,
|
|
1475
1462
|
open: !1,
|
|
@@ -1478,7 +1465,9 @@ let configCache = {}, OVERRIDE_PATHS = [
|
|
|
1478
1465
|
compress: !0,
|
|
1479
1466
|
printUrls: !0,
|
|
1480
1467
|
strictPort: !1,
|
|
1481
|
-
cors:
|
|
1468
|
+
cors: {
|
|
1469
|
+
origin: LOCAL_ORIGINS_REGEX
|
|
1470
|
+
},
|
|
1482
1471
|
middlewareMode: !1
|
|
1483
1472
|
}), getDefaultSourceConfig = ()=>({
|
|
1484
1473
|
alias: {},
|
|
@@ -1626,8 +1615,7 @@ let resolveConfigPath = (root, customConfig)=>{
|
|
|
1626
1615
|
return null;
|
|
1627
1616
|
};
|
|
1628
1617
|
async function config_loadConfig({ cwd = process.cwd(), path, envMode, meta, loader = 'jiti' } = {}) {
|
|
1629
|
-
let configExport;
|
|
1630
|
-
let configFilePath = resolveConfigPath(cwd, path);
|
|
1618
|
+
let configExport, configFilePath = resolveConfigPath(cwd, path);
|
|
1631
1619
|
if (!configFilePath) return __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('no config file found.'), {
|
|
1632
1620
|
content: {},
|
|
1633
1621
|
filePath: configFilePath
|
|
@@ -1880,8 +1868,7 @@ function createAsyncHook() {
|
|
|
1880
1868
|
let onBeforeCompile = ({ compiler, beforeCompile, beforeEnvironmentCompiler, isWatch })=>{
|
|
1881
1869
|
let name = 'rsbuild:beforeCompile';
|
|
1882
1870
|
if (helpers_isMultiCompiler(compiler)) {
|
|
1883
|
-
let waitBeforeCompileDone;
|
|
1884
|
-
let { compilers } = compiler, doneCompilers = 0;
|
|
1871
|
+
let waitBeforeCompileDone, { compilers } = compiler, doneCompilers = 0;
|
|
1885
1872
|
for(let index = 0; index < compilers.length; index++){
|
|
1886
1873
|
let compiler = compilers[index], compilerDone = !1;
|
|
1887
1874
|
(isWatch ? compiler.hooks.watchRun : compiler.hooks.run).tapPromise(name, async ()=>{
|
|
@@ -2044,12 +2031,10 @@ async function getBrowserslist(path) {
|
|
|
2044
2031
|
if (opts.config) return pickEnv(parsePackageOrReadConfig(opts.config), opts);
|
|
2045
2032
|
if (opts.path) {
|
|
2046
2033
|
let config = function(from) {
|
|
2047
|
-
let resolved;
|
|
2048
|
-
let fromDir = isFile(from = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.resolve(from)) ? __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.dirname(from) : from;
|
|
2034
|
+
let resolved, fromDir = isFile(from = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.resolve(from)) ? __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.dirname(from) : from;
|
|
2049
2035
|
if (fromDir in configCache) return configCache[fromDir];
|
|
2050
2036
|
let configFile = eachParent(from, (dir)=>{
|
|
2051
|
-
let pkgBrowserslist;
|
|
2052
|
-
let config = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.join(dir, 'browserslist'), pkg = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.join(dir, 'package.json'), rc = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.join(dir, '.browserslistrc');
|
|
2037
|
+
let pkgBrowserslist, config = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.join(dir, 'browserslist'), pkg = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.join(dir, 'package.json'), rc = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.join(dir, '.browserslistrc');
|
|
2053
2038
|
if (isFile(pkg)) try {
|
|
2054
2039
|
pkgBrowserslist = parsePackage(pkg);
|
|
2055
2040
|
} catch (e) {
|
|
@@ -2101,7 +2086,7 @@ async function updateEnvironmentContext(context, configs) {
|
|
|
2101
2086
|
name,
|
|
2102
2087
|
distPath: function(cwd, config) {
|
|
2103
2088
|
var _config_output_distPath, _config_output;
|
|
2104
|
-
return getAbsolutePath(cwd, (null === (_config_output = config.output) || void 0 === _config_output
|
|
2089
|
+
return getAbsolutePath(cwd, (null === (_config_output = config.output) || void 0 === _config_output || null === (_config_output_distPath = _config_output.distPath) || void 0 === _config_output_distPath ? void 0 : _config_output_distPath.root) ?? ROOT_DIST_DIR);
|
|
2105
2090
|
}(context.rootPath, config),
|
|
2106
2091
|
entry,
|
|
2107
2092
|
browserslist,
|
|
@@ -2118,7 +2103,7 @@ async function updateEnvironmentContext(context, configs) {
|
|
|
2118
2103
|
async function createContext(options, userConfig) {
|
|
2119
2104
|
let { cwd } = options, rootPath = userConfig.root ? getAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0;
|
|
2120
2105
|
return {
|
|
2121
|
-
version: "1.3.0
|
|
2106
|
+
version: "1.3.0",
|
|
2122
2107
|
rootPath,
|
|
2123
2108
|
distPath: '',
|
|
2124
2109
|
cachePath,
|
|
@@ -2556,7 +2541,7 @@ let pluginCache = ()=>({
|
|
|
2556
2541
|
return 'auto' === enable ? isDev && !config.dev.writeToDisk ? void 0 : isStrictSubdir(rootPath, distPath) ? {
|
|
2557
2542
|
path: distPath,
|
|
2558
2543
|
keep
|
|
2559
|
-
} : (__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn('The dist path is not a subdir of root path, Rsbuild will not empty it.'), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`Please set ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('`output.cleanDistPath`')} config manually.`), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`Current root path: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim(rootPath)}`),
|
|
2544
|
+
} : void (__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn('The dist path is not a subdir of root path, Rsbuild will not empty it.'), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`Please set ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('`output.cleanDistPath`')} config manually.`), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`Current root path: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim(rootPath)}`), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`Current dist path: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim(distPath)}`)) : !0 === enable ? {
|
|
2560
2545
|
path: distPath,
|
|
2561
2546
|
keep
|
|
2562
2547
|
} : void 0;
|
|
@@ -2792,15 +2777,14 @@ let isPostcssPluginCreator = (plugin)=>'function' == typeof plugin && !0 === plu
|
|
|
2792
2777
|
not: /raw|inline/
|
|
2793
2778
|
}), inlineRule.test(CSS_REGEX).type("javascript/auto").resourceQuery(/inline/), chain.module.rule(CHAIN_ID.RULE.CSS_RAW).test(CSS_REGEX).type('asset/source').resourceQuery(/raw/);
|
|
2794
2779
|
let emitCss = config.output.emitCss ?? 'web' === target;
|
|
2795
|
-
if (emitCss) {
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
} else rule.use(CHAIN_ID.USE.IGNORE_CSS).loader(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.join(LOADER_PATH, 'ignoreCssLoader.mjs'));
|
|
2780
|
+
if (emitCss) if (config.output.injectStyles) {
|
|
2781
|
+
let styleLoaderOptions = reduceConfigs({
|
|
2782
|
+
initial: {},
|
|
2783
|
+
config: config.tools.styleLoader
|
|
2784
|
+
});
|
|
2785
|
+
rule.use(CHAIN_ID.USE.STYLE).loader(getCompiledPath('style-loader')).options(styleLoaderOptions);
|
|
2786
|
+
} else rule.use(CHAIN_ID.USE.MINI_CSS_EXTRACT).loader(getCssExtractPlugin().loader).options(config.tools.cssExtract.loaderOptions);
|
|
2787
|
+
else rule.use(CHAIN_ID.USE.IGNORE_CSS).loader(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.join(LOADER_PATH, 'ignoreCssLoader.mjs'));
|
|
2804
2788
|
let importLoaders = 0, updateRules = (callback)=>{
|
|
2805
2789
|
callback(rule, 'normal'), callback(inlineRule, 'inline');
|
|
2806
2790
|
}, cssLoaderPath = getCompiledPath('css-loader');
|
|
@@ -2821,7 +2805,7 @@ let isPostcssPluginCreator = (plugin)=>'function' == typeof plugin && !0 === plu
|
|
|
2821
2805
|
root: api.context.rootPath,
|
|
2822
2806
|
postcssrcCache
|
|
2823
2807
|
});
|
|
2824
|
-
if ('function' == typeof postcssLoaderOptions.postcssOptions || (null === (_postcssLoaderOptions_postcssOptions = postcssLoaderOptions.postcssOptions) || void 0 === _postcssLoaderOptions_postcssOptions
|
|
2808
|
+
if ('function' == typeof postcssLoaderOptions.postcssOptions || (null === (_postcssLoaderOptions_postcssOptions = postcssLoaderOptions.postcssOptions) || void 0 === _postcssLoaderOptions_postcssOptions || null === (_postcssLoaderOptions_postcssOptions_plugins = _postcssLoaderOptions_postcssOptions.plugins) || void 0 === _postcssLoaderOptions_postcssOptions_plugins ? void 0 : _postcssLoaderOptions_postcssOptions_plugins.length)) {
|
|
2825
2809
|
importLoaders++;
|
|
2826
2810
|
let postcssLoaderPath = getCompiledPath('postcss-loader');
|
|
2827
2811
|
updateRules((rule)=>{
|
|
@@ -2867,13 +2851,15 @@ let isPostcssPluginCreator = (plugin)=>'function' == typeof plugin && !0 === plu
|
|
|
2867
2851
|
setup (api) {
|
|
2868
2852
|
api.modifyBundlerChain((chain, { CHAIN_ID, bundler, environment })=>{
|
|
2869
2853
|
let { config } = environment, baseUrl = JSON.stringify(config.server.base), assetPrefix = JSON.stringify(getPublicPathFromChain(chain, !1)), mergedDefine = {
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2854
|
+
...{
|
|
2855
|
+
'import.meta.env.MODE': JSON.stringify(config.mode),
|
|
2856
|
+
'import.meta.env.DEV': 'development' === config.mode,
|
|
2857
|
+
'import.meta.env.PROD': 'production' === config.mode,
|
|
2858
|
+
'import.meta.env.BASE_URL': baseUrl,
|
|
2859
|
+
'import.meta.env.ASSET_PREFIX': assetPrefix,
|
|
2860
|
+
'process.env.BASE_URL': baseUrl,
|
|
2861
|
+
'process.env.ASSET_PREFIX': assetPrefix
|
|
2862
|
+
},
|
|
2877
2863
|
...config.source.define
|
|
2878
2864
|
};
|
|
2879
2865
|
!function(define) {
|
|
@@ -3125,8 +3111,7 @@ let VOID_TAGS = [
|
|
|
3125
3111
|
class RsbuildHtmlPlugin {
|
|
3126
3112
|
apply(compiler) {
|
|
3127
3113
|
let emitFavicon = async (compilation, favicon)=>{
|
|
3128
|
-
let buffer;
|
|
3129
|
-
let name = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.basename(favicon);
|
|
3114
|
+
let buffer, name = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.basename(favicon);
|
|
3130
3115
|
if (compilation.assets[name]) return name;
|
|
3131
3116
|
if (!compilation.inputFileSystem) return addCompilationError(compilation, '[rsbuild:html] Failed to read the favicon file as "compilation.inputFileSystem" is not available.'), null;
|
|
3132
3117
|
let filename = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.isAbsolute(favicon) ? favicon : __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.join(compilation.compiler.context, favicon);
|
|
@@ -3238,7 +3223,29 @@ let getTagConfig = (config)=>{
|
|
|
3238
3223
|
ctx: {
|
|
3239
3224
|
entryName: entryName
|
|
3240
3225
|
}
|
|
3241
|
-
}), filename = htmlPaths[entryName], { templatePath, templateContent } = await getTemplate(entryName, config, api.context.rootPath),
|
|
3226
|
+
}), filename = htmlPaths[entryName], { templatePath, templateContent } = await getTemplate(entryName, config, api.context.rootPath), templateParameters = (compilation, assets, assetTags, pluginOptions)=>{
|
|
3227
|
+
let { mountId, templateParameters } = config.html, rspackConfig = compilation.options, htmlPlugin = {
|
|
3228
|
+
tags: assetTags,
|
|
3229
|
+
files: assets,
|
|
3230
|
+
options: pluginOptions
|
|
3231
|
+
};
|
|
3232
|
+
return reduceConfigsWithContext({
|
|
3233
|
+
initial: {
|
|
3234
|
+
mountId,
|
|
3235
|
+
entryName: entryName,
|
|
3236
|
+
assetPrefix: assetPrefix,
|
|
3237
|
+
compilation,
|
|
3238
|
+
htmlPlugin,
|
|
3239
|
+
rspackConfig,
|
|
3240
|
+
webpackConfig: rspackConfig,
|
|
3241
|
+
htmlWebpackPlugin: htmlPlugin
|
|
3242
|
+
},
|
|
3243
|
+
config: templateParameters,
|
|
3244
|
+
ctx: {
|
|
3245
|
+
entryName: entryName
|
|
3246
|
+
}
|
|
3247
|
+
});
|
|
3248
|
+
}, pluginOptions = {
|
|
3242
3249
|
meta: function(entryName, config, templateContent) {
|
|
3243
3250
|
let metaTags = reduceConfigsMergeContext({
|
|
3244
3251
|
initial: {},
|
|
@@ -3253,29 +3260,7 @@ let getTagConfig = (config)=>{
|
|
|
3253
3260
|
inject,
|
|
3254
3261
|
filename,
|
|
3255
3262
|
entryName,
|
|
3256
|
-
templateParameters
|
|
3257
|
-
let { mountId, templateParameters } = config.html, rspackConfig = compilation.options, htmlPlugin = {
|
|
3258
|
-
tags: assetTags,
|
|
3259
|
-
files: assets,
|
|
3260
|
-
options: pluginOptions
|
|
3261
|
-
};
|
|
3262
|
-
return reduceConfigsWithContext({
|
|
3263
|
-
initial: {
|
|
3264
|
-
mountId,
|
|
3265
|
-
entryName: entryName,
|
|
3266
|
-
assetPrefix: assetPrefix,
|
|
3267
|
-
compilation,
|
|
3268
|
-
htmlPlugin,
|
|
3269
|
-
rspackConfig,
|
|
3270
|
-
webpackConfig: rspackConfig,
|
|
3271
|
-
htmlWebpackPlugin: htmlPlugin
|
|
3272
|
-
},
|
|
3273
|
-
config: templateParameters,
|
|
3274
|
-
ctx: {
|
|
3275
|
-
entryName: entryName
|
|
3276
|
-
}
|
|
3277
|
-
});
|
|
3278
|
-
},
|
|
3263
|
+
templateParameters,
|
|
3279
3264
|
scriptLoading: config.html.scriptLoading
|
|
3280
3265
|
};
|
|
3281
3266
|
templatePath && (pluginOptions.template = templatePath), chunks.length > 1 && (pluginOptions.chunksSortMode = 'manual');
|
|
@@ -4154,7 +4139,7 @@ let resourceHints_generateLinks = (options, rel)=>options.map((option)=>({
|
|
|
4154
4139
|
if ('true' !== process.env.RSDOCTOR) return;
|
|
4155
4140
|
let isRspack = 'rspack' === api.context.bundlerType, pluginName = isRspack ? 'RsdoctorRspackPlugin' : 'RsdoctorWebpackPlugin', isRsdoctorPlugin = (plugin)=>{
|
|
4156
4141
|
var _plugin_constructor;
|
|
4157
|
-
return (null == plugin ? void 0 : plugin.isRsdoctorPlugin) === !0 || (null == plugin
|
|
4142
|
+
return (null == plugin ? void 0 : plugin.isRsdoctorPlugin) === !0 || (null == plugin || null === (_plugin_constructor = plugin.constructor) || void 0 === _plugin_constructor ? void 0 : _plugin_constructor.name) === pluginName;
|
|
4158
4143
|
};
|
|
4159
4144
|
for (let config of bundlerConfigs){
|
|
4160
4145
|
var _config_plugins;
|
|
@@ -4371,7 +4356,7 @@ let resourceHints_generateLinks = (options, rel)=>options.map((option)=>({
|
|
|
4371
4356
|
return;
|
|
4372
4357
|
}
|
|
4373
4358
|
let { config } = environment, defaultConfig = {
|
|
4374
|
-
chunks: (null === (_config_moduleFederation = config.moduleFederation) || void 0 === _config_moduleFederation
|
|
4359
|
+
chunks: (null === (_config_moduleFederation = config.moduleFederation) || void 0 === _config_moduleFederation || null === (_config_moduleFederation_options = _config_moduleFederation.options) || void 0 === _config_moduleFederation_options ? void 0 : _config_moduleFederation_options.exposes) ? 'async' : 'all',
|
|
4375
4360
|
cacheGroups: {}
|
|
4376
4361
|
};
|
|
4377
4362
|
'webpack' === api.context.bundlerType && (defaultConfig.enforceSizeThreshold = 50000);
|
|
@@ -4677,15 +4662,14 @@ async function generateRspackConfig({ target, context, environment }) {
|
|
|
4677
4662
|
HotModuleReplacementPlugin
|
|
4678
4663
|
}
|
|
4679
4664
|
})).toConfig();
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
}
|
|
4665
|
+
var config = rspackConfig = await modifyRspackConfig(context, rspackConfig, chainUtils);
|
|
4666
|
+
if (config.plugins) {
|
|
4667
|
+
for (let plugin of config.plugins)if (plugin && void 0 === plugin.apply && 'name' in plugin && 'setup' in plugin) {
|
|
4668
|
+
let name = __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.bold(__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(plugin.name));
|
|
4669
|
+
throw Error(`[rsbuild:plugin] "${name}" appears to be an Rsbuild plugin. It cannot be used as an Rspack plugin.`);
|
|
4686
4670
|
}
|
|
4687
|
-
|
|
4688
|
-
|
|
4671
|
+
}
|
|
4672
|
+
return config.devServer && __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`[rsbuild:config] Find invalid Rspack config: "${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('devServer')}". Note that Rspack's "devServer" config is not supported by Rsbuild. You can use Rsbuild's "dev" config to configure the Rsbuild dev server.`), rspackConfig;
|
|
4689
4673
|
}
|
|
4690
4674
|
async function modifyRsbuildConfig(context) {
|
|
4691
4675
|
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('modify Rsbuild config');
|
|
@@ -4709,8 +4693,7 @@ async function modifyEnvironmentConfig(context, config, name) {
|
|
|
4709
4693
|
return __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug(`modify Rsbuild environment(${name}) config done`), modified;
|
|
4710
4694
|
}
|
|
4711
4695
|
let initEnvironmentConfigs = (normalizedConfig, rootPath, specifiedEnvironments)=>{
|
|
4712
|
-
let defaultEntry
|
|
4713
|
-
let getDefaultEntryWithMemo = ()=>(defaultEntry || (defaultEntry = function(root) {
|
|
4696
|
+
let defaultEntry, getDefaultEntryWithMemo = ()=>(defaultEntry || (defaultEntry = function(root) {
|
|
4714
4697
|
let entryFile = findExists([
|
|
4715
4698
|
'ts',
|
|
4716
4699
|
'js',
|
|
@@ -4783,25 +4766,24 @@ async function initRsbuildConfig({ context, pluginManager }) {
|
|
|
4783
4766
|
server
|
|
4784
4767
|
};
|
|
4785
4768
|
}
|
|
4786
|
-
|
|
4769
|
+
context.normalizedConfig = {
|
|
4787
4770
|
...normalizeBaseConfig,
|
|
4788
4771
|
environments
|
|
4789
|
-
}, await updateEnvironmentContext(context, environments)
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
}(context), validateRsbuildConfig(context.normalizedConfig), context.normalizedConfig;
|
|
4772
|
+
}, await updateEnvironmentContext(context, environments);
|
|
4773
|
+
let distPaths = Object.values(context.environments).map((item)=>item.distPath);
|
|
4774
|
+
return context.distPath = function(paths) {
|
|
4775
|
+
let uniquePaths = [
|
|
4776
|
+
...new Set(paths)
|
|
4777
|
+
];
|
|
4778
|
+
if (1 === uniquePaths.length) return uniquePaths[0];
|
|
4779
|
+
let [first, ...rest] = uniquePaths.map((p)=>p.split(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.sep)), common = [];
|
|
4780
|
+
for(let i = 0; i < first.length; i++){
|
|
4781
|
+
let segment = first[i];
|
|
4782
|
+
if (rest.every((p)=>p[i] === segment)) common.push(segment);
|
|
4783
|
+
else break;
|
|
4784
|
+
}
|
|
4785
|
+
return common.join(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.sep);
|
|
4786
|
+
}(distPaths), validateRsbuildConfig(context.normalizedConfig), context.normalizedConfig;
|
|
4805
4787
|
}
|
|
4806
4788
|
async function initConfigs({ context, pluginManager, rsbuildOptions }) {
|
|
4807
4789
|
let normalizedConfig = await initRsbuildConfig({
|
|
@@ -4988,7 +4970,7 @@ async function watchFilesForRestart({ files, rsbuild, isBuildWatch, watchOptions
|
|
|
4988
4970
|
ignorePermissionErrors: !0,
|
|
4989
4971
|
...watchOptions
|
|
4990
4972
|
}), restarting = !1, onChange = async (filePath)=>{
|
|
4991
|
-
|
|
4973
|
+
restarting || (restarting = !0, (isBuildWatch ? await restartBuild({
|
|
4992
4974
|
filePath
|
|
4993
4975
|
}) : await restartDevServer({
|
|
4994
4976
|
filePath
|
|
@@ -5277,13 +5259,16 @@ class SocketServer {
|
|
|
5277
5259
|
data: {
|
|
5278
5260
|
text: formattedErrors,
|
|
5279
5261
|
html: function(errors, root) {
|
|
5280
|
-
let htmlItems = errors.map((item)=>
|
|
5262
|
+
let htmlItems = errors.map((item)=>{
|
|
5263
|
+
var text;
|
|
5264
|
+
return text = server_ansiHTML(item ? item.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''') : ''), text.replace(/(?:\.\.?[\/\\]|[a-zA-Z]:\\|\/)[^:]*:\d+:\d+/g, (file)=>{
|
|
5281
5265
|
let hasClosingSpan = file.includes('</span>') && !file.includes('<span'), filePath = hasClosingSpan ? file.replace('</span>', '') : file, isAbsolute = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.isAbsolute(filePath), absolutePath = root && !isAbsolute ? __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.join(root, filePath) : filePath, relativePath = root && isAbsolute ? function(base, filepath) {
|
|
5282
5266
|
let relativePath = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.relative)(base, filepath);
|
|
5283
5267
|
return '' === relativePath ? `.${__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.sep}` : relativePath.startsWith('.') ? relativePath : `.${__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.sep}${relativePath}`;
|
|
5284
5268
|
}(root, filePath) : filePath;
|
|
5285
5269
|
return `<a class="file-link" data-file="${absolutePath}">${relativePath}</a>${hasClosingSpan ? '</span>' : ''}`;
|
|
5286
|
-
})
|
|
5270
|
+
});
|
|
5271
|
+
});
|
|
5287
5272
|
return `
|
|
5288
5273
|
<style>
|
|
5289
5274
|
.root {
|
|
@@ -5524,8 +5509,7 @@ let ENCODING_REGEX = /\bgzip\b/, CONTENT_TYPE_REGEX = /text|javascript|\/json|xm
|
|
|
5524
5509
|
let size = res.getHeader('Content-Length');
|
|
5525
5510
|
return void 0 === size || Number(size) > 1024;
|
|
5526
5511
|
}, gzipMiddleware = ({ level = __WEBPACK_EXTERNAL_MODULE_node_zlib_a5bb16fc__.default.constants.Z_BEST_SPEED } = {})=>(req, res, next)=>{
|
|
5527
|
-
let gzip, writeHeadStatus;
|
|
5528
|
-
let accept = req.headers['accept-encoding'], encoding = 'string' == typeof accept && ENCODING_REGEX.test(accept);
|
|
5512
|
+
let gzip, writeHeadStatus, accept = req.headers['accept-encoding'], encoding = 'string' == typeof accept && ENCODING_REGEX.test(accept);
|
|
5529
5513
|
if ('HEAD' === req.method || !encoding) {
|
|
5530
5514
|
next();
|
|
5531
5515
|
return;
|
|
@@ -5725,15 +5709,15 @@ let ENCODING_REGEX = /\bgzip\b/, CONTENT_TYPE_REGEX = /text|javascript|\/json|xm
|
|
|
5725
5709
|
};
|
|
5726
5710
|
}, applyDefaultMiddlewares = async ({ dev, middlewares, server, compilationManager, context, pwd, environments, postCallbacks })=>{
|
|
5727
5711
|
let upgradeEvents = [];
|
|
5728
|
-
if (server.compress && middlewares.push(gzipMiddleware()),
|
|
5729
|
-
let confHeaders = server.headers;
|
|
5730
|
-
if (confHeaders) for (let [key, value] of Object.entries(confHeaders))res.setHeader(key, value);
|
|
5731
|
-
next();
|
|
5732
|
-
}), server.cors) {
|
|
5712
|
+
if (server.compress && middlewares.push(gzipMiddleware()), server.cors) {
|
|
5733
5713
|
let { default: corsMiddleware } = await import("../compiled/cors/index.js");
|
|
5734
5714
|
middlewares.push(corsMiddleware('boolean' == typeof server.cors ? {} : server.cors));
|
|
5735
5715
|
}
|
|
5736
|
-
|
|
5716
|
+
let { headers } = server;
|
|
5717
|
+
if (headers && middlewares.push((_req, res, next)=>{
|
|
5718
|
+
for (let [key, value] of Object.entries(headers))res.setHeader(key, value);
|
|
5719
|
+
next();
|
|
5720
|
+
}), 'dev' === context.action && 'rspack' === context.bundlerType && dev.lazyCompilation && compilationManager) {
|
|
5737
5721
|
let { compiler } = compilationManager;
|
|
5738
5722
|
middlewares.push(__WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.default.experiments.lazyCompilationMiddleware(helpers_isMultiCompiler(compiler) ? compiler.compilers[0] : compiler, dev.lazyCompilation));
|
|
5739
5723
|
}
|
|
@@ -6316,8 +6300,7 @@ async function createCompiler_createCompiler(options) {
|
|
|
6316
6300
|
};
|
|
6317
6301
|
}
|
|
6318
6302
|
let RSPACK_BUILD_ERROR = 'Rspack build failed.', build_build = async (initOptions, { watch, compiler: customCompiler } = {})=>{
|
|
6319
|
-
let compiler, bundlerConfigs;
|
|
6320
|
-
let { context } = initOptions;
|
|
6303
|
+
let compiler, bundlerConfigs, { context } = initOptions;
|
|
6321
6304
|
if (customCompiler) compiler = customCompiler;
|
|
6322
6305
|
else {
|
|
6323
6306
|
let result = await createCompiler_createCompiler(initOptions);
|
|
@@ -6419,14 +6402,14 @@ class RsbuildProdServer {
|
|
|
6419
6402
|
let { headers, proxy, historyApiFallback, compress, base, cors } = this.options.serverConfig;
|
|
6420
6403
|
if ('verbose' === __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.level && this.middlewares.use(await getRequestLoggerMiddleware()), compress && this.middlewares.use(gzipMiddleware({
|
|
6421
6404
|
level: 6
|
|
6422
|
-
})),
|
|
6423
|
-
for (let [key, value] of Object.entries(headers))res.setHeader(key, value);
|
|
6424
|
-
next();
|
|
6425
|
-
}), cors) {
|
|
6405
|
+
})), cors) {
|
|
6426
6406
|
let { default: corsMiddleware } = await import("../compiled/cors/index.js");
|
|
6427
6407
|
this.middlewares.use(corsMiddleware('boolean' == typeof cors ? {} : cors));
|
|
6428
6408
|
}
|
|
6429
|
-
if (
|
|
6409
|
+
if (headers && this.middlewares.use((_req, res, next)=>{
|
|
6410
|
+
for (let [key, value] of Object.entries(headers))res.setHeader(key, value);
|
|
6411
|
+
next();
|
|
6412
|
+
}), proxy) {
|
|
6430
6413
|
let { middlewares, upgrade } = await createProxyMiddleware(proxy);
|
|
6431
6414
|
for (let middleware of middlewares)this.middlewares.use(middleware);
|
|
6432
6415
|
this.app.on('upgrade', upgrade);
|
|
@@ -6602,13 +6585,13 @@ async function applyDefaultPlugins(pluginManager, context) {
|
|
|
6602
6585
|
setup (api) {
|
|
6603
6586
|
'webpack' !== api.context.bundlerType && (api.modifyRsbuildConfig((config)=>{
|
|
6604
6587
|
let { moduleFederation } = config;
|
|
6605
|
-
if (api.isPluginExists('rsbuild:module-federation-enhanced') && (config.server ||= {}, config.server.cors
|
|
6588
|
+
if (api.isPluginExists('rsbuild:module-federation-enhanced') && (config.server ||= {}, config.server.cors = !0), (null == moduleFederation ? void 0 : moduleFederation.options) && moduleFederation.options.exposes) {
|
|
6606
6589
|
var _config_server, _config_dev_client, _originalConfig_dev, _config_server1;
|
|
6607
|
-
config.dev ||= {}, config.server ||= {}, config.server.cors
|
|
6590
|
+
config.dev ||= {}, config.server ||= {}, config.server.cors = !0, (null === (_config_server = config.server) || void 0 === _config_server ? void 0 : _config_server.port) && !(null === (_config_dev_client = config.dev.client) || void 0 === _config_dev_client ? void 0 : _config_dev_client.port) && (config.dev.client ||= {}, config.dev.client.port = config.server.port), (null === (_originalConfig_dev = api.getRsbuildConfig('original').dev) || void 0 === _originalConfig_dev ? void 0 : _originalConfig_dev.assetPrefix) === void 0 && config.dev.assetPrefix === (null === (_config_server1 = config.server) || void 0 === _config_server1 ? void 0 : _config_server1.base) && (config.dev.assetPrefix = !0);
|
|
6608
6591
|
}
|
|
6609
6592
|
}), api.modifyEnvironmentConfig((config)=>{
|
|
6610
6593
|
var _config_moduleFederation, _config_performance_chunkSplit, _config_performance;
|
|
6611
|
-
(null === (_config_moduleFederation = config.moduleFederation) || void 0 === _config_moduleFederation ? void 0 : _config_moduleFederation.options) && ((null === (_config_performance = config.performance) || void 0 === _config_performance
|
|
6594
|
+
(null === (_config_moduleFederation = config.moduleFederation) || void 0 === _config_moduleFederation ? void 0 : _config_moduleFederation.options) && ((null === (_config_performance = config.performance) || void 0 === _config_performance || null === (_config_performance_chunkSplit = _config_performance.chunkSplit) || void 0 === _config_performance_chunkSplit ? void 0 : _config_performance_chunkSplit.strategy) === 'split-by-experience' && (config.performance.chunkSplit = {
|
|
6612
6595
|
...config.performance.chunkSplit,
|
|
6613
6596
|
strategy: 'custom'
|
|
6614
6597
|
}), config.source.include = [
|
|
@@ -6634,31 +6617,26 @@ async function applyDefaultPlugins(pluginManager, context) {
|
|
|
6634
6617
|
]);
|
|
6635
6618
|
}
|
|
6636
6619
|
async function createRsbuild(options = {}) {
|
|
6637
|
-
let plugins
|
|
6638
|
-
let envs = options.loadEnv ? loadEnv({
|
|
6620
|
+
let plugins, envs = options.loadEnv ? loadEnv({
|
|
6639
6621
|
cwd: options.cwd,
|
|
6640
6622
|
...'boolean' == typeof options.loadEnv ? {} : options.loadEnv
|
|
6641
6623
|
}) : null, config = isFunction(options.rsbuildConfig) ? await options.rsbuildConfig() : options.rsbuildConfig || {};
|
|
6642
|
-
|
|
6643
|
-
|
|
6644
|
-
|
|
6645
|
-
|
|
6646
|
-
|
|
6647
|
-
|
|
6648
|
-
|
|
6649
|
-
|
|
6650
|
-
|
|
6651
|
-
paths: envs.filePaths,
|
|
6652
|
-
type: 'reload-server'
|
|
6653
|
-
}
|
|
6654
|
-
], null === (_config_performance = config.performance) || void 0 === _config_performance ? void 0 : _config_performance.buildCache)) {
|
|
6655
|
-
let { buildCache } = config.performance;
|
|
6656
|
-
!0 === buildCache ? config.performance.buildCache = {
|
|
6657
|
-
buildDependencies: envs.filePaths
|
|
6658
|
-
} : (buildCache.buildDependencies ||= [], buildCache.buildDependencies.push(...envs.filePaths));
|
|
6659
|
-
}
|
|
6624
|
+
var _config_performance, config1 = config, envs1 = envs;
|
|
6625
|
+
if (null !== envs1 && (config1.source ||= {}, config1.source.define = {
|
|
6626
|
+
...envs1.publicVars,
|
|
6627
|
+
...config1.source.define
|
|
6628
|
+
}, 0 !== envs1.filePaths.length && (config1.dev ||= {}, config1.dev.watchFiles = [
|
|
6629
|
+
...config1.dev.watchFiles ? castArray(config1.dev.watchFiles) : [],
|
|
6630
|
+
{
|
|
6631
|
+
paths: envs1.filePaths,
|
|
6632
|
+
type: 'reload-server'
|
|
6660
6633
|
}
|
|
6661
|
-
|
|
6634
|
+
], null === (_config_performance = config1.performance) || void 0 === _config_performance ? void 0 : _config_performance.buildCache))) {
|
|
6635
|
+
let { buildCache } = config1.performance;
|
|
6636
|
+
!0 === buildCache ? config1.performance.buildCache = {
|
|
6637
|
+
buildDependencies: envs1.filePaths
|
|
6638
|
+
} : (buildCache.buildDependencies ||= [], buildCache.buildDependencies.push(...envs1.filePaths));
|
|
6639
|
+
}
|
|
6662
6640
|
let resolvedOptions = {
|
|
6663
6641
|
cwd: process.cwd(),
|
|
6664
6642
|
...options,
|
|
@@ -6671,15 +6649,14 @@ async function createRsbuild(options = {}) {
|
|
|
6671
6649
|
addPlugins: (newPlugins, options)=>{
|
|
6672
6650
|
let { before, environment = RSBUILD_ALL_ENVIRONMENT_SYMBOL } = options || {};
|
|
6673
6651
|
for (let newPlugin of newPlugins)if (newPlugin) {
|
|
6674
|
-
|
|
6675
|
-
|
|
6676
|
-
|
|
6677
|
-
if (
|
|
6678
|
-
|
|
6679
|
-
|
|
6680
|
-
|
|
6681
|
-
|
|
6682
|
-
__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.green(`
|
|
6652
|
+
let type = typeof newPlugin;
|
|
6653
|
+
if ('object' !== type || null === newPlugin) throw Error(`[rsbuild:plugin] Expect Rsbuild plugin instance to be an object, but got ${type}.`);
|
|
6654
|
+
if (!isFunction(newPlugin.setup)) {
|
|
6655
|
+
if (isFunction(newPlugin.apply)) {
|
|
6656
|
+
let { name = 'SomeWebpackPlugin' } = newPlugin.constructor || {};
|
|
6657
|
+
throw Error([
|
|
6658
|
+
`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(name)} looks like a webpack or Rspack plugin, please use ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('`tools.rspack`')} to register it:`,
|
|
6659
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.green(`
|
|
6683
6660
|
// rsbuild.config.ts
|
|
6684
6661
|
export default {
|
|
6685
6662
|
tools: {
|
|
@@ -6689,11 +6666,11 @@ async function createRsbuild(options = {}) {
|
|
|
6689
6666
|
}
|
|
6690
6667
|
};
|
|
6691
6668
|
`)
|
|
6692
|
-
|
|
6693
|
-
}
|
|
6694
|
-
throw Error(`[rsbuild:plugin] Expect the setup function of Rsbuild plugin to be a function, but got ${type}.`);
|
|
6669
|
+
].join('\n'));
|
|
6695
6670
|
}
|
|
6696
|
-
|
|
6671
|
+
throw Error(`[rsbuild:plugin] Expect the setup function of Rsbuild plugin to be a function, but got ${type}.`);
|
|
6672
|
+
}
|
|
6673
|
+
if (before) {
|
|
6697
6674
|
let index = plugins.findIndex((item)=>item.instance.name === before);
|
|
6698
6675
|
-1 === index ? (__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`Plugin "${before}" does not exist.`), plugins.push({
|
|
6699
6676
|
environment,
|
|
@@ -6983,8 +6960,7 @@ function toArr(any) {
|
|
|
6983
6960
|
];
|
|
6984
6961
|
}
|
|
6985
6962
|
let removeBrackets = (v)=>v.replace(/[<[].+/, "").trim(), findAllBrackets = (v)=>{
|
|
6986
|
-
let angledMatch, squareMatch
|
|
6987
|
-
let ANGLED_BRACKET_RE_GLOBAL = /<([^>]+)>/g, SQUARE_BRACKET_RE_GLOBAL = /\[([^\]]+)\]/g, res = [], parse = (match)=>{
|
|
6963
|
+
let angledMatch, squareMatch, ANGLED_BRACKET_RE_GLOBAL = /<([^>]+)>/g, SQUARE_BRACKET_RE_GLOBAL = /\[([^\]]+)\]/g, res = [], parse = (match)=>{
|
|
6988
6964
|
let variadic = !1, value = match[1];
|
|
6989
6965
|
return value.startsWith("...") && (value = value.slice(3), variadic = !0), {
|
|
6990
6966
|
required: match[0].startsWith("<"),
|
|
@@ -7293,21 +7269,20 @@ let cac_dist = (name = "")=>new CAC(name), applyCommonOptions = (cli)=>{
|
|
|
7293
7269
|
command.option('-o, --open [url]', 'open the page in browser on startup').option('--port <port>', 'specify a port number for server to listen').option('--host <host>', 'specify the host that the server listens to');
|
|
7294
7270
|
};
|
|
7295
7271
|
async function runCLI() {
|
|
7296
|
-
!
|
|
7297
|
-
|
|
7298
|
-
|
|
7299
|
-
|
|
7300
|
-
|
|
7301
|
-
|
|
7302
|
-
|
|
7303
|
-
|
|
7304
|
-
}(), process.title = 'rsbuild-node';
|
|
7272
|
+
if (!process.env.NODE_ENV) {
|
|
7273
|
+
let command = process.argv[2];
|
|
7274
|
+
process.env.NODE_ENV = [
|
|
7275
|
+
'build',
|
|
7276
|
+
'preview'
|
|
7277
|
+
].includes(command) ? 'production' : 'development';
|
|
7278
|
+
}
|
|
7279
|
+
process.title = 'rsbuild-node';
|
|
7305
7280
|
let { npm_execpath } = process.env;
|
|
7306
|
-
(!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.greet(` Rsbuild v1.3.0
|
|
7281
|
+
(!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.greet(` Rsbuild v1.3.0\n`);
|
|
7307
7282
|
try {
|
|
7308
7283
|
!function() {
|
|
7309
7284
|
let cli = cac_dist('rsbuild');
|
|
7310
|
-
cli.help(), cli.version("1.3.0
|
|
7285
|
+
cli.help(), cli.version("1.3.0"), applyCommonOptions(cli);
|
|
7311
7286
|
let devCommand = cli.command('', 'starting the dev server').alias('dev'), buildCommand = cli.command('build', 'build the app for production'), previewCommand = cli.command('preview', 'preview the production build locally'), inspectCommand = cli.command('inspect', 'inspect the Rspack and Rsbuild configs');
|
|
7312
7287
|
applyServerOptions(devCommand), applyServerOptions(previewCommand), devCommand.action(async (options)=>{
|
|
7313
7288
|
try {
|
|
@@ -7358,6 +7333,6 @@ async function runCLI() {
|
|
|
7358
7333
|
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error('Failed to start Rsbuild CLI.'), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(err);
|
|
7359
7334
|
}
|
|
7360
7335
|
}
|
|
7361
|
-
let src_version = "1.3.0
|
|
7336
|
+
let src_version = "1.3.0";
|
|
7362
7337
|
var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger, __webpack_exports__rspack = __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack;
|
|
7363
7338
|
export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, createRsbuild, defineConfig, ensureAssetPrefix, config_loadConfig as loadConfig, loadEnv, mergeRsbuildConfig, runCLI, src_version as version, __webpack_exports__logger as logger, __webpack_exports__rspack as rspack };
|