@rsbuild/core 2.0.0-beta.7 → 2.0.0-beta.8
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/bin/rsbuild.js +13 -0
- package/compiled/connect-next/index.d.ts +56 -0
- package/compiled/{connect → connect-next}/license +1 -0
- package/compiled/connect-next/package.json +1 -0
- package/compiled/css-loader/index.js +2 -2
- package/compiled/html-rspack-plugin/index.js +14 -14
- package/compiled/jiti/dist/babel.cjs +60 -60
- package/compiled/jiti/dist/jiti.cjs +2 -2
- package/compiled/postcss-loader/index.js +6 -6
- package/compiled/rslog/index.d.ts +17 -1
- package/compiled/rslog/package.json +1 -1
- package/dist/{131.js → 958.js} +254 -357
- package/dist/chokidar.js +59 -57
- package/dist/client/hmr.js +1 -1
- package/dist/client/overlay.js +1 -1
- package/dist/connect-next.js +268 -0
- package/dist/{connect.js.LICENSE.txt → connect-next.js.LICENSE.txt} +3 -13
- package/dist/cors.js +2 -2
- package/dist/http-proxy-middleware.js +57 -552
- package/dist/index.js +1 -1
- package/dist/launch-editor-middleware.js +23 -8
- package/dist/manifest-plugin.js +18 -18
- package/dist/memfs.js +178 -717
- package/dist/{710.js → mrmime.js} +2 -1
- package/dist/open.js +35 -32
- package/dist/range-parser.js +2 -2
- package/dist/remapping.js +2 -2
- package/dist/rslib-runtime.js +3 -3
- package/dist/sirv.js +14 -14
- package/dist/src.js +510 -0
- package/dist/tinyglobby.js +25 -25
- package/dist/transformLoader.mjs +38 -1
- package/dist/transformRawLoader.mjs +1 -1
- package/dist/ws.js +1541 -0
- package/dist-types/helpers/index.d.ts +1 -1
- package/dist-types/helpers/vendors.d.ts +0 -1
- package/dist-types/server/runner/asModule.d.ts +1 -1
- package/dist-types/server/socketServer.d.ts +1 -1
- package/dist-types/types/thirdParty.d.ts +1 -1
- package/package.json +7 -8
- package/compiled/connect/index.d.ts +0 -90
- package/compiled/connect/package.json +0 -1
- package/compiled/ws/index.d.ts +0 -437
- package/compiled/ws/index.js +0 -3166
- package/compiled/ws/license +0 -20
- package/compiled/ws/package.json +0 -1
- package/dist/397.js +0 -11
- package/dist/7.js +0 -1
- package/dist/712.js +0 -15
- package/dist/743.js +0 -7
- package/dist/88.js +0 -40
- package/dist/connect.js +0 -574
- package/dist-types/helpers/color.d.ts +0 -4
- /package/dist/{131.js.LICENSE.txt → 958.js.LICENSE.txt} +0 -0
- /package/dist/client/{59.js → 797.js} +0 -0
- /package/dist/{31.js → trace-mapping.js} +0 -0
package/dist/{131.js → 958.js}
RENAMED
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
/*!
|
|
1
|
+
/*! LICENSE: 958.js.LICENSE.txt */
|
|
2
2
|
let flagForceColor, runtimeProcessArgs, runtimeInfo, swcHelpersPath, pluginHelper_htmlPlugin, cssExtractPlugin;
|
|
3
|
-
import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
|
|
4
|
-
import { createRequire as __rspack_createRequire } from "node:module";
|
|
3
|
+
import { fileURLToPath as __rspack_fileURLToPath, URL as external_node_url_URL, fileURLToPath, pathToFileURL } from "node:url";
|
|
4
|
+
import { createRequire as __rspack_createRequire, builtinModules, createRequire } from "node:module";
|
|
5
5
|
let __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
|
|
6
6
|
import * as __rspack_external_async_hooks from "async_hooks";
|
|
7
7
|
import * as __rspack_external_fs from "fs";
|
|
8
|
-
import * as __rspack_external_node_fs_5ea92f0c from "node:fs";
|
|
9
8
|
import * as __rspack_external_node_module_ab9f2194 from "node:module";
|
|
10
|
-
import * as
|
|
11
|
-
import * as __rspack_external_node_path_c5b9b54f from "node:path";
|
|
12
|
-
import * as __rspack_external_node_process_786449bf from "node:process";
|
|
13
|
-
import * as __rspack_external_node_tty_c64aab7e from "node:tty";
|
|
9
|
+
import node_path, * as __rspack_external_node_path_c5b9b54f from "node:path";
|
|
14
10
|
import * as __rspack_external_node_url_e96de089 from "node:url";
|
|
15
11
|
import * as __rspack_external_os from "os";
|
|
16
12
|
import * as __rspack_external_path from "path";
|
|
17
13
|
import * as __rspack_external_url from "url";
|
|
18
14
|
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
19
15
|
import { rspack as core_rspack } from "@rspack/core";
|
|
20
|
-
import {
|
|
16
|
+
import node_util, { stripVTControlCharacters } from "node:util";
|
|
17
|
+
import node_process from "node:process";
|
|
18
|
+
import node_os, { constants as external_node_os_constants } from "node:os";
|
|
19
|
+
import node_tty from "node:tty";
|
|
20
|
+
import { dirname as external_node_path_dirname, isAbsolute as external_node_path_isAbsolute, join, posix, relative, sep, win32 } from "node:path";
|
|
21
|
+
import node_fs, { existsSync } from "node:fs";
|
|
21
22
|
import { isPromise, isRegExp } from "node:util/types";
|
|
22
23
|
import node_zlib from "node:zlib";
|
|
23
24
|
__webpack_require__.add({
|
|
@@ -156,7 +157,7 @@ __webpack_require__.add({
|
|
|
156
157
|
};
|
|
157
158
|
},
|
|
158
159
|
"../../node_modules/.pnpm/lilconfig@3.1.3/node_modules/lilconfig/src/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
159
|
-
let path = __webpack_require__("path"), fs = __webpack_require__("fs"), os = __webpack_require__("os"), url = __webpack_require__("url"), fsReadFileAsync = fs.promises.readFile;
|
|
160
|
+
let path = __webpack_require__("path?48c6"), fs = __webpack_require__("fs?5e1e"), os = __webpack_require__("os?6427"), url = __webpack_require__("url?e527"), fsReadFileAsync = fs.promises.readFile;
|
|
160
161
|
function getDefaultSearchPlaces(name, sync) {
|
|
161
162
|
return [
|
|
162
163
|
'package.json',
|
|
@@ -188,9 +189,7 @@ __webpack_require__.add({
|
|
|
188
189
|
'.json': __rspack_createRequire_require,
|
|
189
190
|
'.cjs': __rspack_createRequire_require,
|
|
190
191
|
noExt: jsonLoader
|
|
191
|
-
})
|
|
192
|
-
module.exports.defaultLoadersSync = defaultLoadersSync;
|
|
193
|
-
let dynamicImport = async (id)=>{
|
|
192
|
+
}), dynamicImport = async (id)=>{
|
|
194
193
|
try {
|
|
195
194
|
let fileUrl = url.pathToFileURL(id).href;
|
|
196
195
|
return (await import(fileUrl)).default;
|
|
@@ -241,10 +240,8 @@ __webpack_require__.add({
|
|
|
241
240
|
if (!loader) throw Error(`No loader specified for extension "${ext}"`);
|
|
242
241
|
if ('function' != typeof loader) throw Error('loader is not a function');
|
|
243
242
|
}
|
|
244
|
-
module.exports.defaultLoaders = defaultLoaders;
|
|
245
|
-
let makeEmplace = (enableCache)=>(c, filepath, res)=>(enableCache && c.set(filepath, res), res);
|
|
246
243
|
module.exports.lilconfig = function lilconfig(name, options) {
|
|
247
|
-
let { ignoreEmptySearchPlaces, loaders, packageProp, searchPlaces, stopDir, transform, cache } = getOptions(name, options ?? {}, !1), searchCache = new Map(), loadCache = new Map(), emplace =
|
|
244
|
+
let { ignoreEmptySearchPlaces, loaders, packageProp, searchPlaces, stopDir, transform, cache } = getOptions(name, options ?? {}, !1), searchCache = new Map(), loadCache = new Map(), emplace = (c, filepath, res)=>(cache && c.set(filepath, res), res);
|
|
248
245
|
return {
|
|
249
246
|
async search (searchFrom = process.cwd()) {
|
|
250
247
|
let result = {
|
|
@@ -327,87 +324,6 @@ __webpack_require__.add({
|
|
|
327
324
|
cache && (loadCache.clear(), searchCache.clear());
|
|
328
325
|
}
|
|
329
326
|
};
|
|
330
|
-
}, module.exports.lilconfigSync = function lilconfigSync(name, options) {
|
|
331
|
-
let { ignoreEmptySearchPlaces, loaders, packageProp, searchPlaces, stopDir, transform, cache } = getOptions(name, options ?? {}, !0), searchCache = new Map(), loadCache = new Map(), emplace = makeEmplace(cache);
|
|
332
|
-
return {
|
|
333
|
-
search (searchFrom = process.cwd()) {
|
|
334
|
-
let result = {
|
|
335
|
-
config: null,
|
|
336
|
-
filepath: ''
|
|
337
|
-
}, visited = new Set(), dir = searchFrom;
|
|
338
|
-
dirLoop: for(;;){
|
|
339
|
-
if (cache) {
|
|
340
|
-
let r = searchCache.get(dir);
|
|
341
|
-
if (void 0 !== r) {
|
|
342
|
-
for (let p of visited)searchCache.set(p, r);
|
|
343
|
-
return r;
|
|
344
|
-
}
|
|
345
|
-
visited.add(dir);
|
|
346
|
-
}
|
|
347
|
-
for (let searchPlace of searchPlaces){
|
|
348
|
-
let filepath = path.join(dir, searchPlace);
|
|
349
|
-
try {
|
|
350
|
-
fs.accessSync(filepath);
|
|
351
|
-
} catch {
|
|
352
|
-
continue;
|
|
353
|
-
}
|
|
354
|
-
let loaderKey = path.extname(searchPlace) || 'noExt', loader = loaders[loaderKey], content = String(fs.readFileSync(filepath));
|
|
355
|
-
if ('package.json' === searchPlace) {
|
|
356
|
-
let maybeConfig = getPackageProp(packageProp, loader(filepath, content));
|
|
357
|
-
if (null != maybeConfig) {
|
|
358
|
-
result.config = maybeConfig, result.filepath = filepath;
|
|
359
|
-
break dirLoop;
|
|
360
|
-
}
|
|
361
|
-
continue;
|
|
362
|
-
}
|
|
363
|
-
let isEmpty = '' === content.trim();
|
|
364
|
-
if (!isEmpty || !ignoreEmptySearchPlaces) {
|
|
365
|
-
isEmpty ? (result.isEmpty = !0, result.config = void 0) : (validateLoader(loader, loaderKey), result.config = loader(filepath, content)), result.filepath = filepath;
|
|
366
|
-
break dirLoop;
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
if (dir === stopDir || dir === parentDir(dir)) break;
|
|
370
|
-
dir = parentDir(dir);
|
|
371
|
-
}
|
|
372
|
-
let transformed = '' === result.filepath && null === result.config ? transform(null) : transform(result);
|
|
373
|
-
if (cache) for (let p of visited)searchCache.set(p, transformed);
|
|
374
|
-
return transformed;
|
|
375
|
-
},
|
|
376
|
-
load (filepath) {
|
|
377
|
-
validateFilePath(filepath);
|
|
378
|
-
let absPath = path.resolve(process.cwd(), filepath);
|
|
379
|
-
if (cache && loadCache.has(absPath)) return loadCache.get(absPath);
|
|
380
|
-
let { base, ext } = path.parse(absPath), loaderKey = ext || 'noExt', loader = loaders[loaderKey];
|
|
381
|
-
validateLoader(loader, loaderKey);
|
|
382
|
-
let content = String(fs.readFileSync(absPath));
|
|
383
|
-
if ('package.json' === base) return transform({
|
|
384
|
-
config: getPackageProp(packageProp, loader(absPath, content)),
|
|
385
|
-
filepath: absPath
|
|
386
|
-
});
|
|
387
|
-
let result = {
|
|
388
|
-
config: null,
|
|
389
|
-
filepath: absPath
|
|
390
|
-
}, isEmpty = '' === content.trim();
|
|
391
|
-
return isEmpty && ignoreEmptySearchPlaces ? emplace(loadCache, absPath, transform({
|
|
392
|
-
filepath: absPath,
|
|
393
|
-
config: void 0,
|
|
394
|
-
isEmpty: !0
|
|
395
|
-
})) : (result.config = isEmpty ? void 0 : loader(absPath, content), emplace(loadCache, absPath, transform(isEmpty ? {
|
|
396
|
-
...result,
|
|
397
|
-
isEmpty,
|
|
398
|
-
config: void 0
|
|
399
|
-
} : result)));
|
|
400
|
-
},
|
|
401
|
-
clearLoadCache () {
|
|
402
|
-
cache && loadCache.clear();
|
|
403
|
-
},
|
|
404
|
-
clearSearchCache () {
|
|
405
|
-
cache && searchCache.clear();
|
|
406
|
-
},
|
|
407
|
-
clearCaches () {
|
|
408
|
-
cache && (loadCache.clear(), searchCache.clear());
|
|
409
|
-
}
|
|
410
|
-
};
|
|
411
327
|
};
|
|
412
328
|
},
|
|
413
329
|
"../../node_modules/.pnpm/on-finished@2.4.1/node_modules/on-finished/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
@@ -477,7 +393,7 @@ __webpack_require__.add({
|
|
|
477
393
|
}
|
|
478
394
|
},
|
|
479
395
|
"../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.8_yaml@2.8.2/node_modules/postcss-load-config/src/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
480
|
-
let yaml, { resolve } = __webpack_require__("node:path"), config = __webpack_require__("../../node_modules/.pnpm/lilconfig@3.1.3/node_modules/lilconfig/src/index.js"), loadOptions = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.8_yaml@2.8.2/node_modules/postcss-load-config/src/options.js"), loadPlugins = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.8_yaml@2.8.2/node_modules/postcss-load-config/src/plugins.js"), req = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.8_yaml@2.8.2/node_modules/postcss-load-config/src/req.js");
|
|
396
|
+
let yaml, { resolve } = __webpack_require__("node:path?f52c"), config = __webpack_require__("../../node_modules/.pnpm/lilconfig@3.1.3/node_modules/lilconfig/src/index.js"), loadOptions = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.8_yaml@2.8.2/node_modules/postcss-load-config/src/options.js"), loadPlugins = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.8_yaml@2.8.2/node_modules/postcss-load-config/src/plugins.js"), req = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.8_yaml@2.8.2/node_modules/postcss-load-config/src/req.js");
|
|
481
397
|
async function processResult(ctx, result) {
|
|
482
398
|
let obj, file = result.filepath || '', projectConfig = ((obj = result.config) && obj.__esModule ? obj : {
|
|
483
399
|
default: obj
|
|
@@ -591,7 +507,7 @@ __webpack_require__.add({
|
|
|
591
507
|
"../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.8_yaml@2.8.2/node_modules/postcss-load-config/src/req.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
592
508
|
let tsx, jiti;
|
|
593
509
|
var __filename = __rspack_fileURLToPath(import.meta.url);
|
|
594
|
-
let { createRequire } = __webpack_require__("node:module"), { pathToFileURL } = __webpack_require__("node:url"), TS_EXT_RE = /\.[mc]?ts$/, importError = [];
|
|
510
|
+
let { createRequire } = __webpack_require__("node:module?330e"), { pathToFileURL } = __webpack_require__("node:url?3475"), TS_EXT_RE = /\.[mc]?ts$/, importError = [];
|
|
595
511
|
module.exports = async function req(name, rootFile = __filename) {
|
|
596
512
|
let url = createRequire(rootFile).resolve(name);
|
|
597
513
|
try {
|
|
@@ -622,46 +538,55 @@ __webpack_require__.add({
|
|
|
622
538
|
async_hooks (module) {
|
|
623
539
|
module.exports = __rspack_external_async_hooks;
|
|
624
540
|
},
|
|
625
|
-
fs (module) {
|
|
541
|
+
"fs?5e1e" (module) {
|
|
626
542
|
module.exports = __rspack_external_fs;
|
|
627
543
|
},
|
|
628
|
-
"node:
|
|
629
|
-
module.exports = __rspack_external_node_fs_5ea92f0c;
|
|
630
|
-
},
|
|
631
|
-
"node:module" (module) {
|
|
544
|
+
"node:module?330e" (module) {
|
|
632
545
|
module.exports = __rspack_external_node_module_ab9f2194;
|
|
633
546
|
},
|
|
634
|
-
"node:
|
|
635
|
-
module.exports = __rspack_external_node_os_74b4b876;
|
|
636
|
-
},
|
|
637
|
-
"node:path" (module) {
|
|
547
|
+
"node:path?f52c" (module) {
|
|
638
548
|
module.exports = __rspack_external_node_path_c5b9b54f;
|
|
639
549
|
},
|
|
640
|
-
"node:
|
|
641
|
-
module.exports = __rspack_external_node_process_786449bf;
|
|
642
|
-
},
|
|
643
|
-
"node:tty" (module) {
|
|
644
|
-
module.exports = __rspack_external_node_tty_c64aab7e;
|
|
645
|
-
},
|
|
646
|
-
"node:url" (module) {
|
|
550
|
+
"node:url?3475" (module) {
|
|
647
551
|
module.exports = __rspack_external_node_url_e96de089;
|
|
648
552
|
},
|
|
649
|
-
os (module) {
|
|
553
|
+
"os?6427" (module) {
|
|
650
554
|
module.exports = __rspack_external_os;
|
|
651
555
|
},
|
|
652
|
-
path (module) {
|
|
556
|
+
"path?48c6" (module) {
|
|
653
557
|
module.exports = __rspack_external_path;
|
|
654
558
|
},
|
|
655
|
-
url (module) {
|
|
559
|
+
"url?e527" (module) {
|
|
656
560
|
module.exports = __rspack_external_url;
|
|
657
|
-
}
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
561
|
+
},
|
|
562
|
+
events (module) {
|
|
563
|
+
module.exports = __rspack_createRequire_require("node:events");
|
|
564
|
+
}
|
|
565
|
+
}), function checkNodeVersion() {
|
|
566
|
+
let { versions } = process;
|
|
567
|
+
if (!("styleText" in node_util) && versions.node && !versions.bun && !versions.deno) throw Error(`Unsupported Node.js version: "${process.versions.node || 'unknown'}". Expected Node.js >= 20.`);
|
|
568
|
+
}();
|
|
569
|
+
let createStyler = (style)=>(text)=>node_util.styleText(style, String(text)), color = {
|
|
570
|
+
dim: createStyler('dim'),
|
|
571
|
+
red: createStyler('red'),
|
|
572
|
+
bold: createStyler('bold'),
|
|
573
|
+
blue: createStyler('blue'),
|
|
574
|
+
cyan: createStyler('cyan'),
|
|
575
|
+
gray: createStyler('gray'),
|
|
576
|
+
black: createStyler('black'),
|
|
577
|
+
green: createStyler('green'),
|
|
578
|
+
white: createStyler('white'),
|
|
579
|
+
reset: createStyler('reset'),
|
|
580
|
+
yellow: createStyler('yellow'),
|
|
581
|
+
magenta: createStyler('magenta'),
|
|
582
|
+
underline: createStyler('underline'),
|
|
583
|
+
strikethrough: createStyler('strikethrough')
|
|
584
|
+
};
|
|
585
|
+
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : node_process.argv) {
|
|
661
586
|
let prefix = flag.startsWith('-') ? '' : 1 === flag.length ? '-' : '--', position = argv.indexOf(prefix + flag), terminatorPosition = argv.indexOf('--');
|
|
662
587
|
return -1 !== position && (-1 === terminatorPosition || position < terminatorPosition);
|
|
663
588
|
}
|
|
664
|
-
let { env: dist_env } =
|
|
589
|
+
let { env: dist_env } = node_process;
|
|
665
590
|
function envForceColor() {
|
|
666
591
|
if (!('FORCE_COLOR' in dist_env)) return;
|
|
667
592
|
if ('true' === dist_env.FORCE_COLOR) return 1;
|
|
@@ -696,8 +621,8 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = !0 } = {}) {
|
|
|
696
621
|
if (haveStream && !streamIsTTY && void 0 === forceColor) return 0;
|
|
697
622
|
let min = forceColor || 0;
|
|
698
623
|
if ('dumb' === dist_env.TERM) return min;
|
|
699
|
-
if ('win32' ===
|
|
700
|
-
let osRelease =
|
|
624
|
+
if ('win32' === node_process.platform) {
|
|
625
|
+
let osRelease = node_os.release().split('.');
|
|
701
626
|
return Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586 ? Number(osRelease[2]) >= 14931 ? 3 : 2 : 1;
|
|
702
627
|
}
|
|
703
628
|
if ('CI' in dist_env) return [
|
|
@@ -733,10 +658,10 @@ function createSupportsColor(stream, options = {}) {
|
|
|
733
658
|
hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false') || hasFlag('color=never') ? flagForceColor = 0 : (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) && (flagForceColor = 1);
|
|
734
659
|
let supportsColor = {
|
|
735
660
|
stdout: createSupportsColor({
|
|
736
|
-
isTTY:
|
|
661
|
+
isTTY: node_tty.isatty(1)
|
|
737
662
|
}),
|
|
738
663
|
stderr: createSupportsColor({
|
|
739
|
-
isTTY:
|
|
664
|
+
isTTY: node_tty.isatty(2)
|
|
740
665
|
})
|
|
741
666
|
}, colorLevel = supportsColor.stdout ? supportsColor.stdout.level : 0, errorStackRegExp = /at [^\r\n]{0,200}:\d+:\d+[\s\)]*$/, anonymousErrorStackRegExp = /at [^\r\n]{0,200}\(<anonymous>\)$/, indexErrorStackRegExp = /at [^\r\n]{0,200}\(index\s\d+\)$/, isWord = (char)=>!/[\s\n]/.test(char), LOG_LEVEL = {
|
|
742
667
|
silent: -1,
|
|
@@ -749,32 +674,32 @@ let supportsColor = {
|
|
|
749
674
|
error: {
|
|
750
675
|
label: 'error',
|
|
751
676
|
level: 'error',
|
|
752
|
-
color: red
|
|
677
|
+
color: color.red
|
|
753
678
|
},
|
|
754
679
|
warn: {
|
|
755
680
|
label: 'warn',
|
|
756
681
|
level: 'warn',
|
|
757
|
-
color: yellow
|
|
682
|
+
color: color.yellow
|
|
758
683
|
},
|
|
759
684
|
info: {
|
|
760
685
|
label: 'info',
|
|
761
686
|
level: 'info',
|
|
762
|
-
color: cyan
|
|
687
|
+
color: color.cyan
|
|
763
688
|
},
|
|
764
689
|
start: {
|
|
765
690
|
label: 'start',
|
|
766
691
|
level: 'info',
|
|
767
|
-
color: cyan
|
|
692
|
+
color: color.cyan
|
|
768
693
|
},
|
|
769
694
|
ready: {
|
|
770
695
|
label: 'ready',
|
|
771
696
|
level: 'info',
|
|
772
|
-
color: green
|
|
697
|
+
color: color.green
|
|
773
698
|
},
|
|
774
699
|
success: {
|
|
775
700
|
label: 'success',
|
|
776
701
|
level: 'info',
|
|
777
|
-
color: green
|
|
702
|
+
color: color.green
|
|
778
703
|
},
|
|
779
704
|
log: {
|
|
780
705
|
level: 'info'
|
|
@@ -782,12 +707,12 @@ let supportsColor = {
|
|
|
782
707
|
debug: {
|
|
783
708
|
label: 'debug',
|
|
784
709
|
level: 'verbose',
|
|
785
|
-
color: magenta
|
|
710
|
+
color: color.magenta
|
|
786
711
|
}
|
|
787
712
|
}, normalizeErrorMessage = (err)=>{
|
|
788
713
|
if (err.stack) {
|
|
789
714
|
let [name, ...rest] = err.stack.split('\n');
|
|
790
|
-
return name.startsWith('Error: ') && (name = name.slice(7)), `${name}\n${gray(rest.join('\n'))}`;
|
|
715
|
+
return name.startsWith('Error: ') && (name = name.slice(7)), `${name}\n${color.gray(rest.join('\n'))}`;
|
|
791
716
|
}
|
|
792
717
|
return err.message;
|
|
793
718
|
}, src_logger = ((options = {})=>{
|
|
@@ -796,20 +721,20 @@ let supportsColor = {
|
|
|
796
721
|
if (LOG_LEVEL[level] > LOG_LEVEL[maxLevel]) return;
|
|
797
722
|
if (null == message) return console.log();
|
|
798
723
|
let label = '', text = '';
|
|
799
|
-
if ('label' in logType && (label = (logType.label || '').padEnd(7), label = bold(logType.color ? logType.color(label) : label)), message instanceof Error) {
|
|
724
|
+
if ('label' in logType && (label = (logType.label || '').padEnd(7), label = color.bold(logType.color ? logType.color(label) : label)), message instanceof Error) {
|
|
800
725
|
text += normalizeErrorMessage(message);
|
|
801
726
|
let { cause } = message;
|
|
802
|
-
cause && (text += yellow('\n [cause]: '), text += cause instanceof Error ? normalizeErrorMessage(cause) : String(cause));
|
|
803
|
-
} else text = 'error' === level && 'string' == typeof message ? message.split('\n').map((line)=>errorStackRegExp.test(line) || anonymousErrorStackRegExp.test(line) || indexErrorStackRegExp.test(line) ? gray(line) : line).join('\n') : `${message}`;
|
|
727
|
+
cause && (text += color.yellow('\n [cause]: '), text += cause instanceof Error ? normalizeErrorMessage(cause) : String(cause));
|
|
728
|
+
} else text = 'error' === level && 'string' == typeof message ? message.split('\n').map((line)=>errorStackRegExp.test(line) || anonymousErrorStackRegExp.test(line) || indexErrorStackRegExp.test(line) ? color.gray(line) : line).join('\n') : `${message}`;
|
|
804
729
|
console['error' === level || 'warn' === level ? level : 'log'](label.length ? `${label} ${text}` : text, ...args);
|
|
805
730
|
}, logger = {
|
|
806
731
|
greet: (message)=>log('log', ((message)=>{
|
|
807
|
-
if (colorLevel < 3) return 2 === colorLevel ?
|
|
732
|
+
if (colorLevel < 3) return 2 === colorLevel ? color.cyan(message) : message;
|
|
808
733
|
let chars = [
|
|
809
734
|
...message
|
|
810
735
|
], steps = chars.filter(isWord).length, r = 189, g = 255, b = 243, rStep = -115 / steps, gStep = -61 / steps, bStep = -89 / steps, output = '';
|
|
811
736
|
for (let char of chars)isWord(char) && (r += rStep, g += gStep, b += bStep), output += `\x1b[38;2;${Math.round(r)};${Math.round(g)};${Math.round(b)}m${char}\x1b[39m`;
|
|
812
|
-
return bold(output);
|
|
737
|
+
return color.bold(output);
|
|
813
738
|
})(message))
|
|
814
739
|
};
|
|
815
740
|
return Object.keys(LOG_TYPES).forEach((key)=>{
|
|
@@ -822,18 +747,7 @@ let supportsColor = {
|
|
|
822
747
|
}), logger.override = (customLogger)=>{
|
|
823
748
|
Object.assign(logger, customLogger);
|
|
824
749
|
}, logger;
|
|
825
|
-
})(),
|
|
826
|
-
red: color_createStyler('red'),
|
|
827
|
-
yellow: color_createStyler('yellow'),
|
|
828
|
-
green: color_createStyler('green'),
|
|
829
|
-
blue: color_createStyler('blue'),
|
|
830
|
-
magenta: color_createStyler('magenta'),
|
|
831
|
-
cyan: color_createStyler('cyan'),
|
|
832
|
-
gray: color_createStyler('gray'),
|
|
833
|
-
dim: color_createStyler('dim'),
|
|
834
|
-
bold: color_createStyler('bold'),
|
|
835
|
-
underline: color_createStyler('underline')
|
|
836
|
-
}, isDebug = ()=>{
|
|
750
|
+
})(), isDebug = ()=>{
|
|
837
751
|
if (!process.env.DEBUG) return !1;
|
|
838
752
|
let values = process.env.DEBUG.toLocaleLowerCase().split(',');
|
|
839
753
|
return [
|
|
@@ -1235,7 +1149,7 @@ var Command = class {
|
|
|
1235
1149
|
}), actionArgs.push(options), command.commandAction.apply(this, actionArgs);
|
|
1236
1150
|
}
|
|
1237
1151
|
};
|
|
1238
|
-
let
|
|
1152
|
+
let isDeno = "u" > typeof Deno, isWindows = 'win32' === process.platform, ROOT_DIST_DIR = 'dist', dirname = import.meta.dirname, STATIC_PATH = join(dirname, '../static'), CLIENT_PATH = join(dirname, 'client'), COMPILED_PATH = join(dirname, '../compiled'), RSBUILD_OUTPUTS_PATH = '.rsbuild', LOCALHOST = 'localhost', ALL_INTERFACES_IPV4 = '0.0.0.0', DEFAULT_ASSET_PREFIX = '/', DEFAULT_STACK_TRACE = 'summary', DEFAULT_WEB_BROWSERSLIST = [
|
|
1239
1153
|
'chrome >= 107',
|
|
1240
1154
|
'edge >= 107',
|
|
1241
1155
|
'firefox >= 104',
|
|
@@ -2351,7 +2265,7 @@ let Rule = Orderable(class extends ChainedMap {
|
|
|
2351
2265
|
'plugin'
|
|
2352
2266
|
]);
|
|
2353
2267
|
}
|
|
2354
|
-
},
|
|
2268
|
+
}, vendors_require = createRequire(import.meta.url), requireCompiledPackage = (name)=>vendors_require(`${COMPILED_PATH}/${name}/index.js`), cjs_0 = __webpack_require__("../../node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge/dist/cjs.js");
|
|
2355
2269
|
var cjs_0_default = __webpack_require__.n(cjs_0);
|
|
2356
2270
|
let setNodeEnv = (env)=>{
|
|
2357
2271
|
process.env.NODE_ENV = env;
|
|
@@ -2495,8 +2409,8 @@ function formatStatsError(stats, root, level = 'error') {
|
|
|
2495
2409
|
let snippet = fileName.replace(DATA_URI_PREFIX, '');
|
|
2496
2410
|
return snippet.length > 30 && (snippet = `${snippet.slice(0, 30)}...`), `File: ${color.cyan('data-uri virtual module')} ${color.dim(`(${snippet})`)}\n`;
|
|
2497
2411
|
}
|
|
2498
|
-
let prefix = root +
|
|
2499
|
-
return (fileName.startsWith(prefix) && (fileName = fileName.replace(prefix, `.${
|
|
2412
|
+
let prefix = root + sep;
|
|
2413
|
+
return (fileName.startsWith(prefix) && (fileName = fileName.replace(prefix, `.${sep}`)), /:\d+:\d+/.test(fileName)) ? `File: ${color.cyan(fileName)}\n` : stats.loc ? `File: ${color.cyan(`${fileName}:${stats.loc}`)}\n` : `File: ${color.cyan(`${fileName}:1:1`)}\n`;
|
|
2500
2414
|
})(fileName, stats, root)}${stats.message}`, verbose = isVerbose();
|
|
2501
2415
|
if (verbose && (stats.details && (message += `\nDetails: ${stats.details}\n`), stats.stack && (message += `\n${stats.stack}`)), 'error' === level || isVerbose()) {
|
|
2502
2416
|
let moduleTrace = formatModuleTrace(stats, fileName, level);
|
|
@@ -2523,7 +2437,7 @@ function formatStatsError(stats, root, level = 'error') {
|
|
|
2523
2437
|
let matchArray = stripVTControlCharacters(message).match(/Can't resolve '(\w+)'/);
|
|
2524
2438
|
if (!matchArray) return message;
|
|
2525
2439
|
let moduleName = matchArray[1];
|
|
2526
|
-
return moduleName &&
|
|
2440
|
+
return moduleName && builtinModules.includes(moduleName) ? getTips(moduleName) : message;
|
|
2527
2441
|
})(message = hintUnknownFiles(message)))).split('\n');
|
|
2528
2442
|
return (message = (lines = lines.filter((line, index, arr)=>0 === index || '' !== line.trim() || line.trim() !== arr[index - 1].trim())).join('\n')).trim();
|
|
2529
2443
|
}
|
|
@@ -2717,7 +2631,7 @@ let onBeforeCompile = ({ compiler, beforeCompile, beforeEnvironmentCompile, isWa
|
|
|
2717
2631
|
} else compiler.hooks.done.tapPromise('rsbuild:done', async (stats)=>{
|
|
2718
2632
|
await onEnvironmentDone(0, stats), await onDone(stats);
|
|
2719
2633
|
});
|
|
2720
|
-
}
|
|
2634
|
+
};
|
|
2721
2635
|
function _define_property(obj, key, value) {
|
|
2722
2636
|
return key in obj ? Object.defineProperty(obj, key, {
|
|
2723
2637
|
value: value,
|
|
@@ -2734,7 +2648,7 @@ class BrowserslistError extends Error {
|
|
|
2734
2648
|
let isFileCache = {};
|
|
2735
2649
|
function isFile(file) {
|
|
2736
2650
|
if (file in isFileCache) return isFileCache[file];
|
|
2737
|
-
let result =
|
|
2651
|
+
let result = node_fs.existsSync(file) && node_fs.statSync(file).isFile();
|
|
2738
2652
|
return isFileCache[file] = result, result;
|
|
2739
2653
|
}
|
|
2740
2654
|
function dist_check(section) {
|
|
@@ -2744,7 +2658,7 @@ function dist_check(section) {
|
|
|
2744
2658
|
} else if ('string' != typeof section) throw new BrowserslistError(FORMAT);
|
|
2745
2659
|
}
|
|
2746
2660
|
function parsePackage(file) {
|
|
2747
|
-
let config = JSON.parse(
|
|
2661
|
+
let config = JSON.parse(node_fs.readFileSync(file).toString().replace(/^\uFEFF/m, ''));
|
|
2748
2662
|
if (config.browserlist && !config.browserslist) throw new BrowserslistError(`\`browserlist\` key instead of \`browserslist\` in ${file}`);
|
|
2749
2663
|
let list = config.browserslist;
|
|
2750
2664
|
for(let i in Array.isArray(list) && (list = {
|
|
@@ -2771,24 +2685,24 @@ function parseConfig(string) {
|
|
|
2771
2685
|
}
|
|
2772
2686
|
function readConfig(file) {
|
|
2773
2687
|
if (!isFile(file)) throw new BrowserslistError(`Can't read ${file} config`);
|
|
2774
|
-
return parseConfig(
|
|
2688
|
+
return parseConfig(node_fs.readFileSync(file, 'utf-8'));
|
|
2775
2689
|
}
|
|
2776
2690
|
function parsePackageOrReadConfig(file) {
|
|
2777
|
-
return 'package.json' ===
|
|
2691
|
+
return 'package.json' === node_path.basename(file) ? parsePackage(file) : readConfig(file);
|
|
2778
2692
|
}
|
|
2779
2693
|
function pickEnv(config, opts) {
|
|
2780
2694
|
return 'object' != typeof config ? config : config['string' == typeof opts.env ? opts.env : process.env.BROWSERSLIST_ENV ? process.env.BROWSERSLIST_ENV : process.env.NODE_ENV ? process.env.NODE_ENV : 'production'] || config.defaults;
|
|
2781
2695
|
}
|
|
2782
2696
|
function eachParent(file, callback) {
|
|
2783
|
-
let dir = isFile(file) ?
|
|
2697
|
+
let dir = isFile(file) ? node_path.dirname(file) : file, loc = node_path.resolve(dir);
|
|
2784
2698
|
do {
|
|
2785
2699
|
let result = callback(loc);
|
|
2786
2700
|
if (void 0 !== result) return result;
|
|
2787
|
-
}while (loc !== (loc =
|
|
2701
|
+
}while (loc !== (loc = node_path.dirname(loc)));
|
|
2788
2702
|
}
|
|
2789
2703
|
function findConfigFile(from) {
|
|
2790
2704
|
return eachParent(from, (dir)=>{
|
|
2791
|
-
let pkgBrowserslist, config =
|
|
2705
|
+
let pkgBrowserslist, config = node_path.join(dir, 'browserslist'), pkg = node_path.join(dir, 'package.json'), rc = node_path.join(dir, '.browserslistrc');
|
|
2792
2706
|
if (isFile(pkg)) try {
|
|
2793
2707
|
pkgBrowserslist = parsePackage(pkg);
|
|
2794
2708
|
} catch (e) {
|
|
@@ -2803,11 +2717,11 @@ function findConfigFile(from) {
|
|
|
2803
2717
|
}
|
|
2804
2718
|
let configCache = {};
|
|
2805
2719
|
function findConfig(from) {
|
|
2806
|
-
let resolved, fromDir = isFile(from =
|
|
2720
|
+
let resolved, fromDir = isFile(from = node_path.resolve(from)) ? node_path.dirname(from) : from;
|
|
2807
2721
|
if (fromDir in configCache) return configCache[fromDir];
|
|
2808
2722
|
let configFile = findConfigFile(from);
|
|
2809
2723
|
configFile && (resolved = parsePackageOrReadConfig(configFile));
|
|
2810
|
-
let configDir = configFile &&
|
|
2724
|
+
let configDir = configFile && node_path.dirname(configFile);
|
|
2811
2725
|
return eachParent(from, (dir)=>{
|
|
2812
2726
|
if (resolved && (configCache[dir] = resolved), dir === configDir) return null;
|
|
2813
2727
|
}), resolved;
|
|
@@ -2821,31 +2735,31 @@ function loadConfig(opts) {
|
|
|
2821
2735
|
}
|
|
2822
2736
|
}
|
|
2823
2737
|
function toRelativePath(base, filepath) {
|
|
2824
|
-
let relativePath =
|
|
2825
|
-
return '' === relativePath ? `.${
|
|
2738
|
+
let relativePath = relative(base, filepath);
|
|
2739
|
+
return '' === relativePath ? `.${sep}` : relativePath.startsWith('.') ? relativePath : `.${sep}${relativePath}`;
|
|
2826
2740
|
}
|
|
2827
2741
|
function getCommonParentPath(paths) {
|
|
2828
2742
|
let uniquePaths = [
|
|
2829
2743
|
...new Set(paths)
|
|
2830
2744
|
];
|
|
2831
2745
|
if (1 === uniquePaths.length) return uniquePaths[0];
|
|
2832
|
-
let [first, ...rest] = uniquePaths.map((p)=>p.split(
|
|
2746
|
+
let [first, ...rest] = uniquePaths.map((p)=>p.split(sep)), common = [];
|
|
2833
2747
|
for(let i = 0; i < first.length; i++){
|
|
2834
2748
|
let segment = first[i];
|
|
2835
2749
|
if (rest.every((p)=>p[i] === segment)) common.push(segment);
|
|
2836
2750
|
else break;
|
|
2837
2751
|
}
|
|
2838
|
-
return common.join(
|
|
2752
|
+
return common.join(sep);
|
|
2839
2753
|
}
|
|
2840
|
-
let
|
|
2754
|
+
let ensureAbsolutePath = (base, filePath)=>external_node_path_isAbsolute(filePath) ? filePath : join(base, filePath), getPathnameFromUrl = (url)=>{
|
|
2841
2755
|
try {
|
|
2842
2756
|
return url ? new URL(url, 'http://localhost').pathname : url;
|
|
2843
2757
|
} catch {
|
|
2844
2758
|
return url;
|
|
2845
2759
|
}
|
|
2846
|
-
}, dedupeNestedPaths = (paths)=>paths.sort((p1, p2)=>p2.length > p1.length ? -1 : 1).reduce((prev, curr)=>prev.find((p)=>curr.startsWith(p) || curr === p) ? prev : prev.concat(curr), []), toPosixPath = (filepath)=>'/' ===
|
|
2760
|
+
}, dedupeNestedPaths = (paths)=>paths.sort((p1, p2)=>p2.length > p1.length ? -1 : 1).reduce((prev, curr)=>prev.find((p)=>curr.startsWith(p) || curr === p) ? prev : prev.concat(curr), []), toPosixPath = (filepath)=>'/' === sep ? filepath : filepath.replace(/\\/g, '/'), normalizeRuleConditionPath = (filepath)=>isWindows && 'string' == typeof filepath && filepath.includes('/') && win32.isAbsolute(filepath) ? filepath.replace(/\//g, '\\') : filepath, isFileSync = (filePath)=>{
|
|
2847
2761
|
try {
|
|
2848
|
-
return
|
|
2762
|
+
return node_fs.statSync(filePath, {
|
|
2849
2763
|
throwIfNoEntry: !1
|
|
2850
2764
|
})?.isFile();
|
|
2851
2765
|
} catch (_) {
|
|
@@ -2853,7 +2767,7 @@ let getCompiledPath = (packageName)=>(0, external_node_path_.join)(COMPILED_PATH
|
|
|
2853
2767
|
}
|
|
2854
2768
|
};
|
|
2855
2769
|
function isEmptyDir(path) {
|
|
2856
|
-
let files =
|
|
2770
|
+
let files = node_fs.readdirSync(path);
|
|
2857
2771
|
return 0 === files.length || 1 === files.length && '.git' === files[0];
|
|
2858
2772
|
}
|
|
2859
2773
|
let findExists = (files)=>{
|
|
@@ -2861,10 +2775,10 @@ let findExists = (files)=>{
|
|
|
2861
2775
|
return !1;
|
|
2862
2776
|
};
|
|
2863
2777
|
async function pathExists(path) {
|
|
2864
|
-
return
|
|
2778
|
+
return node_fs.promises.access(path).then(()=>!0).catch(()=>!1);
|
|
2865
2779
|
}
|
|
2866
2780
|
async function isFileExists(file) {
|
|
2867
|
-
return
|
|
2781
|
+
return node_fs.promises.access(file, node_fs.constants.F_OK).then(()=>!0).catch(()=>!1);
|
|
2868
2782
|
}
|
|
2869
2783
|
async function fileExistsByCompilation({ inputFileSystem }, filePath) {
|
|
2870
2784
|
return new Promise((resolve)=>{
|
|
@@ -2882,16 +2796,16 @@ function readFileAsync(fs, filename) {
|
|
|
2882
2796
|
}
|
|
2883
2797
|
async function emptyDir(dir, keep = [], checkExists = !0) {
|
|
2884
2798
|
if (!checkExists || await pathExists(dir)) try {
|
|
2885
|
-
let entries = await
|
|
2799
|
+
let entries = await node_fs.promises.readdir(dir, {
|
|
2886
2800
|
withFileTypes: !0
|
|
2887
2801
|
});
|
|
2888
2802
|
await Promise.all(entries.map(async (entry)=>{
|
|
2889
|
-
let fullPath =
|
|
2803
|
+
let fullPath = node_path.join(dir, entry.name);
|
|
2890
2804
|
if (keep.length) {
|
|
2891
2805
|
let posixFullPath = toPosixPath(fullPath);
|
|
2892
2806
|
if (keep.some((regex)=>regex.test(posixFullPath))) return;
|
|
2893
2807
|
}
|
|
2894
|
-
entry.isDirectory() ? (await emptyDir(fullPath, keep, !1), keep.length || await
|
|
2808
|
+
entry.isDirectory() ? (await emptyDir(fullPath, keep, !1), keep.length || await node_fs.promises.rmdir(fullPath)) : await node_fs.promises.unlink(fullPath);
|
|
2895
2809
|
}));
|
|
2896
2810
|
} catch (err) {
|
|
2897
2811
|
src_logger.debug(`failed to empty dir: ${dir}`), src_logger.debug(err);
|
|
@@ -3013,7 +2927,7 @@ let OVERRIDE_PATHS = new Set([
|
|
|
3013
2927
|
scriptLoading: 'defer',
|
|
3014
2928
|
implementation: 'js'
|
|
3015
2929
|
},
|
|
3016
|
-
resolve: (swcHelpersPath || (swcHelpersPath = (
|
|
2930
|
+
resolve: (swcHelpersPath || (swcHelpersPath = external_node_path_dirname(vendors_require.resolve('@swc/helpers/package.json'))), {
|
|
3017
2931
|
alias: {
|
|
3018
2932
|
'@swc/helpers': swcHelpersPath
|
|
3019
2933
|
},
|
|
@@ -3110,7 +3024,7 @@ function getDefaultEntry(root) {
|
|
|
3110
3024
|
'cts',
|
|
3111
3025
|
'mjs',
|
|
3112
3026
|
'cjs'
|
|
3113
|
-
].map((ext)=>
|
|
3027
|
+
].map((ext)=>join(root, `src/index.${ext}`)));
|
|
3114
3028
|
return entryFile ? {
|
|
3115
3029
|
index: entryFile
|
|
3116
3030
|
} : {};
|
|
@@ -3121,7 +3035,7 @@ let withDefaultConfig = async (rootPath, userConfig)=>{
|
|
|
3121
3035
|
imports: !0,
|
|
3122
3036
|
entries: !1
|
|
3123
3037
|
}), !config.source.tsconfigPath) {
|
|
3124
|
-
let tsconfigPath =
|
|
3038
|
+
let tsconfigPath = join(rootPath, 'tsconfig.json');
|
|
3125
3039
|
await isFileExists(tsconfigPath) && (config.source.tsconfigPath = tsconfigPath);
|
|
3126
3040
|
}
|
|
3127
3041
|
return config;
|
|
@@ -3130,26 +3044,26 @@ function exit(exitCode, type) {
|
|
|
3130
3044
|
if (!isCalled) {
|
|
3131
3045
|
for (let callback of (isCalled = !0, exitHook_callbacks))callback(exitCode);
|
|
3132
3046
|
if ('SIGINT' === type) {
|
|
3133
|
-
let listeners =
|
|
3134
|
-
Array.isArray(listeners) && listeners.length <= 1 &&
|
|
3047
|
+
let listeners = node_process.listeners('SIGINT');
|
|
3048
|
+
Array.isArray(listeners) && listeners.length <= 1 && node_process.exit(exitCode);
|
|
3135
3049
|
}
|
|
3136
3050
|
}
|
|
3137
3051
|
}
|
|
3138
3052
|
function exitHook(onExit) {
|
|
3139
|
-
return exitHook_callbacks.add(onExit), isRegistered || (isRegistered = !0,
|
|
3140
|
-
exit(
|
|
3141
|
-
}),
|
|
3142
|
-
exit(
|
|
3143
|
-
}),
|
|
3053
|
+
return exitHook_callbacks.add(onExit), isRegistered || (isRegistered = !0, node_process.on('SIGINT', ()=>{
|
|
3054
|
+
exit(external_node_os_constants.signals.SIGINT + 128, 'SIGINT');
|
|
3055
|
+
}), node_process.once('SIGTERM', ()=>{
|
|
3056
|
+
exit(external_node_os_constants.signals.SIGTERM + 128, 'SIGTERM');
|
|
3057
|
+
}), node_process.once('exit', (exitCode)=>{
|
|
3144
3058
|
exit(exitCode, 'exit');
|
|
3145
3059
|
})), ()=>{
|
|
3146
3060
|
exitHook_callbacks.delete(onExit);
|
|
3147
3061
|
};
|
|
3148
3062
|
}
|
|
3149
|
-
let
|
|
3063
|
+
let addTrailingSlash = (s)=>s.endsWith('/') ? s : `${s}/`, isURL = (str)=>str.startsWith('http') || str.startsWith('//'), urlJoin = (base, path)=>{
|
|
3150
3064
|
let [urlProtocol, baseUrl] = base.split('://');
|
|
3151
|
-
return `${urlProtocol}://${
|
|
3152
|
-
}, ensureAssetPrefix = (url, assetPrefix = DEFAULT_ASSET_PREFIX)=>url.startsWith('//') ||
|
|
3065
|
+
return `${urlProtocol}://${posix.join(baseUrl, path)}`;
|
|
3066
|
+
}, ensureAssetPrefix = (url, assetPrefix = DEFAULT_ASSET_PREFIX)=>url.startsWith('//') || external_node_url_URL.canParse(url) || 'auto' === assetPrefix || 'function' == typeof assetPrefix ? url : assetPrefix.startsWith('http') ? urlJoin(assetPrefix, url) : assetPrefix.startsWith('//') ? urlJoin(`https:${assetPrefix}`, url).replace('https:', '') : posix.join(assetPrefix, url), formatPublicPath = (publicPath, withSlash = !0)=>'auto' === publicPath || '' === publicPath ? publicPath : withSlash ? addTrailingSlash(publicPath) : publicPath.replace(/\/+$/, ''), getPublicPathFromChain = (chain, withSlash = !0)=>{
|
|
3153
3067
|
let publicPath = chain.output.get('publicPath');
|
|
3154
3068
|
return 'string' == typeof publicPath ? formatPublicPath(publicPath, withSlash) : formatPublicPath(DEFAULT_ASSET_PREFIX, withSlash);
|
|
3155
3069
|
};
|
|
@@ -3272,7 +3186,7 @@ async function initPlugins({ context, pluginManager }) {
|
|
|
3272
3186
|
}
|
|
3273
3187
|
function getHTMLPathByEntry(entryName, config) {
|
|
3274
3188
|
let filename = getFilename(config, 'html').replace('[name]', entryName), prefix = config.output.distPath.html;
|
|
3275
|
-
return prefix.startsWith('/') && src_logger.warn(`${color.dim('[rsbuild:config]')} Absolute path is not recommended at ${color.yellow(`output.distPath.html: "${prefix}"`)}, use relative path instead.`),
|
|
3189
|
+
return prefix.startsWith('/') && src_logger.warn(`${color.dim('[rsbuild:config]')} Absolute path is not recommended at ${color.yellow(`output.distPath.html: "${prefix}"`)}, use relative path instead.`), posix.join(prefix, filename).replace(/^\/+/, '');
|
|
3276
3190
|
}
|
|
3277
3191
|
let mapProcessAssetsStage = (stage)=>{
|
|
3278
3192
|
let { Compilation } = core_rspack;
|
|
@@ -3390,7 +3304,7 @@ function initPluginAPI({ context, pluginManager }) {
|
|
|
3390
3304
|
if (descriptor.targets && !descriptor.targets.includes(target) || descriptor.environments && !descriptor.environments.includes(environmentContext.name)) return;
|
|
3391
3305
|
let rule = chain.module.rule(id);
|
|
3392
3306
|
descriptor.test && rule.test(descriptor.test), descriptor.resourceQuery && rule.resourceQuery(descriptor.resourceQuery), descriptor.layer && rule.layer(descriptor.layer), descriptor.issuerLayer && rule.issuerLayer(descriptor.issuerLayer), descriptor.issuer && rule.issuer(descriptor.issuer), descriptor.with && rule.with(descriptor.with), descriptor.mimetype && rule.mimetype(descriptor.mimetype), descriptor.order && 'default' !== descriptor.order ? rule.enforce(descriptor.order) : descriptor.enforce && rule.enforce(descriptor.enforce);
|
|
3393
|
-
let
|
|
3307
|
+
let loaderPath = join(dirname, descriptor.raw ? 'transformRawLoader.mjs' : 'transformLoader.mjs');
|
|
3394
3308
|
rule.use(id).loader(loaderPath).options({
|
|
3395
3309
|
id,
|
|
3396
3310
|
getEnvironment: ()=>environmentContext
|
|
@@ -3542,9 +3456,9 @@ function createPublicContext(context) {
|
|
|
3542
3456
|
});
|
|
3543
3457
|
}
|
|
3544
3458
|
async function createContext(options, userConfig) {
|
|
3545
|
-
let { cwd } = options, rootPath = userConfig.root ? ensureAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath =
|
|
3459
|
+
let { cwd } = options, rootPath = userConfig.root ? ensureAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = join(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0;
|
|
3546
3460
|
return {
|
|
3547
|
-
version: "2.0.0-beta.
|
|
3461
|
+
version: "2.0.0-beta.8",
|
|
3548
3462
|
rootPath,
|
|
3549
3463
|
distPath: '',
|
|
3550
3464
|
cachePath,
|
|
@@ -3579,28 +3493,28 @@ async function emitConfigFiles({ bundlerConfigs, environmentConfigs, extraConfig
|
|
|
3579
3493
|
...environmentConfigs.map(({ name, content })=>{
|
|
3580
3494
|
let outputFile = isSingle ? 'rsbuild.config.mjs' : `rsbuild.config.${name}.mjs`, label = isSingle ? 'Rsbuild config' : `Rsbuild config (${name})`;
|
|
3581
3495
|
return {
|
|
3582
|
-
path:
|
|
3496
|
+
path: join(outputPath, outputFile),
|
|
3583
3497
|
label,
|
|
3584
3498
|
content
|
|
3585
3499
|
};
|
|
3586
3500
|
}),
|
|
3587
3501
|
...bundlerConfigs.map(({ name, content })=>{
|
|
3588
|
-
let
|
|
3589
|
-
return
|
|
3502
|
+
let outputFilePath = join(outputPath, `rspack.config.${name}.mjs`);
|
|
3503
|
+
return node_fs.existsSync(outputFilePath) && (outputFilePath = outputFilePath.replace(/\.mjs$/, `.${Date.now()}.mjs`)), {
|
|
3590
3504
|
path: outputFilePath,
|
|
3591
3505
|
label: `Rspack Config (${name})`,
|
|
3592
3506
|
content
|
|
3593
3507
|
};
|
|
3594
3508
|
}),
|
|
3595
3509
|
...(extraConfigs || []).map(({ name, content })=>({
|
|
3596
|
-
path:
|
|
3510
|
+
path: join(outputPath, `${name}.config.mjs`),
|
|
3597
3511
|
label: `${upperFirst(name)} Config`,
|
|
3598
3512
|
content
|
|
3599
3513
|
}))
|
|
3600
3514
|
];
|
|
3601
|
-
await
|
|
3515
|
+
await node_fs.promises.mkdir(outputPath, {
|
|
3602
3516
|
recursive: !0
|
|
3603
|
-
}), await Promise.all(files.map(async (item)=>
|
|
3517
|
+
}), await Promise.all(files.map(async (item)=>node_fs.promises.writeFile(item.path, `export default ${item.content}`)));
|
|
3604
3518
|
let fileInfos = files.map((item)=>` - ${color.bold(color.yellow(item.label))}: ${color.underline(item.path)}`).join('\n');
|
|
3605
3519
|
src_logger.success(`config inspection completed, generated files: \n\n${fileInfos}\n`);
|
|
3606
3520
|
}
|
|
@@ -3632,7 +3546,7 @@ async function inspectConfig_inspectConfig({ context, pluginManager, bundlerConf
|
|
|
3632
3546
|
}
|
|
3633
3547
|
let outputPath = ((context, inspectOptions)=>{
|
|
3634
3548
|
let { outputPath } = inspectOptions;
|
|
3635
|
-
return outputPath ? (
|
|
3549
|
+
return outputPath ? external_node_path_isAbsolute(outputPath) ? outputPath : join(context.distPath, outputPath) : join(context.distPath, RSBUILD_OUTPUTS_PATH);
|
|
3636
3550
|
})(context, inspectOptions), stringifiedExtraConfigs = inspectOptions.extraConfigs ? Object.entries(inspectOptions.extraConfigs).map(([name, content])=>({
|
|
3637
3551
|
name,
|
|
3638
3552
|
content: 'string' == typeof content ? content : stringifyConfig(content, inspectOptions.verbose)
|
|
@@ -3907,7 +3821,7 @@ async function initRsbuildConfig({ context, pluginManager }) {
|
|
|
3907
3821
|
let normalizedBaseConfig = (config = context.config, rootPath = context.rootPath, config.server ||= {}, config.server.host = 'string' == typeof (host = config.server.host) ? host : !0 === host ? ALL_INTERFACES_IPV4 : LOCALHOST, config.server.publicDir = ((rootPath, publicDir)=>{
|
|
3908
3822
|
if (!1 === publicDir) return [];
|
|
3909
3823
|
let defaultConfig = {
|
|
3910
|
-
name:
|
|
3824
|
+
name: join(rootPath, 'public'),
|
|
3911
3825
|
copyOnBuild: 'auto',
|
|
3912
3826
|
watch: !1,
|
|
3913
3827
|
ignore: []
|
|
@@ -3921,7 +3835,7 @@ async function initRsbuildConfig({ context, pluginManager }) {
|
|
|
3921
3835
|
...defaultConfig,
|
|
3922
3836
|
...options
|
|
3923
3837
|
};
|
|
3924
|
-
return (
|
|
3838
|
+
return external_node_path_isAbsolute(merged.name) || (merged.name = join(rootPath, merged.name)), merged;
|
|
3925
3839
|
};
|
|
3926
3840
|
return Array.isArray(publicDir) ? publicDir.map((options)=>mergeWithDefault(options)) : [
|
|
3927
3841
|
mergeWithDefault(publicDir)
|
|
@@ -4026,13 +3940,13 @@ async function initConfigs_initConfigs({ context, pluginManager, rsbuildOptions
|
|
|
4026
3940
|
};
|
|
4027
3941
|
}
|
|
4028
3942
|
function cutPath(originalFilePath, root) {
|
|
4029
|
-
let prefix = root.endsWith(
|
|
3943
|
+
let prefix = root.endsWith(sep) ? root : root + sep, filePath = originalFilePath;
|
|
4030
3944
|
filePath.startsWith(prefix) && (filePath = filePath.slice(prefix.length));
|
|
4031
|
-
let parts = filePath.split(
|
|
4032
|
-
return parts.length > 3 ? parts.slice(-3).join(
|
|
3945
|
+
let parts = filePath.split(sep).filter(Boolean);
|
|
3946
|
+
return parts.length > 3 ? parts.slice(-3).join(sep) : parts.join(sep);
|
|
4033
3947
|
}
|
|
4034
3948
|
function isLikelyFile(filePath) {
|
|
4035
|
-
return (filePath.split(
|
|
3949
|
+
return (filePath.split(sep).pop() || '').includes('.');
|
|
4036
3950
|
}
|
|
4037
3951
|
function formatFileList(paths, rootPath) {
|
|
4038
3952
|
let files = paths.filter(isLikelyFile);
|
|
@@ -4299,8 +4213,8 @@ function loadEnv({ cwd = process.cwd(), mode = process.env.NODE_ENV || '', prefi
|
|
|
4299
4213
|
'.env.local',
|
|
4300
4214
|
`.env.${mode}`,
|
|
4301
4215
|
`.env.${mode}.local`
|
|
4302
|
-
].map((filename)=>
|
|
4303
|
-
for (let envPath of filePaths)Object.assign(parsed, loadEnv_parse(
|
|
4216
|
+
].map((filename)=>join(cwd, filename)).filter(isFileSync), parsed = {};
|
|
4217
|
+
for (let envPath of filePaths)Object.assign(parsed, loadEnv_parse(node_fs.readFileSync(envPath))), src_logger.debug('loaded env file:', envPath);
|
|
4304
4218
|
parsed.NODE_ENV && (processEnv.NODE_ENV = parsed.NODE_ENV), (0, main.expand)({
|
|
4305
4219
|
parsed,
|
|
4306
4220
|
processEnv
|
|
@@ -4344,10 +4258,10 @@ function getRegExpForExts(exts) {
|
|
|
4344
4258
|
return RegExp(1 === normalizedExts.length ? `\\.${matcher}$` : `\\.(?:${matcher})$`, 'i');
|
|
4345
4259
|
}
|
|
4346
4260
|
function getCacheDirectory({ cacheDirectory }, context) {
|
|
4347
|
-
return cacheDirectory ? (
|
|
4261
|
+
return cacheDirectory ? external_node_path_isAbsolute(cacheDirectory) ? cacheDirectory : join(context.rootPath, cacheDirectory) : join(context.cachePath, 'rspack');
|
|
4348
4262
|
}
|
|
4349
4263
|
async function getBuildDependencies(context, config, environmentContext, additionalDependencies) {
|
|
4350
|
-
let rootPackageJson =
|
|
4264
|
+
let rootPackageJson = join(context.rootPath, 'package.json'), browserslistConfig = join(context.rootPath, '.browserslistrc'), buildDependencies = {};
|
|
4351
4265
|
await isFileExists(rootPackageJson) && (buildDependencies.packageJson = [
|
|
4352
4266
|
rootPackageJson
|
|
4353
4267
|
]);
|
|
@@ -4364,12 +4278,12 @@ async function getBuildDependencies(context, config, environmentContext, additio
|
|
|
4364
4278
|
'js',
|
|
4365
4279
|
'cjs',
|
|
4366
4280
|
'mjs'
|
|
4367
|
-
].map((ext)=>
|
|
4281
|
+
].map((ext)=>join(context.rootPath, `tailwind.config.${ext}`)));
|
|
4368
4282
|
return tailwindConfig && (buildDependencies.tailwindcss = [
|
|
4369
4283
|
tailwindConfig
|
|
4370
4284
|
]), additionalDependencies && (buildDependencies.additional = additionalDependencies), buildDependencies;
|
|
4371
4285
|
}
|
|
4372
|
-
let addTrailingSep = (dir)=>dir.endsWith(
|
|
4286
|
+
let addTrailingSep = (dir)=>dir.endsWith(sep) ? dir : dir + sep, isStrictSubdir = (parent, child)=>{
|
|
4373
4287
|
let parentDir = addTrailingSep(parent), childDir = addTrailingSep(child);
|
|
4374
4288
|
return parentDir !== childDir && childDir.startsWith(parentDir);
|
|
4375
4289
|
}, normalizeCleanDistPath = (userOptions)=>{
|
|
@@ -4425,8 +4339,8 @@ function parseMinifyOptions(config) {
|
|
|
4425
4339
|
cssOptions: minify.cssOptions
|
|
4426
4340
|
};
|
|
4427
4341
|
}
|
|
4428
|
-
let
|
|
4429
|
-
var
|
|
4342
|
+
let postcss_load_config_src = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.8_yaml@2.8.2/node_modules/postcss-load-config/src/index.js");
|
|
4343
|
+
var postcss_load_config_src_default = __webpack_require__.n(postcss_load_config_src);
|
|
4430
4344
|
function getLightningCSSLoaderOptions(config, targets, minify) {
|
|
4431
4345
|
let userOptions = 'object' == typeof config.tools.lightningcssLoader ? config.tools.lightningcssLoader : {}, initialOptions = {
|
|
4432
4346
|
targets,
|
|
@@ -4449,7 +4363,7 @@ let clonePostCSSConfig = (config)=>({
|
|
|
4449
4363
|
async function loadUserPostcssrc(root, postcssrcCache) {
|
|
4450
4364
|
let cached = postcssrcCache.get(root);
|
|
4451
4365
|
if (cached) return clonePostCSSConfig(await cached);
|
|
4452
|
-
let promise =
|
|
4366
|
+
let promise = postcss_load_config_src_default()({}, root).catch((err)=>{
|
|
4453
4367
|
if (err.message?.includes('No PostCSS Config found')) return {};
|
|
4454
4368
|
throw err;
|
|
4455
4369
|
});
|
|
@@ -4460,7 +4374,7 @@ let getPostcssLoaderOptions = async ({ config, root, postcssrcCache })=>{
|
|
|
4460
4374
|
userOptions.plugins ||= [];
|
|
4461
4375
|
let finalOptions = reduceConfigsWithContext({
|
|
4462
4376
|
initial: {
|
|
4463
|
-
implementation:
|
|
4377
|
+
implementation: join(COMPILED_PATH, 'postcss', 'index.js'),
|
|
4464
4378
|
postcssOptions: userOptions,
|
|
4465
4379
|
sourceMap: getCSSSourceMap(config)
|
|
4466
4380
|
},
|
|
@@ -4528,14 +4442,14 @@ async function gzipSize(input) {
|
|
|
4528
4442
|
return Buffer.byteLength(data);
|
|
4529
4443
|
}
|
|
4530
4444
|
function getSnapshotPath(dir, snapshotHash) {
|
|
4531
|
-
return snapshotHash ?
|
|
4445
|
+
return snapshotHash ? node_path.join(dir, `rsbuild/file-sizes-${snapshotHash}.json`) : node_path.join(dir, 'rsbuild/file-sizes.json');
|
|
4532
4446
|
}
|
|
4533
4447
|
function normalizeFilePath(filePath) {
|
|
4534
4448
|
return filePath.replace(/\.[a-f0-9]{8,}\./g, '.');
|
|
4535
4449
|
}
|
|
4536
4450
|
async function loadPrevSnapshots(snapshotPath) {
|
|
4537
4451
|
try {
|
|
4538
|
-
let content = await
|
|
4452
|
+
let content = await node_fs.promises.readFile(snapshotPath, 'utf-8');
|
|
4539
4453
|
return JSON.parse(content);
|
|
4540
4454
|
} catch {
|
|
4541
4455
|
return null;
|
|
@@ -4543,9 +4457,9 @@ async function loadPrevSnapshots(snapshotPath) {
|
|
|
4543
4457
|
}
|
|
4544
4458
|
async function saveSnapshots(snapshotPath, snapshots) {
|
|
4545
4459
|
try {
|
|
4546
|
-
await
|
|
4460
|
+
await node_fs.promises.mkdir(node_path.dirname(snapshotPath), {
|
|
4547
4461
|
recursive: !0
|
|
4548
|
-
}), await
|
|
4462
|
+
}), await node_fs.promises.writeFile(snapshotPath, JSON.stringify(snapshots, null, 2));
|
|
4549
4463
|
} catch (err) {
|
|
4550
4464
|
src_logger.debug('Failed to save file size snapshots:', err);
|
|
4551
4465
|
}
|
|
@@ -4581,7 +4495,7 @@ async function printFileSizes(options, stats, rootPath, distPath, environmentNam
|
|
|
4581
4495
|
if (!showTotal && !showDetail) return {
|
|
4582
4496
|
logs
|
|
4583
4497
|
};
|
|
4584
|
-
let relativeDistPath =
|
|
4498
|
+
let relativeDistPath = node_path.relative(rootPath, distPath), snapshot = {
|
|
4585
4499
|
files: {},
|
|
4586
4500
|
totalSize: 0,
|
|
4587
4501
|
totalGzipSize: 0
|
|
@@ -4603,7 +4517,7 @@ async function printFileSizes(options, stats, rootPath, distPath, environmentNam
|
|
|
4603
4517
|
isSignificantDiff(gzipDiff) && (gzipSizeLabel += ` ${formatDiff(gzipDiff).label}`);
|
|
4604
4518
|
}
|
|
4605
4519
|
}
|
|
4606
|
-
let folder =
|
|
4520
|
+
let folder = node_path.join(relativeDistPath, node_path.dirname(filePath)), filename = node_path.basename(filePath), filenameLabel = color.dim(folder + node_path.sep) + (JS_REGEX.test(filename) ? color.cyan(filename) : filename.endsWith('.css') ? color.yellow(filename) : filename.endsWith('.html') ? color.green(filename) : color.magenta(filename)), filenameLength = (folder + node_path.sep + filename).length;
|
|
4607
4521
|
return {
|
|
4608
4522
|
filePath,
|
|
4609
4523
|
filename,
|
|
@@ -4621,7 +4535,7 @@ async function printFileSizes(options, stats, rootPath, distPath, environmentNam
|
|
|
4621
4535
|
try {
|
|
4622
4536
|
content = value.source();
|
|
4623
4537
|
} catch {
|
|
4624
|
-
content =
|
|
4538
|
+
content = node_fs.readFileSync(node_path.join(distPath, filePath));
|
|
4625
4539
|
}
|
|
4626
4540
|
return {
|
|
4627
4541
|
filePath,
|
|
@@ -4772,17 +4686,17 @@ class RsbuildHtmlPlugin {
|
|
|
4772
4686
|
}
|
|
4773
4687
|
apply(compiler) {
|
|
4774
4688
|
let emitFavicon = async ({ compilation, favicon, faviconDistPath })=>{
|
|
4775
|
-
let fileContent, name =
|
|
4689
|
+
let fileContent, name = node_path.basename(favicon);
|
|
4776
4690
|
if (compilation.assets[name]) return name;
|
|
4777
4691
|
let inputFs = compilation.inputFileSystem;
|
|
4778
4692
|
if (!inputFs) return addCompilationError(compilation, `${color.dim('[rsbuild:html]')} Failed to read the favicon file as ${color.yellow('compilation.inputFileSystem')} is not available.`), null;
|
|
4779
|
-
let inputFilename =
|
|
4693
|
+
let inputFilename = node_path.isAbsolute(favicon) ? favicon : node_path.join(compilation.compiler.context, favicon);
|
|
4780
4694
|
try {
|
|
4781
4695
|
fileContent = await readFileAsync(inputFs, inputFilename);
|
|
4782
4696
|
} catch (error) {
|
|
4783
4697
|
return src_logger.debug(`read favicon error: ${error}`), addCompilationError(compilation, `${color.dim('[rsbuild:html]')} Failed to read the favicon file at ${color.yellow(inputFilename)}.`), null;
|
|
4784
4698
|
}
|
|
4785
|
-
let source = new core_rspack.sources.RawSource(fileContent, !1), outputFilename =
|
|
4699
|
+
let source = new core_rspack.sources.RawSource(fileContent, !1), outputFilename = node_path.posix.join(faviconDistPath, name);
|
|
4786
4700
|
return compilation.emitAsset(outputFilename, source), outputFilename;
|
|
4787
4701
|
}, addFavicon = async ({ headTags, favicon, faviconDistPath, compilation, publicPath })=>{
|
|
4788
4702
|
let href = favicon;
|
|
@@ -4941,12 +4855,12 @@ async function getTemplate(entryName, config, rootPath) {
|
|
|
4941
4855
|
templateContent: (mountId = config.html.mountId, `<!DOCTYPE html><html><head></head><body><div id="${mountId}"></div></body></html>`)
|
|
4942
4856
|
};
|
|
4943
4857
|
}
|
|
4944
|
-
let absolutePath = (
|
|
4858
|
+
let absolutePath = external_node_path_isAbsolute(templatePath) ? templatePath : node_path.join(rootPath, templatePath);
|
|
4945
4859
|
if (!existTemplatePath.has(absolutePath)) {
|
|
4946
4860
|
if (!await isFileExists(absolutePath)) throw Error(`${color.dim('[rsbuild:html]')} Failed to resolve HTML template, check if the file exists: ${color.yellow(absolutePath)}`);
|
|
4947
4861
|
existTemplatePath.add(absolutePath);
|
|
4948
4862
|
}
|
|
4949
|
-
let templateContent = await
|
|
4863
|
+
let templateContent = await node_fs.promises.readFile(absolutePath, 'utf-8');
|
|
4950
4864
|
return {
|
|
4951
4865
|
templatePath: absolutePath,
|
|
4952
4866
|
templateContent
|
|
@@ -5035,7 +4949,7 @@ let normalizeUrl = (url)=>url.replace(/([^:]\/)\/+/g, '$1'), joinUrlSegments = (
|
|
|
5035
4949
|
if (0 === environmentWithHtml.length) return [];
|
|
5036
4950
|
let commonDistPath = getCommonParentPath(environmentWithHtml.map((item)=>item.distPath));
|
|
5037
4951
|
return environmentWithHtml.reduce((prev, environmentContext)=>{
|
|
5038
|
-
let { distPath, config } = environmentContext, distPrefix =
|
|
4952
|
+
let { distPath, config } = environmentContext, distPrefix = relative(commonDistPath, distPath).split(sep).join('/'), routes = formatRoutes(environmentContext.htmlPaths, context.normalizedConfig.server.base, posix.join(distPrefix, config.output.distPath.html), config.html.outputStructure);
|
|
5039
4953
|
return prev.concat(...routes);
|
|
5040
4954
|
}, []);
|
|
5041
4955
|
}, formatRoutes = (entry, base, distPathPrefix, outputStructure)=>{
|
|
@@ -5150,7 +5064,7 @@ let getPort = async ({ host, port, strictPort, tryLimits = 20 })=>{
|
|
|
5150
5064
|
];
|
|
5151
5065
|
}
|
|
5152
5066
|
let ipv4Interfaces = (()=>{
|
|
5153
|
-
let interfaces =
|
|
5067
|
+
let interfaces = node_os.networkInterfaces(), ipv4Interfaces = new Map();
|
|
5154
5068
|
for (let key of Object.keys(interfaces))for (let detail of interfaces[key]){
|
|
5155
5069
|
let familyV4Value = 'string' == typeof detail.family ? 'IPv4' : 4;
|
|
5156
5070
|
detail.family !== familyV4Value || ipv4Interfaces.has(detail.address) || ipv4Interfaces.set(detail.address, detail);
|
|
@@ -5222,10 +5136,7 @@ async function openBrowser(url) {
|
|
|
5222
5136
|
src_logger.debug("failed to open start URL with apple script."), src_logger.debug(err);
|
|
5223
5137
|
}
|
|
5224
5138
|
}
|
|
5225
|
-
let { apps, default: baseOpen } = await import("./open.js")
|
|
5226
|
-
apps: mod.open_apps,
|
|
5227
|
-
default: mod.node_modules_open
|
|
5228
|
-
}));
|
|
5139
|
+
let { apps, default: baseOpen } = await import("./open.js");
|
|
5229
5140
|
try {
|
|
5230
5141
|
let options = browser ? {
|
|
5231
5142
|
app: {
|
|
@@ -5242,9 +5153,9 @@ async function openBrowser(url) {
|
|
|
5242
5153
|
}
|
|
5243
5154
|
let openedURLs = [], replacePortPlaceholder = (url, port)=>url.replace(/<port>/g, String(port));
|
|
5244
5155
|
function resolveUrl(str, base) {
|
|
5245
|
-
if (
|
|
5156
|
+
if (external_node_url_URL.canParse(str)) return str;
|
|
5246
5157
|
try {
|
|
5247
|
-
return new
|
|
5158
|
+
return new external_node_url_URL(str, base).href;
|
|
5248
5159
|
} catch {
|
|
5249
5160
|
throw Error(`${color.dim('[rsbuild:open]')} Invalid input: ${color.yellow(str)} is not a valid URL or pathname`);
|
|
5250
5161
|
}
|
|
@@ -5355,7 +5266,7 @@ function applyAlias({ chain, config, rootPath }) {
|
|
|
5355
5266
|
continue;
|
|
5356
5267
|
}
|
|
5357
5268
|
try {
|
|
5358
|
-
pkgPath = (
|
|
5269
|
+
pkgPath = external_node_path_dirname(vendors_require.resolve(`${pkgName}/package.json`, {
|
|
5359
5270
|
paths: [
|
|
5360
5271
|
rootPath
|
|
5361
5272
|
]
|
|
@@ -5370,8 +5281,8 @@ function applyAlias({ chain, config, rootPath }) {
|
|
|
5370
5281
|
let trailing = [
|
|
5371
5282
|
'node_modules',
|
|
5372
5283
|
...pkgName.split('/')
|
|
5373
|
-
].join(
|
|
5374
|
-
for(; !pkgPath.endsWith(trailing) && pkgPath.includes('node_modules');)pkgPath = (
|
|
5284
|
+
].join(sep);
|
|
5285
|
+
for(; !pkgPath.endsWith(trailing) && pkgPath.includes('node_modules');)pkgPath = external_node_path_dirname(pkgPath);
|
|
5375
5286
|
} catch {
|
|
5376
5287
|
src_logger.debug(`${color.dim('[rsbuild:resolve]')} The package ${color.yellow(pkgName)} is not resolved in the project, dedupe option for ${color.yellow(pkgName)} will be ignored.`);
|
|
5377
5288
|
continue;
|
|
@@ -5406,7 +5317,7 @@ function extractChunks(compilation, includeType) {
|
|
|
5406
5317
|
return chunks;
|
|
5407
5318
|
}
|
|
5408
5319
|
function getResourceType({ href, file }) {
|
|
5409
|
-
let url = new
|
|
5320
|
+
let url = new external_node_url_URL(file || href, 'https://example.com'), extension = node_path.extname(url.pathname).slice(1);
|
|
5410
5321
|
return [
|
|
5411
5322
|
'css'
|
|
5412
5323
|
].includes(extension) ? 'style' : IMAGE_EXTENSIONS.includes(extension) ? 'image' : VIDEO_EXTENSIONS.includes(extension) ? 'video' : AUDIO_EXTENSIONS.includes(extension) ? 'audio' : FONT_EXTENSIONS.includes(extension) ? 'font' : [
|
|
@@ -5497,15 +5408,15 @@ function resolveLayer(value) {
|
|
|
5497
5408
|
return "OVERVIEW" === value ? 'info' : "ALL" === value ? 'trace' : value;
|
|
5498
5409
|
}
|
|
5499
5410
|
async function ensureFileDir(outputFilePath) {
|
|
5500
|
-
let dir =
|
|
5501
|
-
await
|
|
5411
|
+
let dir = node_path.dirname(outputFilePath);
|
|
5412
|
+
await node_fs.promises.mkdir(dir, {
|
|
5502
5413
|
recursive: !0
|
|
5503
5414
|
});
|
|
5504
5415
|
}
|
|
5505
5416
|
async function applyProfile(root, filterValue, traceLayer = 'perfetto', traceOutput) {
|
|
5506
5417
|
if ('perfetto' !== traceLayer && 'logger' !== traceLayer) throw Error(`unsupported trace layer: ${traceLayer}`);
|
|
5507
5418
|
if (!traceOutput) {
|
|
5508
|
-
let timestamp = Date.now(), defaultOutputDir =
|
|
5419
|
+
let timestamp = Date.now(), defaultOutputDir = node_path.join(root, `.rspack-profile-${timestamp}-${process.pid}`), defaultRustTracePerfettoOutput = node_path.join(defaultOutputDir, 'rspack.pftrace');
|
|
5509
5420
|
traceOutput = 'perfetto' === traceLayer ? defaultRustTracePerfettoOutput : 'stdout';
|
|
5510
5421
|
}
|
|
5511
5422
|
let filter = resolveLayer(filterValue);
|
|
@@ -5718,12 +5629,12 @@ function applyCoreJs(swcConfig, polyfillMode, rootPath) {
|
|
|
5718
5629
|
}
|
|
5719
5630
|
})(rootPath), version = ((corejsPkgPath)=>{
|
|
5720
5631
|
try {
|
|
5721
|
-
let rawJson =
|
|
5632
|
+
let rawJson = node_fs.readFileSync(corejsPkgPath, 'utf-8'), { version } = JSON.parse(rawJson), [major, minor] = version.split('.');
|
|
5722
5633
|
return `${major}.${minor}`;
|
|
5723
5634
|
} catch {
|
|
5724
5635
|
return '3';
|
|
5725
5636
|
}
|
|
5726
|
-
})(coreJsPath), coreJsDir =
|
|
5637
|
+
})(coreJsPath), coreJsDir = node_path.dirname(coreJsPath);
|
|
5727
5638
|
return swcConfig.env.coreJs = version, 'usage' === polyfillMode && (swcConfig.env.shippedProposals = !0), coreJsDir;
|
|
5728
5639
|
}
|
|
5729
5640
|
function applyTransformImport(swcConfig, pluginImport) {
|
|
@@ -5783,7 +5694,7 @@ async function getFileFromUrl(url, outputFileSystem, context) {
|
|
|
5783
5694
|
if (pathname.includes('\0')) return {
|
|
5784
5695
|
errorCode: 400
|
|
5785
5696
|
};
|
|
5786
|
-
if (UP_PATH_REGEXP.test(
|
|
5697
|
+
if (UP_PATH_REGEXP.test(node_path.normalize(`./${pathname}`))) return {
|
|
5787
5698
|
errorCode: 403
|
|
5788
5699
|
};
|
|
5789
5700
|
let stat = async (filename)=>new Promise((resolve, reject)=>{
|
|
@@ -5793,9 +5704,9 @@ async function getFileFromUrl(url, outputFileSystem, context) {
|
|
|
5793
5704
|
}), { environmentList, publicPathnames } = context, distPaths = environmentList.map((env)=>env.distPath), possibleFilenames = new Set();
|
|
5794
5705
|
for (let [index, distPath] of distPaths.entries()){
|
|
5795
5706
|
let prefix = publicPathnames[index];
|
|
5796
|
-
prefix && '/' !== prefix && pathname.startsWith(prefix) && possibleFilenames.add(
|
|
5707
|
+
prefix && '/' !== prefix && pathname.startsWith(prefix) && possibleFilenames.add(node_path.join(distPath, pathname.slice(prefix.length)));
|
|
5797
5708
|
}
|
|
5798
|
-
for (let distPath of distPaths)possibleFilenames.add(
|
|
5709
|
+
for (let distPath of distPaths)possibleFilenames.add(node_path.join(distPath, pathname));
|
|
5799
5710
|
for (let filename of possibleFilenames){
|
|
5800
5711
|
let fsStats;
|
|
5801
5712
|
try {
|
|
@@ -5809,7 +5720,7 @@ async function getFileFromUrl(url, outputFileSystem, context) {
|
|
|
5809
5720
|
fsStats
|
|
5810
5721
|
};
|
|
5811
5722
|
if (fsStats.isDirectory()) {
|
|
5812
|
-
filename =
|
|
5723
|
+
filename = node_path.join(filename, 'index.html');
|
|
5813
5724
|
try {
|
|
5814
5725
|
fsStats = await stat(filename);
|
|
5815
5726
|
} catch {
|
|
@@ -5854,9 +5765,7 @@ function createReadStreamOrReadFileSync(filename, outputFileSystem, start, end)
|
|
|
5854
5765
|
};
|
|
5855
5766
|
}
|
|
5856
5767
|
async function getContentType(str) {
|
|
5857
|
-
let { lookup } = await import("./
|
|
5858
|
-
lookup: mod.lookup
|
|
5859
|
-
})), mime = lookup(str);
|
|
5768
|
+
let { lookup } = await import("./mrmime.js"), mime = lookup(str);
|
|
5860
5769
|
return !!mime && ((mime.startsWith('text/') || 'application/json' === mime || 'application/manifest+json' === mime) && (mime += '; charset=utf-8'), mime);
|
|
5861
5770
|
}
|
|
5862
5771
|
let BYTES_RANGE_REGEXP = /^ *bytes/i;
|
|
@@ -6059,26 +5968,26 @@ function createMiddleware(context, ready, outputFileSystem) {
|
|
|
6059
5968
|
}
|
|
6060
5969
|
async function setupOutputFileSystem(writeToDisk, compilers) {
|
|
6061
5970
|
if (!0 !== writeToDisk) {
|
|
6062
|
-
let { createFsFromVolume, Volume } = await import("./memfs.js").then(__webpack_require__.t.bind(__webpack_require__, "../../node_modules/.pnpm/memfs@4.56.
|
|
5971
|
+
let { createFsFromVolume, Volume } = await import("./memfs.js").then(__webpack_require__.t.bind(__webpack_require__, "../../node_modules/.pnpm/memfs@4.56.11_tslib@2.8.1/node_modules/memfs/lib/index.js", 23)), outputFileSystem = createFsFromVolume(new Volume());
|
|
6063
5972
|
for (let compiler of compilers)compiler.outputFileSystem = outputFileSystem;
|
|
6064
5973
|
}
|
|
6065
5974
|
let compiler = compilers.find((compiler)=>!!compiler.outputFileSystem);
|
|
6066
|
-
return compiler?.outputFileSystem ??
|
|
5975
|
+
return compiler?.outputFileSystem ?? node_fs;
|
|
6067
5976
|
}
|
|
6068
5977
|
function setupWriteToDisk(compilers, writeToDisk) {
|
|
6069
5978
|
for (let compiler of compilers)compiler.hooks.emit.tap('DevMiddleware', ()=>{
|
|
6070
5979
|
compiler.__hasRsbuildAssetEmittedCallback || (compiler.hooks.assetEmitted.tapAsync('DevMiddleware', (_file, info, callback)=>{
|
|
6071
5980
|
let { targetPath, content, compilation } = info;
|
|
6072
5981
|
if (!(!writeToDisk || 'function' != typeof writeToDisk || writeToDisk(targetPath, compilation.name))) return void callback();
|
|
6073
|
-
let dir =
|
|
6074
|
-
|
|
5982
|
+
let dir = node_path.dirname(targetPath), name = compiler.options.name ? `Child "${compiler.options.name}": ` : '';
|
|
5983
|
+
node_fs.mkdir(dir, {
|
|
6075
5984
|
recursive: !0
|
|
6076
5985
|
}, (mkdirError)=>{
|
|
6077
5986
|
if (mkdirError) {
|
|
6078
5987
|
src_logger.error(`[rsbuild:middleware] ${name}Unable to write "${dir}" directory to disk:\n${mkdirError.message}`), callback(mkdirError);
|
|
6079
5988
|
return;
|
|
6080
5989
|
}
|
|
6081
|
-
|
|
5990
|
+
node_fs.writeFile(targetPath, content, (writeFileError)=>{
|
|
6082
5991
|
if (writeFileError) {
|
|
6083
5992
|
src_logger.error(`[rsbuild:middleware] ${name}Unable to write "${targetPath}" asset to disk:\n${writeFileError.message}`), callback(writeFileError);
|
|
6084
5993
|
return;
|
|
@@ -6105,8 +6014,8 @@ function applyHMREntry({ config, compiler, token, resolvedHost, resolvedPort })
|
|
|
6105
6014
|
...config.dev.client
|
|
6106
6015
|
};
|
|
6107
6016
|
'<port>' === clientConfig.port && (clientConfig.port = resolvedPort);
|
|
6108
|
-
let hmrEntry = `import { init } from '${toPosixPath(
|
|
6109
|
-
${config.dev.client.overlay ? `import '${toPosixPath(
|
|
6017
|
+
let hmrEntry = `import { init } from '${toPosixPath(join(CLIENT_PATH, 'hmr.js'))}';
|
|
6018
|
+
${config.dev.client.overlay ? `import '${toPosixPath(join(CLIENT_PATH, 'overlay.js'))}';` : ''}
|
|
6110
6019
|
init(
|
|
6111
6020
|
'${token}',
|
|
6112
6021
|
${JSON.stringify(clientConfig)},
|
|
@@ -6278,10 +6187,7 @@ function parseNode(line) {
|
|
|
6278
6187
|
let isValidMethodName = (methodName)=>'<unknown>' !== methodName && !/[\\/]/.test(methodName), parseFrame = async (frame, fs, context, cachedTraceMap)=>{
|
|
6279
6188
|
let { file, column, lineNumber } = frame, sourceMapInfo = await getFileFromUrl(`${file}.map`, fs, context);
|
|
6280
6189
|
if (!sourceMapInfo || 'errorCode' in sourceMapInfo) return;
|
|
6281
|
-
let { TraceMap, originalPositionFor } = await import("./
|
|
6282
|
-
TraceMap: mod.TraceMap,
|
|
6283
|
-
originalPositionFor: mod.originalPositionFor
|
|
6284
|
-
})), sourceMapPath = sourceMapInfo.filename;
|
|
6190
|
+
let { TraceMap, originalPositionFor } = await import("./trace-mapping.js"), sourceMapPath = sourceMapInfo.filename;
|
|
6285
6191
|
try {
|
|
6286
6192
|
let tracer = cachedTraceMap.get(sourceMapPath);
|
|
6287
6193
|
if (!tracer) {
|
|
@@ -6314,8 +6220,8 @@ let isValidMethodName = (methodName)=>'<unknown>' !== methodName && !/[\\/]/.tes
|
|
|
6314
6220
|
if (!source) return;
|
|
6315
6221
|
let result = ((source, sourceMapPath, context)=>{
|
|
6316
6222
|
if (source.startsWith('webpack/runtime/')) return source;
|
|
6317
|
-
let absoluteSourcePath =
|
|
6318
|
-
return
|
|
6223
|
+
let absoluteSourcePath = node_path.isAbsolute(source) ? source : node_path.join(node_path.dirname(sourceMapPath), source);
|
|
6224
|
+
return node_path.relative(context.rootPath, absoluteSourcePath);
|
|
6319
6225
|
})(source, sourceMapPath, context);
|
|
6320
6226
|
return null !== line && (result += null === column ? `:${line}` : `:${line}:${column}`), result;
|
|
6321
6227
|
}, formatFrameLocation = (frame)=>{
|
|
@@ -6414,7 +6320,7 @@ function convertLinksInHtml(text, root) {
|
|
|
6414
6320
|
if (!file.startsWith('file://')) return file;
|
|
6415
6321
|
let windows = file.replace(FILE_URI_WINDOWS_RE, '$1');
|
|
6416
6322
|
return windows !== file ? windows : file.replace(FILE_URI_UNIX_RE, '');
|
|
6417
|
-
})(file)).includes('</span>') && !file.includes('<span'), filePath = hasClosingSpan ? file.replace('</span>', '') : file, isAbsolute =
|
|
6323
|
+
})(file)).includes('</span>') && !file.includes('<span'), filePath = hasClosingSpan ? file.replace('</span>', '') : file, isAbsolute = node_path.isAbsolute(filePath), absolutePath = root && !isAbsolute ? node_path.join(root, filePath) : filePath, displayPath = formatDisplayPath(filePath, isAbsolute, root);
|
|
6418
6324
|
return `<a class="file-link" data-file="${absolutePath}">${displayPath}</a>${hasClosingSpan ? '</span>' : ''}`;
|
|
6419
6325
|
});
|
|
6420
6326
|
return replacedLine.replace(URL_RE, (url)=>`<a class="url-link" href="${url}" target="_blank" rel="noopener noreferrer">${url}</a>`);
|
|
@@ -6456,10 +6362,10 @@ class SocketServer {
|
|
|
6456
6362
|
clearHeartbeatTimer() {
|
|
6457
6363
|
this.heartbeatTimer && (clearTimeout(this.heartbeatTimer), this.heartbeatTimer = null);
|
|
6458
6364
|
}
|
|
6459
|
-
prepare() {
|
|
6365
|
+
async prepare() {
|
|
6460
6366
|
this.clearHeartbeatTimer();
|
|
6461
|
-
let
|
|
6462
|
-
this.wsServer = new
|
|
6367
|
+
let { WebSocketServer } = await import("./ws.js");
|
|
6368
|
+
this.wsServer = new WebSocketServer({
|
|
6463
6369
|
noServer: !0,
|
|
6464
6370
|
path: this.options.client?.path
|
|
6465
6371
|
}), this.wsServer.on('error', (err)=>{
|
|
@@ -6614,12 +6520,12 @@ class BuildManager {
|
|
|
6614
6520
|
resolvedPort;
|
|
6615
6521
|
context;
|
|
6616
6522
|
constructor({ config, context, compiler, resolvedPort }){
|
|
6617
|
-
this.config = config, this.context = context, this.compiler = compiler, this.resolvedPort = resolvedPort, this.outputFileSystem =
|
|
6523
|
+
this.config = config, this.context = context, this.compiler = compiler, this.resolvedPort = resolvedPort, this.outputFileSystem = node_fs, this.socketServer = new SocketServer(context, config.dev, ()=>this.outputFileSystem), this.context.socketServer = this.socketServer;
|
|
6618
6524
|
}
|
|
6619
6525
|
async init() {
|
|
6620
|
-
await this.setupCompilationMiddleware(), this.socketServer.prepare();
|
|
6526
|
+
await this.setupCompilationMiddleware(), await this.socketServer.prepare();
|
|
6621
6527
|
let { compiler } = this;
|
|
6622
|
-
this.outputFileSystem = (compiler_isMultiCompiler(compiler) ? compiler.compilers[0].outputFileSystem : compiler.outputFileSystem) ||
|
|
6528
|
+
this.outputFileSystem = (compiler_isMultiCompiler(compiler) ? compiler.compilers[0].outputFileSystem : compiler.outputFileSystem) || node_fs;
|
|
6623
6529
|
}
|
|
6624
6530
|
watch() {
|
|
6625
6531
|
this.assetsMiddleware.watch();
|
|
@@ -6635,7 +6541,7 @@ class BuildManager {
|
|
|
6635
6541
|
});
|
|
6636
6542
|
});
|
|
6637
6543
|
}
|
|
6638
|
-
readFileSync = (fileName)=>'readFileSync' in this.outputFileSystem ? this.outputFileSystem.readFileSync(fileName, 'utf-8') :
|
|
6544
|
+
readFileSync = (fileName)=>'readFileSync' in this.outputFileSystem ? this.outputFileSystem.readFileSync(fileName, 'utf-8') : node_fs.readFileSync(fileName, 'utf-8');
|
|
6639
6545
|
async setupCompilationMiddleware() {
|
|
6640
6546
|
let { config, context } = this, middleware = await assets_middleware_assetsMiddleware({
|
|
6641
6547
|
config,
|
|
@@ -6786,7 +6692,7 @@ function historyApiFallback_historyApiFallbackMiddleware(options = {}) {
|
|
|
6786
6692
|
function parseReqUrl(req) {
|
|
6787
6693
|
let proto = req.headers['x-forwarded-proto'] || 'http', host = req.headers['x-forwarded-host'] || req.headers.host || LOCALHOST;
|
|
6788
6694
|
try {
|
|
6789
|
-
return new
|
|
6695
|
+
return new external_node_url_URL(req.url || '/', `${proto}://${host}`);
|
|
6790
6696
|
} catch {
|
|
6791
6697
|
return null;
|
|
6792
6698
|
}
|
|
@@ -6975,10 +6881,10 @@ let applyDefaultMiddlewares = async ({ config, buildManager, context, devServer,
|
|
|
6975
6881
|
});
|
|
6976
6882
|
};
|
|
6977
6883
|
if (pathname.endsWith('/')) {
|
|
6978
|
-
let newUrl = `${pathname}index.html`, filePath =
|
|
6884
|
+
let newUrl = `${pathname}index.html`, filePath = node_path.join(distPath, newUrl);
|
|
6979
6885
|
if (await middlewares_isFileExists(filePath, buildManager.outputFileSystem)) return void rewrite(newUrl);
|
|
6980
|
-
} else if (!
|
|
6981
|
-
let newUrl = `${pathname}.html`, filePath =
|
|
6886
|
+
} else if (!node_path.extname(pathname)) {
|
|
6887
|
+
let newUrl = `${pathname}.html`, filePath = node_path.join(distPath, newUrl);
|
|
6982
6888
|
if (await middlewares_isFileExists(filePath, buildManager.outputFileSystem)) return void rewrite(newUrl);
|
|
6983
6889
|
}
|
|
6984
6890
|
next();
|
|
@@ -6986,9 +6892,7 @@ let applyDefaultMiddlewares = async ({ config, buildManager, context, devServer,
|
|
|
6986
6892
|
buildManager,
|
|
6987
6893
|
distPath: context.distPath
|
|
6988
6894
|
})), server.publicDir.length) {
|
|
6989
|
-
let { default: sirv } = await import("./sirv.js")
|
|
6990
|
-
default: mod.build
|
|
6991
|
-
}));
|
|
6895
|
+
let { default: sirv } = await import("./sirv.js");
|
|
6992
6896
|
for (let { name } of server.publicDir){
|
|
6993
6897
|
let sirvMiddleware = sirv(name, {
|
|
6994
6898
|
etag: !0,
|
|
@@ -7002,7 +6906,7 @@ let applyDefaultMiddlewares = async ({ config, buildManager, context, devServer,
|
|
|
7002
6906
|
for (let callback of postCallbacks)await callback();
|
|
7003
6907
|
return server.historyApiFallback && (middlewares.use(historyApiFallback_historyApiFallbackMiddleware(!0 === server.historyApiFallback ? {} : server.historyApiFallback)), buildManager?.assetsMiddleware && middlewares.use(buildManager.assetsMiddleware)), buildManager && server.htmlFallback && middlewares.use((({ distPath, buildManager })=>async function htmlFallbackMiddleware(req, res, next) {
|
|
7004
6908
|
if (!maybeHTMLRequest(req) || '/favicon.ico' === req.url) return void next();
|
|
7005
|
-
let filePath =
|
|
6909
|
+
let filePath = node_path.join(distPath, 'index.html');
|
|
7006
6910
|
if (await middlewares_isFileExists(filePath, buildManager.outputFileSystem)) {
|
|
7007
6911
|
let newUrl = '/index.html';
|
|
7008
6912
|
isVerbose() && src_logger.debug(` ${req.method} ${req.url} ${color.yellow('fallback to')} ${newUrl}`), req.url = newUrl, buildManager.assetsMiddleware(req, res, (...args)=>{
|
|
@@ -7050,16 +6954,19 @@ let applyDefaultMiddlewares = async ({ config, buildManager, context, devServer,
|
|
|
7050
6954
|
},
|
|
7051
6955
|
onUpgrade
|
|
7052
6956
|
};
|
|
7053
|
-
}, asModule = async (
|
|
6957
|
+
}, isModuleNamespaceObject = (moduleExports)=>'[object Module]' === Object.prototype.toString.call(moduleExports), asModule = async (moduleExports, context, unlinked)=>{
|
|
7054
6958
|
let { Module, SyntheticModule } = await import("node:vm");
|
|
7055
|
-
if (
|
|
6959
|
+
if (moduleExports instanceof Module) return moduleExports;
|
|
7056
6960
|
let exports = [
|
|
7057
6961
|
...new Set([
|
|
7058
6962
|
'default',
|
|
7059
|
-
...Object.keys(
|
|
6963
|
+
...Object.keys(moduleExports)
|
|
7060
6964
|
])
|
|
7061
6965
|
], syntheticModule = new SyntheticModule(exports, ()=>{
|
|
7062
|
-
for (let name of exports)
|
|
6966
|
+
for (let name of exports)if ('default' === name) {
|
|
6967
|
+
let defaultExport = isModuleNamespaceObject(moduleExports) && 'default' in moduleExports ? moduleExports.default : moduleExports;
|
|
6968
|
+
syntheticModule.setExport(name, defaultExport);
|
|
6969
|
+
} else syntheticModule.setExport(name, moduleExports[name]);
|
|
7063
6970
|
}, {
|
|
7064
6971
|
context
|
|
7065
6972
|
});
|
|
@@ -7084,11 +6991,11 @@ class BasicRunner {
|
|
|
7084
6991
|
}
|
|
7085
6992
|
getFile(modulePath, currentDirectory) {
|
|
7086
6993
|
if (Array.isArray(modulePath)) return {
|
|
7087
|
-
path:
|
|
6994
|
+
path: node_path.join(currentDirectory, '.array-require.js'),
|
|
7088
6995
|
content: `module.exports = (${modulePath.map((arg)=>`require(${JSON.stringify(`./${arg}`)})`).join(', ')});`,
|
|
7089
6996
|
subPath: ''
|
|
7090
6997
|
};
|
|
7091
|
-
let joinedPath = /^\.\.?\//.test(modulePath) ?
|
|
6998
|
+
let joinedPath = /^\.\.?\//.test(modulePath) ? node_path.join(currentDirectory, modulePath) : modulePath;
|
|
7092
6999
|
return this._options.isBundleOutput(joinedPath) ? {
|
|
7093
7000
|
path: joinedPath,
|
|
7094
7001
|
content: this._options.readFileSync(joinedPath),
|
|
@@ -7142,10 +7049,10 @@ class CommonJsRunner extends BasicRunner {
|
|
|
7142
7049
|
createModuleScope(requireFn, m, file) {
|
|
7143
7050
|
return {
|
|
7144
7051
|
...this.baseModuleScope,
|
|
7145
|
-
require: requireFn.bind(null,
|
|
7052
|
+
require: requireFn.bind(null, node_path.dirname(file.path)),
|
|
7146
7053
|
module: m,
|
|
7147
7054
|
exports: m.exports,
|
|
7148
|
-
__dirname:
|
|
7055
|
+
__dirname: node_path.dirname(file.path),
|
|
7149
7056
|
__filename: file.path,
|
|
7150
7057
|
define: cjs_define
|
|
7151
7058
|
};
|
|
@@ -7209,15 +7116,15 @@ class EsmRunner extends CommonJsRunner {
|
|
|
7209
7116
|
let esm = esmCache.get(file.path);
|
|
7210
7117
|
return (esm || (esm = new vm.SourceTextModule(file.content, {
|
|
7211
7118
|
identifier: file.path,
|
|
7212
|
-
url: `${
|
|
7119
|
+
url: `${pathToFileURL(file.path).href}?${esmIdentifier}`,
|
|
7213
7120
|
initializeImportMeta: (meta, _)=>{
|
|
7214
|
-
meta.url =
|
|
7121
|
+
meta.url = pathToFileURL(file.path).href;
|
|
7215
7122
|
},
|
|
7216
|
-
importModuleDynamically: async (specifier, module)=>asModule(await _require(
|
|
7123
|
+
importModuleDynamically: async (specifier, module)=>asModule(await _require(node_path.dirname(file.path), specifier, {
|
|
7217
7124
|
esmMode: 1
|
|
7218
7125
|
}), module.context)
|
|
7219
7126
|
}), esmCache.set(file.path, esm)), 2 === context.esmMode) ? esm : (async ()=>{
|
|
7220
|
-
if (await esm.link(async (specifier, referencingModule)=>asModule(await _require(
|
|
7127
|
+
if (await esm.link(async (specifier, referencingModule)=>asModule(await _require(node_path.dirname(referencingModule.identifier ?? fileURLToPath(referencingModule.url)), specifier, {
|
|
7221
7128
|
esmMode: 2
|
|
7222
7129
|
}), referencingModule.context, !0)), await esm.evaluate(), 1 === context.esmMode) return esm;
|
|
7223
7130
|
let ns = esm.namespace;
|
|
@@ -7260,7 +7167,7 @@ let runner_run = async ({ bundlePath, ...runnerFactoryOptions })=>{
|
|
|
7260
7167
|
}, []);
|
|
7261
7168
|
if (0 === files.length) throw Error(`${color.dim('[rsbuild:loadBundle]')} Failed to get bundle by entryName: ${color.yellow(entryName)}`);
|
|
7262
7169
|
if (files.length > 1) throw Error(`${color.dim('[rsbuild:loadBundle]')} Only support load single entry chunk, but got ${color.yellow(files.length)}: ${files.join(',')}`);
|
|
7263
|
-
let allChunkFiles = chunks?.flatMap((c)=>c.files).map((file)=>
|
|
7170
|
+
let allChunkFiles = chunks?.flatMap((c)=>c.files).map((file)=>join(outputPath, file)) || [];
|
|
7264
7171
|
return await runner_run({
|
|
7265
7172
|
bundlePath: files[0],
|
|
7266
7173
|
dist: outputPath,
|
|
@@ -7294,7 +7201,7 @@ let runner_run = async ({ bundlePath, ...runnerFactoryOptions })=>{
|
|
|
7294
7201
|
}, shutdownRefCount = 0, setupGracefulShutdown = ()=>{
|
|
7295
7202
|
shutdownRefCount++;
|
|
7296
7203
|
let onSigterm = ()=>{
|
|
7297
|
-
handleTermination(
|
|
7204
|
+
handleTermination(external_node_os_constants.signals.SIGTERM + 128);
|
|
7298
7205
|
};
|
|
7299
7206
|
process.once('SIGTERM', onSigterm);
|
|
7300
7207
|
let isCI = 'true' === process.env.CI, onStdinEnd = ()=>{
|
|
@@ -7368,13 +7275,9 @@ function prepareWatchOptions(paths, options = {}, type) {
|
|
|
7368
7275
|
}
|
|
7369
7276
|
let GLOB_REGEX = /[*?{}[\]()!+|]/;
|
|
7370
7277
|
async function createChokidar(pathOrGlobs, root, options) {
|
|
7371
|
-
let { default: chokidar } = await import("./chokidar.js").
|
|
7372
|
-
default: mod.chokidar
|
|
7373
|
-
})), watchFiles = new Set(), globPatterns = pathOrGlobs.filter((pathOrGlob)=>!!GLOB_REGEX.test(pathOrGlob) || (watchFiles.add(pathOrGlob), !1));
|
|
7278
|
+
let { default: chokidar } = await import("./chokidar.js"), watchFiles = new Set(), globPatterns = pathOrGlobs.filter((pathOrGlob)=>!!GLOB_REGEX.test(pathOrGlob) || (watchFiles.add(pathOrGlob), !1));
|
|
7374
7279
|
if (globPatterns.length) {
|
|
7375
|
-
let { glob } = await import("./tinyglobby.js")
|
|
7376
|
-
glob: mod.glob
|
|
7377
|
-
}));
|
|
7280
|
+
let { glob } = await import("./tinyglobby.js");
|
|
7378
7281
|
for (let file of (await glob(globPatterns, {
|
|
7379
7282
|
cwd: root,
|
|
7380
7283
|
absolute: !0
|
|
@@ -7469,7 +7372,7 @@ async function devServer_createDevServer(options, createCompiler, config, { getP
|
|
|
7469
7372
|
}, cacheableLoadBundle = createCacheableFunction(loadBundle), cacheableTransformedHtml = createCacheableFunction((_stats, entryName, utils)=>((entryName, utils)=>{
|
|
7470
7373
|
let { htmlPaths, distPath } = utils.environment, htmlPath = htmlPaths[entryName];
|
|
7471
7374
|
if (!htmlPath) throw Error(`${color.dim('[rsbuild:getTransformedHtml]')} Failed to get HTML file by entryName: ${color.yellow(entryName)}`);
|
|
7472
|
-
let fileName =
|
|
7375
|
+
let fileName = join(distPath, htmlPath);
|
|
7473
7376
|
return utils.readFileSync(fileName);
|
|
7474
7377
|
})(entryName, utils)), environmentAPI = {}, getErrorMsg = (method)=>`${color.dim('[rsbuild:server]')} Can not call ${color.yellow(method)} when ${color.yellow('runCompile')} is false`;
|
|
7475
7378
|
context.environmentList.forEach((environment, index)=>{
|
|
@@ -7495,7 +7398,7 @@ async function devServer_createDevServer(options, createCompiler, config, { getP
|
|
|
7495
7398
|
}
|
|
7496
7399
|
};
|
|
7497
7400
|
});
|
|
7498
|
-
let {
|
|
7401
|
+
let { connect } = await import("./connect-next.js"), middlewares = connect(), httpServer = middlewareMode ? null : await createHttpServer({
|
|
7499
7402
|
serverConfig: config.server,
|
|
7500
7403
|
middlewares
|
|
7501
7404
|
}), devServer = {
|
|
@@ -7561,7 +7464,7 @@ async function devServer_createDevServer(options, createCompiler, config, { getP
|
|
|
7561
7464
|
}), buildManager?.watch(), src_logger.debug('create dev server done'), devServer;
|
|
7562
7465
|
}
|
|
7563
7466
|
async function startPreviewServer(context, config, { getPortSilently } = {}) {
|
|
7564
|
-
let {
|
|
7467
|
+
let { connect } = await import("./connect-next.js"), middlewares = connect(), { port, portTip } = await resolvePort(config), serverConfig = config.server, { host, headers, proxy, historyApiFallback, compress, base, cors } = serverConfig, protocol = serverConfig.https ? 'https' : 'http', routes = getRoutes(context), urls = await getAddressUrls({
|
|
7565
7468
|
protocol,
|
|
7566
7469
|
port,
|
|
7567
7470
|
host
|
|
@@ -7601,9 +7504,7 @@ async function startPreviewServer(context, config, { getPortSilently } = {}) {
|
|
|
7601
7504
|
environments: context.environments
|
|
7602
7505
|
});
|
|
7603
7506
|
let applyStaticAssetMiddleware = async ()=>{
|
|
7604
|
-
let { default: sirv } = await import("./sirv.js").
|
|
7605
|
-
default: mod.build
|
|
7606
|
-
})), assetsMiddleware = sirv(context.distPath, {
|
|
7507
|
+
let { default: sirv } = await import("./sirv.js"), assetsMiddleware = sirv(context.distPath, {
|
|
7607
7508
|
etag: !0,
|
|
7608
7509
|
dev: !0,
|
|
7609
7510
|
ignores: [
|
|
@@ -7792,11 +7693,11 @@ function applyDefaultPlugins(pluginManager, context) {
|
|
|
7792
7693
|
}), jsPath = config.output.distPath.js, jsAsyncPath = void 0 !== (jsAsync = config.output.distPath.jsAsync) ? jsAsync : isServer ? jsPath : jsPath ? `${jsPath}/async` : 'async', jsFilename = getFilename(config, 'js', isProd, isServer), isJsFilenameFn = 'function' == typeof jsFilename;
|
|
7793
7694
|
if (chain.output.path(distPath).filename(isJsFilenameFn ? (...args)=>{
|
|
7794
7695
|
let name = jsFilename(...args);
|
|
7795
|
-
return
|
|
7796
|
-
} :
|
|
7696
|
+
return posix.join(jsPath, name);
|
|
7697
|
+
} : posix.join(jsPath, jsFilename)).chunkFilename(isJsFilenameFn ? (...args)=>{
|
|
7797
7698
|
let name = jsFilename(...args);
|
|
7798
|
-
return
|
|
7799
|
-
} :
|
|
7699
|
+
return posix.join(jsAsyncPath, name);
|
|
7700
|
+
} : posix.join(jsAsyncPath, jsFilename)).publicPath(publicPath).bundlerInfo({
|
|
7800
7701
|
force: !1
|
|
7801
7702
|
}), isServer && chain.output.library({
|
|
7802
7703
|
type: 'commonjs2',
|
|
@@ -7894,7 +7795,7 @@ function applyDefaultPlugins(pluginManager, context) {
|
|
|
7894
7795
|
} : void 0;
|
|
7895
7796
|
})(environment, params.isDev)),
|
|
7896
7797
|
(()=>{
|
|
7897
|
-
let { rootPath, distPath } = api.context, config = api.getNormalizedConfig(), targetPath =
|
|
7798
|
+
let { rootPath, distPath } = api.context, config = api.getNormalizedConfig(), targetPath = join(distPath, RSBUILD_OUTPUTS_PATH), { enable } = normalizeCleanDistPath(config.output.cleanDistPath);
|
|
7898
7799
|
if (!0 === enable || 'auto' === enable && isStrictSubdir(rootPath, targetPath)) return {
|
|
7899
7800
|
path: targetPath
|
|
7900
7801
|
};
|
|
@@ -7927,8 +7828,8 @@ function applyDefaultPlugins(pluginManager, context) {
|
|
|
7927
7828
|
let distDir = config.output.distPath[assetType], filename = getFilename(config, assetType, isProd);
|
|
7928
7829
|
return 'function' == typeof filename ? (...args)=>{
|
|
7929
7830
|
let name = filename(...args);
|
|
7930
|
-
return
|
|
7931
|
-
} :
|
|
7831
|
+
return node_path.posix.join(distDir, name);
|
|
7832
|
+
} : node_path.posix.join(distDir, filename);
|
|
7932
7833
|
}, createAssetRule = (assetType, exts, emit)=>{
|
|
7933
7834
|
let regExp = getRegExpForExts(exts), { dataUriLimit } = config.output, maxSize = 'number' == typeof dataUriLimit ? dataUriLimit : dataUriLimit[assetType];
|
|
7934
7835
|
chainStaticAssetRule({
|
|
@@ -8007,7 +7908,7 @@ function applyDefaultPlugins(pluginManager, context) {
|
|
|
8007
7908
|
'png',
|
|
8008
7909
|
'svg'
|
|
8009
7910
|
], publicDirs = Array.from(new Set(publicDir.map(({ name })=>name))), faviconPaths = [];
|
|
8010
|
-
for (let publicDir of publicDirs)for (let ext of extensions)faviconPaths.push(
|
|
7911
|
+
for (let publicDir of publicDirs)for (let ext of extensions)faviconPaths.push(node_path.join(publicDir, `favicon.${ext}`));
|
|
8011
7912
|
let faviconPath = findExists(faviconPaths);
|
|
8012
7913
|
return faviconPath && (defaultFavicon = faviconPath), defaultFavicon;
|
|
8013
7914
|
})();
|
|
@@ -8064,9 +7965,7 @@ function applyDefaultPlugins(pluginManager, context) {
|
|
|
8064
7965
|
}, async ({ compilation, environment, sources })=>{
|
|
8065
7966
|
let { config } = environment, { appIcon } = config.html;
|
|
8066
7967
|
if (!appIcon) return;
|
|
8067
|
-
let { lookup } = await import("./
|
|
8068
|
-
lookup: mod.lookup
|
|
8069
|
-
})), distDir = config.output.distPath.image, manifestFile = appIcon.filename ?? 'manifest.webmanifest', publicPath = getPublicPathFromCompiler(compilation), icons = appIcon.icons.map((icon)=>((icon, distDir, publicPath, lookup)=>{
|
|
7968
|
+
let { lookup } = await import("./mrmime.js"), distDir = config.output.distPath.image, manifestFile = appIcon.filename ?? 'manifest.webmanifest', publicPath = getPublicPathFromCompiler(compilation), icons = appIcon.icons.map((icon)=>((icon, distDir, publicPath, lookup)=>{
|
|
8070
7969
|
let { src, size } = icon, cacheKey = `${distDir}|${publicPath}|${src}`, cached = iconFormatMap.get(cacheKey);
|
|
8071
7970
|
if (cached) return cached;
|
|
8072
7971
|
let sizes = `${size}x${size}`;
|
|
@@ -8080,7 +7979,7 @@ function applyDefaultPlugins(pluginManager, context) {
|
|
|
8080
7979
|
};
|
|
8081
7980
|
return iconFormatMap.set(cacheKey, formatted), formatted;
|
|
8082
7981
|
}
|
|
8083
|
-
let absolutePath =
|
|
7982
|
+
let absolutePath = node_path.isAbsolute(src) ? src : node_path.join(api.context.rootPath, src), relativePath = node_path.posix.join(distDir, node_path.basename(absolutePath)), formatted = {
|
|
8084
7983
|
...icon,
|
|
8085
7984
|
sizes,
|
|
8086
7985
|
src: ensureAssetPrefix(relativePath, publicPath),
|
|
@@ -8158,7 +8057,7 @@ function applyDefaultPlugins(pluginManager, context) {
|
|
|
8158
8057
|
name: 'rsbuild:wasm',
|
|
8159
8058
|
setup (api) {
|
|
8160
8059
|
api.modifyBundlerChain((chain, { CHAIN_ID, environment, isProd })=>{
|
|
8161
|
-
let { config } = environment, distPath = config.output.distPath.wasm, filename =
|
|
8060
|
+
let { config } = environment, distPath = config.output.distPath.wasm, filename = posix.join(distPath, getFilename(config, 'wasm', isProd));
|
|
8162
8061
|
chain.output.webassemblyModuleFilename(filename), chain.module.rule(CHAIN_ID.RULE.WASM).test(/\.wasm$/).dependency('url').type('asset/resource').set('generator', {
|
|
8163
8062
|
filename
|
|
8164
8063
|
});
|
|
@@ -8175,7 +8074,7 @@ function applyDefaultPlugins(pluginManager, context) {
|
|
|
8175
8074
|
],
|
|
8176
8075
|
raw: !0
|
|
8177
8076
|
}, ({ code, emitFile, resourcePath })=>{
|
|
8178
|
-
let name, filename = (name = resourcePath &&
|
|
8077
|
+
let name, filename = (name = resourcePath && node_path.parse(resourcePath).name) ? `${name}.node` : null;
|
|
8179
8078
|
if (null === filename) throw Error(`${color.dim('[rsbuild:nodeAddons]')} Failed to load Node.js addon: ${color.yellow(resourcePath)}`);
|
|
8180
8079
|
emitFile(filename, code);
|
|
8181
8080
|
let config = api.getNormalizedConfig(), handleErrorSnippet = `throw new Error('Failed to load Node.js addon: "${filename}"', {
|
|
@@ -8252,15 +8151,15 @@ try {
|
|
|
8252
8151
|
initial: {},
|
|
8253
8152
|
config: config.tools.styleLoader
|
|
8254
8153
|
});
|
|
8255
|
-
mainRule.use(CHAIN_ID.USE.STYLE).loader(
|
|
8154
|
+
mainRule.use(CHAIN_ID.USE.STYLE).loader(join(COMPILED_PATH, 'style-loader', 'index.js')).options(styleLoaderOptions);
|
|
8256
8155
|
} else mainRule.use(CHAIN_ID.USE.MINI_CSS_EXTRACT).loader((cssExtractPlugin || core_rspack.CssExtractRspackPlugin).loader).options(config.tools.cssExtract.loaderOptions);
|
|
8257
|
-
else mainRule.use(CHAIN_ID.USE.IGNORE_CSS).loader(
|
|
8156
|
+
else mainRule.use(CHAIN_ID.USE.IGNORE_CSS).loader(node_path.join(dirname, 'ignoreCssLoader.mjs'));
|
|
8258
8157
|
let importLoaders = {
|
|
8259
8158
|
normal: 0,
|
|
8260
8159
|
inline: 0
|
|
8261
8160
|
}, updateRules = (callback, options = {})=>{
|
|
8262
8161
|
options.skipMain || callback(mainRule, 'main'), callback(inlineRule, 'inline');
|
|
8263
|
-
}, cssLoaderPath =
|
|
8162
|
+
}, cssLoaderPath = join(COMPILED_PATH, 'css-loader', 'index.js');
|
|
8264
8163
|
if (updateRules((rule)=>{
|
|
8265
8164
|
rule.use(CHAIN_ID.USE.CSS).loader(cssLoaderPath);
|
|
8266
8165
|
}), !1 !== config.tools.lightningcssLoader) {
|
|
@@ -8284,7 +8183,7 @@ try {
|
|
|
8284
8183
|
});
|
|
8285
8184
|
if ('function' == typeof postcssLoaderOptions.postcssOptions || postcssLoaderOptions.postcssOptions?.plugins?.length) {
|
|
8286
8185
|
emitCss && importLoaders.normal++, importLoaders.inline++;
|
|
8287
|
-
let postcssLoaderPath =
|
|
8186
|
+
let postcssLoaderPath = join(COMPILED_PATH, 'postcss-loader', 'index.js');
|
|
8288
8187
|
updateRules((rule)=>{
|
|
8289
8188
|
rule.use(CHAIN_ID.USE.POSTCSS).loader(postcssLoaderPath).options(postcssLoaderOptions);
|
|
8290
8189
|
}, {
|
|
@@ -8345,12 +8244,12 @@ try {
|
|
|
8345
8244
|
{
|
|
8346
8245
|
filename: isCssFilenameFn ? (...args)=>{
|
|
8347
8246
|
let name = cssFilename(...args);
|
|
8348
|
-
return
|
|
8349
|
-
} :
|
|
8247
|
+
return posix.join(cssPath, name);
|
|
8248
|
+
} : posix.join(cssPath, cssFilename),
|
|
8350
8249
|
chunkFilename: isCssFilenameFn ? (...args)=>{
|
|
8351
8250
|
let name = cssFilename(...args);
|
|
8352
|
-
return
|
|
8353
|
-
} :
|
|
8251
|
+
return posix.join(cssAsyncPath, name);
|
|
8252
|
+
} : posix.join(cssAsyncPath, cssFilename),
|
|
8354
8253
|
...extractPluginOptions
|
|
8355
8254
|
}
|
|
8356
8255
|
]);
|
|
@@ -8410,7 +8309,7 @@ try {
|
|
|
8410
8309
|
api.modifyBundlerChain({
|
|
8411
8310
|
order: 'pre',
|
|
8412
8311
|
handler: (chain, { CHAIN_ID, isDev, isProd, target, environment })=>{
|
|
8413
|
-
let { config, browserslist } = environment, cacheRoot =
|
|
8312
|
+
let { config, browserslist } = environment, cacheRoot = node_path.join(api.context.cachePath, '.swc'), rule = chain.module.rule(CHAIN_ID.RULE.JS).test(SCRIPT_REGEX).dependency({
|
|
8414
8313
|
not: 'url'
|
|
8415
8314
|
});
|
|
8416
8315
|
rule.oneOf(CHAIN_ID.ONE_OF.JS_RAW).resourceQuery(RAW_QUERY_REGEX).type('asset/source');
|
|
@@ -8600,7 +8499,7 @@ try {
|
|
|
8600
8499
|
return;
|
|
8601
8500
|
}
|
|
8602
8501
|
try {
|
|
8603
|
-
let moduleURL = isWindows ?
|
|
8502
|
+
let moduleURL = isWindows ? pathToFileURL(packagePath).href : packagePath;
|
|
8604
8503
|
module = await import(moduleURL);
|
|
8605
8504
|
} catch {
|
|
8606
8505
|
src_logger.error(`\`process.env.RSDOCTOR\` enabled, but failed to load ${color.bold(color.yellow(packageName))} module.`);
|
|
@@ -8691,19 +8590,17 @@ try {
|
|
|
8691
8590
|
api.onAfterStartDevServer(onStartServer), api.onAfterStartPreviewServer(onStartServer), api.onBeforeBuild(async ({ isFirstCompile, environments })=>{
|
|
8692
8591
|
if (isFirstCompile) for (let { name: publicDir, copyOnBuild, ignore } of api.getNormalizedConfig().server.publicDir){
|
|
8693
8592
|
let shouldCopy;
|
|
8694
|
-
if (!1 === copyOnBuild || !
|
|
8593
|
+
if (!1 === copyOnBuild || !node_fs.existsSync(publicDir)) continue;
|
|
8695
8594
|
let distPaths = dedupeNestedPaths(Object.values(environments).filter(({ config })=>!0 === copyOnBuild || 'auto' === copyOnBuild && 'node' !== config.output.target).map(({ distPath })=>distPath));
|
|
8696
8595
|
if (ignore?.length) {
|
|
8697
|
-
let { globSync } = await import("./tinyglobby.js")
|
|
8698
|
-
globSync: mod.globSync
|
|
8699
|
-
})), ignoredSet = new Set(globSync(ignore, {
|
|
8596
|
+
let { globSync } = await import("./tinyglobby.js"), ignoredSet = new Set(globSync(ignore, {
|
|
8700
8597
|
cwd: publicDir,
|
|
8701
8598
|
absolute: !1,
|
|
8702
8599
|
dot: !0,
|
|
8703
8600
|
onlyFiles: !1
|
|
8704
8601
|
}).map((item)=>item.replace(/\\/g, '/').replace(/\/$/, '')));
|
|
8705
8602
|
shouldCopy = (source)=>{
|
|
8706
|
-
let relativePath =
|
|
8603
|
+
let relativePath = node_path.relative(publicDir, source);
|
|
8707
8604
|
if (!relativePath) return !0;
|
|
8708
8605
|
let normalizedPath = relativePath.replace(/\\/g, '/');
|
|
8709
8606
|
return !ignoredSet.has(normalizedPath);
|
|
@@ -8711,13 +8608,13 @@ try {
|
|
|
8711
8608
|
}
|
|
8712
8609
|
try {
|
|
8713
8610
|
await Promise.all(distPaths.map(async (distPath)=>{
|
|
8714
|
-
isDeno &&
|
|
8611
|
+
isDeno && node_fs.existsSync(distPath) && await node_fs.promises.rm(distPath, {
|
|
8715
8612
|
recursive: !0,
|
|
8716
8613
|
force: !0
|
|
8717
|
-
}), await
|
|
8614
|
+
}), await node_fs.promises.cp(publicDir, distPath, {
|
|
8718
8615
|
recursive: !0,
|
|
8719
8616
|
dereference: !0,
|
|
8720
|
-
mode:
|
|
8617
|
+
mode: node_fs.constants.COPYFILE_FICLONE,
|
|
8721
8618
|
filter: shouldCopy
|
|
8722
8619
|
});
|
|
8723
8620
|
}));
|
|
@@ -8735,7 +8632,7 @@ try {
|
|
|
8735
8632
|
api.modifyBundlerChain(async (chain, { CHAIN_ID, environment, isDev })=>{
|
|
8736
8633
|
let { output: { manifest }, dev: { writeToDisk } } = environment.config;
|
|
8737
8634
|
if (!1 === manifest) return;
|
|
8738
|
-
let manifestOptions = normalizeManifestObjectConfig(manifest), { RspackManifestPlugin } = await import("./manifest-plugin.js").then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-beta.
|
|
8635
|
+
let manifestOptions = normalizeManifestObjectConfig(manifest), { RspackManifestPlugin } = await import("./manifest-plugin.js").then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-beta.6_@module-federation+runtime-tools@2.1.0_@swc+helpers@0.5.19_/node_modules/rspack-manifest-plugin/dist/index.js")), { htmlPaths } = environment, filter = manifestOptions.filter ?? ((file)=>!file.name.endsWith('.LICENSE.txt'));
|
|
8739
8636
|
manifestFilenames.set(environment.name, manifestOptions.filename);
|
|
8740
8637
|
let pluginOptions = {
|
|
8741
8638
|
fileName: manifestOptions.filename,
|
|
@@ -8856,7 +8753,7 @@ try {
|
|
|
8856
8753
|
enabled: !0,
|
|
8857
8754
|
hashFuncNames: helpers_castArray(algorithm)
|
|
8858
8755
|
};
|
|
8859
|
-
'js' === config.html.implementation && !1 !== config.tools.htmlPlugin && (pluginOptions.htmlPlugin =
|
|
8756
|
+
'js' === config.html.implementation && !1 !== config.tools.htmlPlugin && (pluginOptions.htmlPlugin = node_path.join(COMPILED_PATH, 'html-rspack-plugin/index.js')), chain.plugin(CHAIN_ID.PLUGIN.SUBRESOURCE_INTEGRITY).use(rspack.SubresourceIntegrityPlugin, [
|
|
8860
8757
|
pluginOptions
|
|
8861
8758
|
]);
|
|
8862
8759
|
});
|
|
@@ -8967,7 +8864,7 @@ async function createRsbuild(options = {}) {
|
|
|
8967
8864
|
pluginManager
|
|
8968
8865
|
}), { distPath } = context, { checkDistDir = !0 } = options;
|
|
8969
8866
|
if (checkDistDir) {
|
|
8970
|
-
if (!
|
|
8867
|
+
if (!existsSync(distPath)) throw Error(`${color.dim('[rsbuild:preview]')} The output directory ${color.yellow(distPath)} does not exist, please build the project before previewing.`);
|
|
8971
8868
|
if (isEmptyDir(distPath)) throw Error(`${color.dim('[rsbuild:preview]')} The output directory ${color.yellow(distPath)} is empty, please build the project before previewing.`);
|
|
8972
8869
|
}
|
|
8973
8870
|
return startPreviewServer(context, config, options);
|
|
@@ -9070,8 +8967,8 @@ function defineConfig(config) {
|
|
|
9070
8967
|
async function loadConfig_loadConfig({ cwd = process.cwd(), path, envMode, meta, loader = 'auto' } = {}) {
|
|
9071
8968
|
let configExport, configFilePath = ((root, customConfig)=>{
|
|
9072
8969
|
if (customConfig) {
|
|
9073
|
-
let customConfigPath = (
|
|
9074
|
-
if (
|
|
8970
|
+
let customConfigPath = external_node_path_isAbsolute(customConfig) ? customConfig : join(root, customConfig);
|
|
8971
|
+
if (node_fs.existsSync(customConfigPath)) return customConfigPath;
|
|
9075
8972
|
throw Error(`${color.dim('[rsbuild:loadConfig]')} Cannot find config file: ${color.dim(customConfigPath)}`);
|
|
9076
8973
|
}
|
|
9077
8974
|
for (let file of [
|
|
@@ -9082,8 +8979,8 @@ async function loadConfig_loadConfig({ cwd = process.cwd(), path, envMode, meta,
|
|
|
9082
8979
|
'rsbuild.config.mts',
|
|
9083
8980
|
'rsbuild.config.cts'
|
|
9084
8981
|
]){
|
|
9085
|
-
let configFile =
|
|
9086
|
-
if (
|
|
8982
|
+
let configFile = join(root, file);
|
|
8983
|
+
if (node_fs.existsSync(configFile)) return configFile;
|
|
9087
8984
|
}
|
|
9088
8985
|
return null;
|
|
9089
8986
|
})(cwd, path);
|
|
@@ -9095,7 +8992,7 @@ async function loadConfig_loadConfig({ cwd = process.cwd(), path, envMode, meta,
|
|
|
9095
8992
|
configFilePath
|
|
9096
8993
|
}, config);
|
|
9097
8994
|
if ('native' === loader || 'auto' === loader && (process.features.typescript || process.versions.bun || process.versions.deno) || /\.(?:js|mjs|cjs)$/.test(configFilePath)) try {
|
|
9098
|
-
let configFileURL =
|
|
8995
|
+
let configFileURL = pathToFileURL(configFilePath).href, exportModule = await import(`${configFileURL}?t=${Date.now()}`);
|
|
9099
8996
|
configExport = exportModule.default ? exportModule.default : exportModule;
|
|
9100
8997
|
} catch (err) {
|
|
9101
8998
|
let errorMessage = `Failed to load file with native loader: ${color.dim(configFilePath)}`;
|
|
@@ -9159,7 +9056,7 @@ async function init_init({ cliOptions, isRestart, isBuildWatch = !1 }) {
|
|
|
9159
9056
|
config: ()=>init_loadConfig(root),
|
|
9160
9057
|
environment: commonOpts.environment,
|
|
9161
9058
|
loadEnv: !1 !== commonOpts.env && {
|
|
9162
|
-
cwd: (envDir = commonOpts.envDir) ?
|
|
9059
|
+
cwd: (envDir = commonOpts.envDir) ? node_path.isAbsolute(envDir) ? envDir : node_path.join(root, envDir) : root,
|
|
9163
9060
|
mode: commonOpts.envMode
|
|
9164
9061
|
}
|
|
9165
9062
|
});
|
|
@@ -9191,7 +9088,7 @@ let cleaners = [], onBeforeRestartServer = (cleaner)=>{
|
|
|
9191
9088
|
cleaners.push(cleaner);
|
|
9192
9089
|
}, beforeRestart = async ({ filePath, clear = !0, id })=>{
|
|
9193
9090
|
if (clear && isTTY() && !process.env.DEBUG && process.stdout.write('\x1B[H\x1B[2J'), filePath) {
|
|
9194
|
-
let filename =
|
|
9091
|
+
let filename = node_path.basename(filePath);
|
|
9195
9092
|
src_logger.info(`restarting ${id} as ${color.yellow(filename)} changed\n`);
|
|
9196
9093
|
} else src_logger.info(`restarting ${id}...\n`);
|
|
9197
9094
|
for (let cleaner of cleaners)await cleaner();
|
|
@@ -9240,7 +9137,7 @@ let applyServerOptions = (command)=>{
|
|
|
9240
9137
|
};
|
|
9241
9138
|
function setupCommands() {
|
|
9242
9139
|
let cli = ((name = "")=>new CAC(name))('rsbuild');
|
|
9243
|
-
cli.version("2.0.0-beta.
|
|
9140
|
+
cli.version("2.0.0-beta.8"), cli.option('--base <base>', 'Set the base path of the server').option('-c, --config <config>', 'Set the configuration file (relative or absolute path)').option('--config-loader <loader>', 'Set the config file loader (auto | jiti | native)', {
|
|
9244
9141
|
default: 'auto'
|
|
9245
9142
|
}).option('--env-dir <dir>', 'Set the directory for loading `.env` files').option('--env-mode <mode>', 'Set the env mode to load the `.env.[mode]` file').option('--environment <name>', 'Set the environment name(s) to build', {
|
|
9246
9143
|
type: [
|
|
@@ -9309,7 +9206,7 @@ function initNodeEnv() {
|
|
|
9309
9206
|
}
|
|
9310
9207
|
function showGreeting() {
|
|
9311
9208
|
let { npm_execpath, npm_lifecycle_event, NODE_RUN_SCRIPT_NAME } = process.env, isBun = npm_execpath?.includes('.bun');
|
|
9312
|
-
src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.0.0-beta.
|
|
9209
|
+
src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.0.0-beta.8\n`);
|
|
9313
9210
|
}
|
|
9314
9211
|
function setupLogLevel() {
|
|
9315
9212
|
let logLevelIndex = process.argv.findIndex((item)=>'--log-level' === item || '--logLevel' === item);
|
|
@@ -9330,5 +9227,5 @@ function runCLI() {
|
|
|
9330
9227
|
src_logger.error('Failed to start Rsbuild CLI.'), src_logger.error(err), process.exit(1);
|
|
9331
9228
|
}
|
|
9332
9229
|
}
|
|
9333
|
-
let src_version = "2.0.0-beta.
|
|
9334
|
-
export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, core_rspack as rspack, createRsbuild, defaultAllowedOrigins, defineConfig, ensureAssetPrefix,
|
|
9230
|
+
let src_version = "2.0.0-beta.8";
|
|
9231
|
+
export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, core_rspack as rspack, createRsbuild, defaultAllowedOrigins, defineConfig, ensureAssetPrefix, loadConfig_loadConfig as loadConfig, loadEnv, mergeRsbuildConfig, runCLI, src_logger as logger, src_version as version };
|