@rsbuild/core 1.3.0-beta.3 → 1.3.1
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 +266 -284
- package/dist/index.js +194 -215
- 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 +4 -4
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
|
|
@@ -1646,7 +1634,11 @@ async function config_loadConfig({ cwd = process.cwd(), path, envMode, meta, loa
|
|
|
1646
1634
|
if (void 0 === configExport) {
|
|
1647
1635
|
let { createJiti } = await import("jiti"), jiti = createJiti(constants_filename, {
|
|
1648
1636
|
moduleCache: !1,
|
|
1649
|
-
interopDefault: !0
|
|
1637
|
+
interopDefault: !0,
|
|
1638
|
+
nativeModules: [
|
|
1639
|
+
'@rspack/core',
|
|
1640
|
+
"typescript"
|
|
1641
|
+
]
|
|
1650
1642
|
});
|
|
1651
1643
|
configExport = await jiti.import(configFilePath, {
|
|
1652
1644
|
default: !0
|
|
@@ -1880,8 +1872,7 @@ function createAsyncHook() {
|
|
|
1880
1872
|
let onBeforeCompile = ({ compiler, beforeCompile, beforeEnvironmentCompiler, isWatch })=>{
|
|
1881
1873
|
let name = 'rsbuild:beforeCompile';
|
|
1882
1874
|
if (helpers_isMultiCompiler(compiler)) {
|
|
1883
|
-
let waitBeforeCompileDone;
|
|
1884
|
-
let { compilers } = compiler, doneCompilers = 0;
|
|
1875
|
+
let waitBeforeCompileDone, { compilers } = compiler, doneCompilers = 0;
|
|
1885
1876
|
for(let index = 0; index < compilers.length; index++){
|
|
1886
1877
|
let compiler = compilers[index], compilerDone = !1;
|
|
1887
1878
|
(isWatch ? compiler.hooks.watchRun : compiler.hooks.run).tapPromise(name, async ()=>{
|
|
@@ -2044,12 +2035,10 @@ async function getBrowserslist(path) {
|
|
|
2044
2035
|
if (opts.config) return pickEnv(parsePackageOrReadConfig(opts.config), opts);
|
|
2045
2036
|
if (opts.path) {
|
|
2046
2037
|
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;
|
|
2038
|
+
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
2039
|
if (fromDir in configCache) return configCache[fromDir];
|
|
2050
2040
|
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');
|
|
2041
|
+
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
2042
|
if (isFile(pkg)) try {
|
|
2054
2043
|
pkgBrowserslist = parsePackage(pkg);
|
|
2055
2044
|
} catch (e) {
|
|
@@ -2101,7 +2090,7 @@ async function updateEnvironmentContext(context, configs) {
|
|
|
2101
2090
|
name,
|
|
2102
2091
|
distPath: function(cwd, config) {
|
|
2103
2092
|
var _config_output_distPath, _config_output;
|
|
2104
|
-
return getAbsolutePath(cwd, (null === (_config_output = config.output) || void 0 === _config_output
|
|
2093
|
+
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
2094
|
}(context.rootPath, config),
|
|
2106
2095
|
entry,
|
|
2107
2096
|
browserslist,
|
|
@@ -2118,7 +2107,7 @@ async function updateEnvironmentContext(context, configs) {
|
|
|
2118
2107
|
async function createContext(options, userConfig) {
|
|
2119
2108
|
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
2109
|
return {
|
|
2121
|
-
version: "1.3.
|
|
2110
|
+
version: "1.3.1",
|
|
2122
2111
|
rootPath,
|
|
2123
2112
|
distPath: '',
|
|
2124
2113
|
cachePath,
|
|
@@ -2556,7 +2545,7 @@ let pluginCache = ()=>({
|
|
|
2556
2545
|
return 'auto' === enable ? isDev && !config.dev.writeToDisk ? void 0 : isStrictSubdir(rootPath, distPath) ? {
|
|
2557
2546
|
path: distPath,
|
|
2558
2547
|
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)}`),
|
|
2548
|
+
} : 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
2549
|
path: distPath,
|
|
2561
2550
|
keep
|
|
2562
2551
|
} : void 0;
|
|
@@ -2792,15 +2781,14 @@ let isPostcssPluginCreator = (plugin)=>'function' == typeof plugin && !0 === plu
|
|
|
2792
2781
|
not: /raw|inline/
|
|
2793
2782
|
}), 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
2783
|
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'));
|
|
2784
|
+
if (emitCss) if (config.output.injectStyles) {
|
|
2785
|
+
let styleLoaderOptions = reduceConfigs({
|
|
2786
|
+
initial: {},
|
|
2787
|
+
config: config.tools.styleLoader
|
|
2788
|
+
});
|
|
2789
|
+
rule.use(CHAIN_ID.USE.STYLE).loader(getCompiledPath('style-loader')).options(styleLoaderOptions);
|
|
2790
|
+
} else rule.use(CHAIN_ID.USE.MINI_CSS_EXTRACT).loader(getCssExtractPlugin().loader).options(config.tools.cssExtract.loaderOptions);
|
|
2791
|
+
else rule.use(CHAIN_ID.USE.IGNORE_CSS).loader(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.join(LOADER_PATH, 'ignoreCssLoader.mjs'));
|
|
2804
2792
|
let importLoaders = 0, updateRules = (callback)=>{
|
|
2805
2793
|
callback(rule, 'normal'), callback(inlineRule, 'inline');
|
|
2806
2794
|
}, cssLoaderPath = getCompiledPath('css-loader');
|
|
@@ -2821,7 +2809,7 @@ let isPostcssPluginCreator = (plugin)=>'function' == typeof plugin && !0 === plu
|
|
|
2821
2809
|
root: api.context.rootPath,
|
|
2822
2810
|
postcssrcCache
|
|
2823
2811
|
});
|
|
2824
|
-
if ('function' == typeof postcssLoaderOptions.postcssOptions || (null === (_postcssLoaderOptions_postcssOptions = postcssLoaderOptions.postcssOptions) || void 0 === _postcssLoaderOptions_postcssOptions
|
|
2812
|
+
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
2813
|
importLoaders++;
|
|
2826
2814
|
let postcssLoaderPath = getCompiledPath('postcss-loader');
|
|
2827
2815
|
updateRules((rule)=>{
|
|
@@ -2867,13 +2855,15 @@ let isPostcssPluginCreator = (plugin)=>'function' == typeof plugin && !0 === plu
|
|
|
2867
2855
|
setup (api) {
|
|
2868
2856
|
api.modifyBundlerChain((chain, { CHAIN_ID, bundler, environment })=>{
|
|
2869
2857
|
let { config } = environment, baseUrl = JSON.stringify(config.server.base), assetPrefix = JSON.stringify(getPublicPathFromChain(chain, !1)), mergedDefine = {
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2858
|
+
...{
|
|
2859
|
+
'import.meta.env.MODE': JSON.stringify(config.mode),
|
|
2860
|
+
'import.meta.env.DEV': 'development' === config.mode,
|
|
2861
|
+
'import.meta.env.PROD': 'production' === config.mode,
|
|
2862
|
+
'import.meta.env.BASE_URL': baseUrl,
|
|
2863
|
+
'import.meta.env.ASSET_PREFIX': assetPrefix,
|
|
2864
|
+
'process.env.BASE_URL': baseUrl,
|
|
2865
|
+
'process.env.ASSET_PREFIX': assetPrefix
|
|
2866
|
+
},
|
|
2877
2867
|
...config.source.define
|
|
2878
2868
|
};
|
|
2879
2869
|
!function(define) {
|
|
@@ -3125,8 +3115,7 @@ let VOID_TAGS = [
|
|
|
3125
3115
|
class RsbuildHtmlPlugin {
|
|
3126
3116
|
apply(compiler) {
|
|
3127
3117
|
let emitFavicon = async (compilation, favicon)=>{
|
|
3128
|
-
let buffer;
|
|
3129
|
-
let name = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.basename(favicon);
|
|
3118
|
+
let buffer, name = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.basename(favicon);
|
|
3130
3119
|
if (compilation.assets[name]) return name;
|
|
3131
3120
|
if (!compilation.inputFileSystem) return addCompilationError(compilation, '[rsbuild:html] Failed to read the favicon file as "compilation.inputFileSystem" is not available.'), null;
|
|
3132
3121
|
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 +3227,29 @@ let getTagConfig = (config)=>{
|
|
|
3238
3227
|
ctx: {
|
|
3239
3228
|
entryName: entryName
|
|
3240
3229
|
}
|
|
3241
|
-
}), filename = htmlPaths[entryName], { templatePath, templateContent } = await getTemplate(entryName, config, api.context.rootPath),
|
|
3230
|
+
}), filename = htmlPaths[entryName], { templatePath, templateContent } = await getTemplate(entryName, config, api.context.rootPath), templateParameters = (compilation, assets, assetTags, pluginOptions)=>{
|
|
3231
|
+
let { mountId, templateParameters } = config.html, rspackConfig = compilation.options, htmlPlugin = {
|
|
3232
|
+
tags: assetTags,
|
|
3233
|
+
files: assets,
|
|
3234
|
+
options: pluginOptions
|
|
3235
|
+
};
|
|
3236
|
+
return reduceConfigsWithContext({
|
|
3237
|
+
initial: {
|
|
3238
|
+
mountId,
|
|
3239
|
+
entryName: entryName,
|
|
3240
|
+
assetPrefix: assetPrefix,
|
|
3241
|
+
compilation,
|
|
3242
|
+
htmlPlugin,
|
|
3243
|
+
rspackConfig,
|
|
3244
|
+
webpackConfig: rspackConfig,
|
|
3245
|
+
htmlWebpackPlugin: htmlPlugin
|
|
3246
|
+
},
|
|
3247
|
+
config: templateParameters,
|
|
3248
|
+
ctx: {
|
|
3249
|
+
entryName: entryName
|
|
3250
|
+
}
|
|
3251
|
+
});
|
|
3252
|
+
}, pluginOptions = {
|
|
3242
3253
|
meta: function(entryName, config, templateContent) {
|
|
3243
3254
|
let metaTags = reduceConfigsMergeContext({
|
|
3244
3255
|
initial: {},
|
|
@@ -3253,29 +3264,7 @@ let getTagConfig = (config)=>{
|
|
|
3253
3264
|
inject,
|
|
3254
3265
|
filename,
|
|
3255
3266
|
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
|
-
},
|
|
3267
|
+
templateParameters,
|
|
3279
3268
|
scriptLoading: config.html.scriptLoading
|
|
3280
3269
|
};
|
|
3281
3270
|
templatePath && (pluginOptions.template = templatePath), chunks.length > 1 && (pluginOptions.chunksSortMode = 'manual');
|
|
@@ -4154,7 +4143,7 @@ let resourceHints_generateLinks = (options, rel)=>options.map((option)=>({
|
|
|
4154
4143
|
if ('true' !== process.env.RSDOCTOR) return;
|
|
4155
4144
|
let isRspack = 'rspack' === api.context.bundlerType, pluginName = isRspack ? 'RsdoctorRspackPlugin' : 'RsdoctorWebpackPlugin', isRsdoctorPlugin = (plugin)=>{
|
|
4156
4145
|
var _plugin_constructor;
|
|
4157
|
-
return (null == plugin ? void 0 : plugin.isRsdoctorPlugin) === !0 || (null == plugin
|
|
4146
|
+
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
4147
|
};
|
|
4159
4148
|
for (let config of bundlerConfigs){
|
|
4160
4149
|
var _config_plugins;
|
|
@@ -4371,7 +4360,7 @@ let resourceHints_generateLinks = (options, rel)=>options.map((option)=>({
|
|
|
4371
4360
|
return;
|
|
4372
4361
|
}
|
|
4373
4362
|
let { config } = environment, defaultConfig = {
|
|
4374
|
-
chunks: (null === (_config_moduleFederation = config.moduleFederation) || void 0 === _config_moduleFederation
|
|
4363
|
+
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
4364
|
cacheGroups: {}
|
|
4376
4365
|
};
|
|
4377
4366
|
'webpack' === api.context.bundlerType && (defaultConfig.enforceSizeThreshold = 50000);
|
|
@@ -4677,15 +4666,14 @@ async function generateRspackConfig({ target, context, environment }) {
|
|
|
4677
4666
|
HotModuleReplacementPlugin
|
|
4678
4667
|
}
|
|
4679
4668
|
})).toConfig();
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
}
|
|
4669
|
+
var config = rspackConfig = await modifyRspackConfig(context, rspackConfig, chainUtils);
|
|
4670
|
+
if (config.plugins) {
|
|
4671
|
+
for (let plugin of config.plugins)if (plugin && void 0 === plugin.apply && 'name' in plugin && 'setup' in plugin) {
|
|
4672
|
+
let name = __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.bold(__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(plugin.name));
|
|
4673
|
+
throw Error(`[rsbuild:plugin] "${name}" appears to be an Rsbuild plugin. It cannot be used as an Rspack plugin.`);
|
|
4686
4674
|
}
|
|
4687
|
-
|
|
4688
|
-
|
|
4675
|
+
}
|
|
4676
|
+
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
4677
|
}
|
|
4690
4678
|
async function modifyRsbuildConfig(context) {
|
|
4691
4679
|
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('modify Rsbuild config');
|
|
@@ -4709,8 +4697,7 @@ async function modifyEnvironmentConfig(context, config, name) {
|
|
|
4709
4697
|
return __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug(`modify Rsbuild environment(${name}) config done`), modified;
|
|
4710
4698
|
}
|
|
4711
4699
|
let initEnvironmentConfigs = (normalizedConfig, rootPath, specifiedEnvironments)=>{
|
|
4712
|
-
let defaultEntry
|
|
4713
|
-
let getDefaultEntryWithMemo = ()=>(defaultEntry || (defaultEntry = function(root) {
|
|
4700
|
+
let defaultEntry, getDefaultEntryWithMemo = ()=>(defaultEntry || (defaultEntry = function(root) {
|
|
4714
4701
|
let entryFile = findExists([
|
|
4715
4702
|
'ts',
|
|
4716
4703
|
'js',
|
|
@@ -4783,25 +4770,24 @@ async function initRsbuildConfig({ context, pluginManager }) {
|
|
|
4783
4770
|
server
|
|
4784
4771
|
};
|
|
4785
4772
|
}
|
|
4786
|
-
|
|
4773
|
+
context.normalizedConfig = {
|
|
4787
4774
|
...normalizeBaseConfig,
|
|
4788
4775
|
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;
|
|
4776
|
+
}, await updateEnvironmentContext(context, environments);
|
|
4777
|
+
let distPaths = Object.values(context.environments).map((item)=>item.distPath);
|
|
4778
|
+
return context.distPath = function(paths) {
|
|
4779
|
+
let uniquePaths = [
|
|
4780
|
+
...new Set(paths)
|
|
4781
|
+
];
|
|
4782
|
+
if (1 === uniquePaths.length) return uniquePaths[0];
|
|
4783
|
+
let [first, ...rest] = uniquePaths.map((p)=>p.split(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.sep)), common = [];
|
|
4784
|
+
for(let i = 0; i < first.length; i++){
|
|
4785
|
+
let segment = first[i];
|
|
4786
|
+
if (rest.every((p)=>p[i] === segment)) common.push(segment);
|
|
4787
|
+
else break;
|
|
4788
|
+
}
|
|
4789
|
+
return common.join(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.sep);
|
|
4790
|
+
}(distPaths), validateRsbuildConfig(context.normalizedConfig), context.normalizedConfig;
|
|
4805
4791
|
}
|
|
4806
4792
|
async function initConfigs({ context, pluginManager, rsbuildOptions }) {
|
|
4807
4793
|
let normalizedConfig = await initRsbuildConfig({
|
|
@@ -4988,7 +4974,7 @@ async function watchFilesForRestart({ files, rsbuild, isBuildWatch, watchOptions
|
|
|
4988
4974
|
ignorePermissionErrors: !0,
|
|
4989
4975
|
...watchOptions
|
|
4990
4976
|
}), restarting = !1, onChange = async (filePath)=>{
|
|
4991
|
-
|
|
4977
|
+
restarting || (restarting = !0, (isBuildWatch ? await restartBuild({
|
|
4992
4978
|
filePath
|
|
4993
4979
|
}) : await restartDevServer({
|
|
4994
4980
|
filePath
|
|
@@ -5277,13 +5263,16 @@ class SocketServer {
|
|
|
5277
5263
|
data: {
|
|
5278
5264
|
text: formattedErrors,
|
|
5279
5265
|
html: function(errors, root) {
|
|
5280
|
-
let htmlItems = errors.map((item)=>
|
|
5266
|
+
let htmlItems = errors.map((item)=>{
|
|
5267
|
+
var text;
|
|
5268
|
+
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
5269
|
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
5270
|
let relativePath = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.relative)(base, filepath);
|
|
5283
5271
|
return '' === relativePath ? `.${__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.sep}` : relativePath.startsWith('.') ? relativePath : `.${__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.sep}${relativePath}`;
|
|
5284
5272
|
}(root, filePath) : filePath;
|
|
5285
5273
|
return `<a class="file-link" data-file="${absolutePath}">${relativePath}</a>${hasClosingSpan ? '</span>' : ''}`;
|
|
5286
|
-
})
|
|
5274
|
+
});
|
|
5275
|
+
});
|
|
5287
5276
|
return `
|
|
5288
5277
|
<style>
|
|
5289
5278
|
.root {
|
|
@@ -5524,8 +5513,7 @@ let ENCODING_REGEX = /\bgzip\b/, CONTENT_TYPE_REGEX = /text|javascript|\/json|xm
|
|
|
5524
5513
|
let size = res.getHeader('Content-Length');
|
|
5525
5514
|
return void 0 === size || Number(size) > 1024;
|
|
5526
5515
|
}, 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);
|
|
5516
|
+
let gzip, writeHeadStatus, accept = req.headers['accept-encoding'], encoding = 'string' == typeof accept && ENCODING_REGEX.test(accept);
|
|
5529
5517
|
if ('HEAD' === req.method || !encoding) {
|
|
5530
5518
|
next();
|
|
5531
5519
|
return;
|
|
@@ -5725,15 +5713,15 @@ let ENCODING_REGEX = /\bgzip\b/, CONTENT_TYPE_REGEX = /text|javascript|\/json|xm
|
|
|
5725
5713
|
};
|
|
5726
5714
|
}, applyDefaultMiddlewares = async ({ dev, middlewares, server, compilationManager, context, pwd, environments, postCallbacks })=>{
|
|
5727
5715
|
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) {
|
|
5716
|
+
if (server.compress && middlewares.push(gzipMiddleware()), server.cors) {
|
|
5733
5717
|
let { default: corsMiddleware } = await import("../compiled/cors/index.js");
|
|
5734
5718
|
middlewares.push(corsMiddleware('boolean' == typeof server.cors ? {} : server.cors));
|
|
5735
5719
|
}
|
|
5736
|
-
|
|
5720
|
+
let { headers } = server;
|
|
5721
|
+
if (headers && middlewares.push((_req, res, next)=>{
|
|
5722
|
+
for (let [key, value] of Object.entries(headers))res.setHeader(key, value);
|
|
5723
|
+
next();
|
|
5724
|
+
}), 'dev' === context.action && 'rspack' === context.bundlerType && dev.lazyCompilation && compilationManager) {
|
|
5737
5725
|
let { compiler } = compilationManager;
|
|
5738
5726
|
middlewares.push(__WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.default.experiments.lazyCompilationMiddleware(helpers_isMultiCompiler(compiler) ? compiler.compilers[0] : compiler, dev.lazyCompilation));
|
|
5739
5727
|
}
|
|
@@ -6316,8 +6304,7 @@ async function createCompiler_createCompiler(options) {
|
|
|
6316
6304
|
};
|
|
6317
6305
|
}
|
|
6318
6306
|
let RSPACK_BUILD_ERROR = 'Rspack build failed.', build_build = async (initOptions, { watch, compiler: customCompiler } = {})=>{
|
|
6319
|
-
let compiler, bundlerConfigs;
|
|
6320
|
-
let { context } = initOptions;
|
|
6307
|
+
let compiler, bundlerConfigs, { context } = initOptions;
|
|
6321
6308
|
if (customCompiler) compiler = customCompiler;
|
|
6322
6309
|
else {
|
|
6323
6310
|
let result = await createCompiler_createCompiler(initOptions);
|
|
@@ -6419,14 +6406,14 @@ class RsbuildProdServer {
|
|
|
6419
6406
|
let { headers, proxy, historyApiFallback, compress, base, cors } = this.options.serverConfig;
|
|
6420
6407
|
if ('verbose' === __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.level && this.middlewares.use(await getRequestLoggerMiddleware()), compress && this.middlewares.use(gzipMiddleware({
|
|
6421
6408
|
level: 6
|
|
6422
|
-
})),
|
|
6423
|
-
for (let [key, value] of Object.entries(headers))res.setHeader(key, value);
|
|
6424
|
-
next();
|
|
6425
|
-
}), cors) {
|
|
6409
|
+
})), cors) {
|
|
6426
6410
|
let { default: corsMiddleware } = await import("../compiled/cors/index.js");
|
|
6427
6411
|
this.middlewares.use(corsMiddleware('boolean' == typeof cors ? {} : cors));
|
|
6428
6412
|
}
|
|
6429
|
-
if (
|
|
6413
|
+
if (headers && this.middlewares.use((_req, res, next)=>{
|
|
6414
|
+
for (let [key, value] of Object.entries(headers))res.setHeader(key, value);
|
|
6415
|
+
next();
|
|
6416
|
+
}), proxy) {
|
|
6430
6417
|
let { middlewares, upgrade } = await createProxyMiddleware(proxy);
|
|
6431
6418
|
for (let middleware of middlewares)this.middlewares.use(middleware);
|
|
6432
6419
|
this.app.on('upgrade', upgrade);
|
|
@@ -6602,13 +6589,13 @@ async function applyDefaultPlugins(pluginManager, context) {
|
|
|
6602
6589
|
setup (api) {
|
|
6603
6590
|
'webpack' !== api.context.bundlerType && (api.modifyRsbuildConfig((config)=>{
|
|
6604
6591
|
let { moduleFederation } = config;
|
|
6605
|
-
if (api.isPluginExists('rsbuild:module-federation-enhanced') && (config.server ||= {}, config.server.cors
|
|
6592
|
+
if (api.isPluginExists('rsbuild:module-federation-enhanced') && (config.server ||= {}, config.server.cors = !0), (null == moduleFederation ? void 0 : moduleFederation.options) && moduleFederation.options.exposes) {
|
|
6606
6593
|
var _config_server, _config_dev_client, _originalConfig_dev, _config_server1;
|
|
6607
|
-
config.dev ||= {}, config.server ||= {}, config.server.cors
|
|
6594
|
+
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
6595
|
}
|
|
6609
6596
|
}), api.modifyEnvironmentConfig((config)=>{
|
|
6610
6597
|
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
|
|
6598
|
+
(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
6599
|
...config.performance.chunkSplit,
|
|
6613
6600
|
strategy: 'custom'
|
|
6614
6601
|
}), config.source.include = [
|
|
@@ -6634,31 +6621,26 @@ async function applyDefaultPlugins(pluginManager, context) {
|
|
|
6634
6621
|
]);
|
|
6635
6622
|
}
|
|
6636
6623
|
async function createRsbuild(options = {}) {
|
|
6637
|
-
let plugins
|
|
6638
|
-
let envs = options.loadEnv ? loadEnv({
|
|
6624
|
+
let plugins, envs = options.loadEnv ? loadEnv({
|
|
6639
6625
|
cwd: options.cwd,
|
|
6640
6626
|
...'boolean' == typeof options.loadEnv ? {} : options.loadEnv
|
|
6641
6627
|
}) : 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
|
-
}
|
|
6628
|
+
var _config_performance, config1 = config, envs1 = envs;
|
|
6629
|
+
if (null !== envs1 && (config1.source ||= {}, config1.source.define = {
|
|
6630
|
+
...envs1.publicVars,
|
|
6631
|
+
...config1.source.define
|
|
6632
|
+
}, 0 !== envs1.filePaths.length && (config1.dev ||= {}, config1.dev.watchFiles = [
|
|
6633
|
+
...config1.dev.watchFiles ? castArray(config1.dev.watchFiles) : [],
|
|
6634
|
+
{
|
|
6635
|
+
paths: envs1.filePaths,
|
|
6636
|
+
type: 'reload-server'
|
|
6660
6637
|
}
|
|
6661
|
-
|
|
6638
|
+
], null === (_config_performance = config1.performance) || void 0 === _config_performance ? void 0 : _config_performance.buildCache))) {
|
|
6639
|
+
let { buildCache } = config1.performance;
|
|
6640
|
+
!0 === buildCache ? config1.performance.buildCache = {
|
|
6641
|
+
buildDependencies: envs1.filePaths
|
|
6642
|
+
} : (buildCache.buildDependencies ||= [], buildCache.buildDependencies.push(...envs1.filePaths));
|
|
6643
|
+
}
|
|
6662
6644
|
let resolvedOptions = {
|
|
6663
6645
|
cwd: process.cwd(),
|
|
6664
6646
|
...options,
|
|
@@ -6671,15 +6653,14 @@ async function createRsbuild(options = {}) {
|
|
|
6671
6653
|
addPlugins: (newPlugins, options)=>{
|
|
6672
6654
|
let { before, environment = RSBUILD_ALL_ENVIRONMENT_SYMBOL } = options || {};
|
|
6673
6655
|
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(`
|
|
6656
|
+
let type = typeof newPlugin;
|
|
6657
|
+
if ('object' !== type || null === newPlugin) throw Error(`[rsbuild:plugin] Expect Rsbuild plugin instance to be an object, but got ${type}.`);
|
|
6658
|
+
if (!isFunction(newPlugin.setup)) {
|
|
6659
|
+
if (isFunction(newPlugin.apply)) {
|
|
6660
|
+
let { name = 'SomeWebpackPlugin' } = newPlugin.constructor || {};
|
|
6661
|
+
throw Error([
|
|
6662
|
+
`${__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:`,
|
|
6663
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.green(`
|
|
6683
6664
|
// rsbuild.config.ts
|
|
6684
6665
|
export default {
|
|
6685
6666
|
tools: {
|
|
@@ -6689,11 +6670,11 @@ async function createRsbuild(options = {}) {
|
|
|
6689
6670
|
}
|
|
6690
6671
|
};
|
|
6691
6672
|
`)
|
|
6692
|
-
|
|
6693
|
-
}
|
|
6694
|
-
throw Error(`[rsbuild:plugin] Expect the setup function of Rsbuild plugin to be a function, but got ${type}.`);
|
|
6673
|
+
].join('\n'));
|
|
6695
6674
|
}
|
|
6696
|
-
|
|
6675
|
+
throw Error(`[rsbuild:plugin] Expect the setup function of Rsbuild plugin to be a function, but got ${type}.`);
|
|
6676
|
+
}
|
|
6677
|
+
if (before) {
|
|
6697
6678
|
let index = plugins.findIndex((item)=>item.instance.name === before);
|
|
6698
6679
|
-1 === index ? (__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`Plugin "${before}" does not exist.`), plugins.push({
|
|
6699
6680
|
environment,
|
|
@@ -6983,8 +6964,7 @@ function toArr(any) {
|
|
|
6983
6964
|
];
|
|
6984
6965
|
}
|
|
6985
6966
|
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)=>{
|
|
6967
|
+
let angledMatch, squareMatch, ANGLED_BRACKET_RE_GLOBAL = /<([^>]+)>/g, SQUARE_BRACKET_RE_GLOBAL = /\[([^\]]+)\]/g, res = [], parse = (match)=>{
|
|
6988
6968
|
let variadic = !1, value = match[1];
|
|
6989
6969
|
return value.startsWith("...") && (value = value.slice(3), variadic = !0), {
|
|
6990
6970
|
required: match[0].startsWith("<"),
|
|
@@ -7293,21 +7273,20 @@ let cac_dist = (name = "")=>new CAC(name), applyCommonOptions = (cli)=>{
|
|
|
7293
7273
|
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
7274
|
};
|
|
7295
7275
|
async function runCLI() {
|
|
7296
|
-
!
|
|
7297
|
-
|
|
7298
|
-
|
|
7299
|
-
|
|
7300
|
-
|
|
7301
|
-
|
|
7302
|
-
|
|
7303
|
-
|
|
7304
|
-
}(), process.title = 'rsbuild-node';
|
|
7276
|
+
if (!process.env.NODE_ENV) {
|
|
7277
|
+
let command = process.argv[2];
|
|
7278
|
+
process.env.NODE_ENV = [
|
|
7279
|
+
'build',
|
|
7280
|
+
'preview'
|
|
7281
|
+
].includes(command) ? 'production' : 'development';
|
|
7282
|
+
}
|
|
7283
|
+
process.title = 'rsbuild-node';
|
|
7305
7284
|
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.
|
|
7285
|
+
(!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.1\n`);
|
|
7307
7286
|
try {
|
|
7308
7287
|
!function() {
|
|
7309
7288
|
let cli = cac_dist('rsbuild');
|
|
7310
|
-
cli.help(), cli.version("1.3.
|
|
7289
|
+
cli.help(), cli.version("1.3.1"), applyCommonOptions(cli);
|
|
7311
7290
|
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
7291
|
applyServerOptions(devCommand), applyServerOptions(previewCommand), devCommand.action(async (options)=>{
|
|
7313
7292
|
try {
|
|
@@ -7358,6 +7337,6 @@ async function runCLI() {
|
|
|
7358
7337
|
__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
7338
|
}
|
|
7360
7339
|
}
|
|
7361
|
-
let src_version = "1.3.
|
|
7340
|
+
let src_version = "1.3.1";
|
|
7362
7341
|
var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger, __webpack_exports__rspack = __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack;
|
|
7363
7342
|
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 };
|