@rsbuild/core 1.4.0 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiled/css-loader/index.js +18 -18
- package/compiled/html-rspack-plugin/index.js +14 -14
- package/compiled/http-proxy-middleware/index.js +11 -7
- package/compiled/postcss-loader/index.js +6 -6
- package/compiled/rsbuild-dev-middleware/index.js +5 -3
- package/compiled/rslog/index.d.ts +69 -63
- package/compiled/rslog/package.json +1 -1
- package/compiled/rspack-manifest-plugin/index.js +4 -4
- package/compiled/sirv/index.js +1 -1
- package/compiled/webpack-bundle-analyzer/index.js +21 -13621
- package/dist/index.cjs +350 -25
- package/dist/index.js +354 -20
- package/dist-types/inspectConfig.d.ts +9 -9
- package/dist-types/types/rsbuild.d.ts +13 -0
- package/package.json +7 -7
- package/compiled/open/index.d.ts +0 -153
- package/compiled/open/index.js +0 -409
- package/compiled/open/package.json +0 -1
- package/compiled/open/xdg-open +0 -1066
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*! For license information please see index.js.LICENSE.txt */
|
|
2
|
-
let swcHelpersPath, pluginHelper_htmlPlugin, cssExtractPlugin;
|
|
2
|
+
let swcHelpersPath, pluginHelper_htmlPlugin, cssExtractPlugin, isDockerCached, cachedResult;
|
|
3
3
|
import { rspack } from "@rspack/core";
|
|
4
4
|
import { logger } from "../compiled/rslog/index.js";
|
|
5
5
|
import node_path, { dirname, isAbsolute as external_node_path_isAbsolute, join, posix, relative, sep } from "node:path";
|
|
@@ -12,9 +12,12 @@ import node_os, { constants } from "node:os";
|
|
|
12
12
|
import node_process from "node:process";
|
|
13
13
|
import rspack_chain from "../compiled/rspack-chain/index.js";
|
|
14
14
|
import { isPromise, isRegExp } from "node:util/types";
|
|
15
|
-
import { promisify as external_node_util_promisify } from "node:util";
|
|
15
|
+
import node_util, { promisify as external_node_util_promisify } from "node:util";
|
|
16
16
|
import { lookup } from "../compiled/mrmime/index.js";
|
|
17
17
|
import node_zlib from "node:zlib";
|
|
18
|
+
import { Buffer as external_node_buffer_Buffer } from "node:buffer";
|
|
19
|
+
import node_child_process, { execFile } from "node:child_process";
|
|
20
|
+
import promises, { constants as promises_constants } from "node:fs/promises";
|
|
18
21
|
var EsmMode, __webpack_modules__ = {
|
|
19
22
|
"../../node_modules/.pnpm/clone-deep@4.0.1/node_modules/clone-deep/index.js": function(module, __unused_webpack_exports, __webpack_require__) {
|
|
20
23
|
let clone = __webpack_require__("../../node_modules/.pnpm/shallow-clone@3.0.1/node_modules/shallow-clone/index.js"), typeOf = __webpack_require__("../../node_modules/.pnpm/kind-of@6.0.3/node_modules/kind-of/index.js"), isPlainObject = __webpack_require__("../../node_modules/.pnpm/is-plain-object@2.0.4/node_modules/is-plain-object/index.js");
|
|
@@ -2059,7 +2062,7 @@ async function updateEnvironmentContext(context, configs) {
|
|
|
2059
2062
|
async function createContext(options, userConfig) {
|
|
2060
2063
|
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, bundlerType = userConfig.provider ? 'webpack' : 'rspack';
|
|
2061
2064
|
return {
|
|
2062
|
-
version: "1.4.
|
|
2065
|
+
version: "1.4.2",
|
|
2063
2066
|
rootPath,
|
|
2064
2067
|
distPath: '',
|
|
2065
2068
|
cachePath,
|
|
@@ -2104,7 +2107,7 @@ let normalizePluginObject = (plugin)=>{
|
|
|
2104
2107
|
setup () {}
|
|
2105
2108
|
};
|
|
2106
2109
|
};
|
|
2107
|
-
async function outputInspectConfigFiles({ rawBundlerConfigs, rawEnvironmentConfigs, inspectOptions, configType }) {
|
|
2110
|
+
async function outputInspectConfigFiles({ rawBundlerConfigs, rawEnvironmentConfigs, inspectOptions, rawExtraConfigs, configType }) {
|
|
2108
2111
|
let { outputPath } = inspectOptions, files = [
|
|
2109
2112
|
...rawEnvironmentConfigs.map(({ name, content })=>1 === rawEnvironmentConfigs.length ? {
|
|
2110
2113
|
path: join(outputPath, 'rsbuild.config.mjs'),
|
|
@@ -2122,7 +2125,12 @@ async function outputInspectConfigFiles({ rawBundlerConfigs, rawEnvironmentConfi
|
|
|
2122
2125
|
label: `${upperFirst(configType)} Config (${name})`,
|
|
2123
2126
|
content
|
|
2124
2127
|
};
|
|
2125
|
-
})
|
|
2128
|
+
}),
|
|
2129
|
+
...(rawExtraConfigs || []).map(({ name, content })=>({
|
|
2130
|
+
path: join(outputPath, `${name}.config.mjs`),
|
|
2131
|
+
label: `${upperFirst(name)} Config`,
|
|
2132
|
+
content
|
|
2133
|
+
}))
|
|
2126
2134
|
];
|
|
2127
2135
|
await node_fs.promises.mkdir(outputPath, {
|
|
2128
2136
|
recursive: !0
|
|
@@ -2168,10 +2176,14 @@ async function inspectConfig({ context, pluginManager, bundlerConfigs, inspectOp
|
|
|
2168
2176
|
normalizedConfig: context.normalizedConfig,
|
|
2169
2177
|
inspectOptions,
|
|
2170
2178
|
pluginManager
|
|
2171
|
-
}), outputPath = (context1 = context, (inspectOptions1 = inspectOptions).outputPath ? external_node_path_isAbsolute(inspectOptions1.outputPath) ? inspectOptions1.outputPath : join(context1.distPath, inspectOptions1.outputPath) : join(context1.distPath, RSBUILD_OUTPUTS_PATH))
|
|
2179
|
+
}), outputPath = (context1 = context, (inspectOptions1 = inspectOptions).outputPath ? external_node_path_isAbsolute(inspectOptions1.outputPath) ? inspectOptions1.outputPath : join(context1.distPath, inspectOptions1.outputPath) : join(context1.distPath, RSBUILD_OUTPUTS_PATH)), rawExtraConfigs = inspectOptions.extraConfigs ? Object.entries(inspectOptions.extraConfigs).map(([name, content])=>({
|
|
2180
|
+
name,
|
|
2181
|
+
content: 'string' == typeof content ? content : stringifyConfig(content, inspectOptions.verbose)
|
|
2182
|
+
})) : void 0;
|
|
2172
2183
|
return inspectOptions.writeToDisk && await outputInspectConfigFiles({
|
|
2173
2184
|
rawBundlerConfigs,
|
|
2174
2185
|
rawEnvironmentConfigs,
|
|
2186
|
+
rawExtraConfigs,
|
|
2175
2187
|
inspectOptions: {
|
|
2176
2188
|
...inspectOptions,
|
|
2177
2189
|
outputPath
|
|
@@ -3218,7 +3230,322 @@ let getInlineTests = (config)=>{
|
|
|
3218
3230
|
scriptTests,
|
|
3219
3231
|
styleTests
|
|
3220
3232
|
};
|
|
3221
|
-
}
|
|
3233
|
+
};
|
|
3234
|
+
function isInsideContainer() {
|
|
3235
|
+
return void 0 === cachedResult && (cachedResult = (()=>{
|
|
3236
|
+
try {
|
|
3237
|
+
return node_fs.statSync('/run/.containerenv'), !0;
|
|
3238
|
+
} catch {
|
|
3239
|
+
return !1;
|
|
3240
|
+
}
|
|
3241
|
+
})() || (void 0 === isDockerCached && (isDockerCached = function() {
|
|
3242
|
+
try {
|
|
3243
|
+
return node_fs.statSync('/.dockerenv'), !0;
|
|
3244
|
+
} catch {
|
|
3245
|
+
return !1;
|
|
3246
|
+
}
|
|
3247
|
+
}() || function() {
|
|
3248
|
+
try {
|
|
3249
|
+
return node_fs.readFileSync('/proc/self/cgroup', 'utf8').includes('docker');
|
|
3250
|
+
} catch {
|
|
3251
|
+
return !1;
|
|
3252
|
+
}
|
|
3253
|
+
}()), isDockerCached)), cachedResult;
|
|
3254
|
+
}
|
|
3255
|
+
let isWsl = ()=>{
|
|
3256
|
+
if ('linux' !== node_process.platform) return !1;
|
|
3257
|
+
if (node_os.release().toLowerCase().includes('microsoft')) return !isInsideContainer();
|
|
3258
|
+
try {
|
|
3259
|
+
return !!node_fs.readFileSync('/proc/version', 'utf8').toLowerCase().includes('microsoft') && !isInsideContainer();
|
|
3260
|
+
} catch {
|
|
3261
|
+
return !1;
|
|
3262
|
+
}
|
|
3263
|
+
}, is_wsl = node_process.env.__IS_WSL_TEST__ ? isWsl : isWsl();
|
|
3264
|
+
function defineLazyProperty(object, propertyName, valueGetter) {
|
|
3265
|
+
let define = (value)=>Object.defineProperty(object, propertyName, {
|
|
3266
|
+
value,
|
|
3267
|
+
enumerable: !0,
|
|
3268
|
+
writable: !0
|
|
3269
|
+
});
|
|
3270
|
+
return Object.defineProperty(object, propertyName, {
|
|
3271
|
+
configurable: !0,
|
|
3272
|
+
enumerable: !0,
|
|
3273
|
+
get () {
|
|
3274
|
+
let result = valueGetter();
|
|
3275
|
+
return define(result), result;
|
|
3276
|
+
},
|
|
3277
|
+
set (value) {
|
|
3278
|
+
define(value);
|
|
3279
|
+
}
|
|
3280
|
+
}), object;
|
|
3281
|
+
}
|
|
3282
|
+
let execFileAsync = external_node_util_promisify(execFile);
|
|
3283
|
+
async function defaultBrowserId() {
|
|
3284
|
+
if ('darwin' !== node_process.platform) throw Error('macOS only');
|
|
3285
|
+
let { stdout } = await execFileAsync('defaults', [
|
|
3286
|
+
'read',
|
|
3287
|
+
'com.apple.LaunchServices/com.apple.launchservices.secure',
|
|
3288
|
+
'LSHandlers'
|
|
3289
|
+
]), match = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout);
|
|
3290
|
+
return match?.groups.id ?? 'com.apple.Safari';
|
|
3291
|
+
}
|
|
3292
|
+
let run_applescript_execFileAsync = external_node_util_promisify(execFile);
|
|
3293
|
+
async function runAppleScript(script, { humanReadableOutput = !0 } = {}) {
|
|
3294
|
+
if ('darwin' !== node_process.platform) throw Error('macOS only');
|
|
3295
|
+
let { stdout } = await run_applescript_execFileAsync("osascript", [
|
|
3296
|
+
'-e',
|
|
3297
|
+
script,
|
|
3298
|
+
humanReadableOutput ? [] : [
|
|
3299
|
+
'-ss'
|
|
3300
|
+
]
|
|
3301
|
+
]);
|
|
3302
|
+
return stdout.trim();
|
|
3303
|
+
}
|
|
3304
|
+
async function bundleName(bundleId) {
|
|
3305
|
+
return runAppleScript(`tell application "Finder" to set app_path to application file id "${bundleId}" as string\ntell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`);
|
|
3306
|
+
}
|
|
3307
|
+
let windows_execFileAsync = external_node_util_promisify(execFile), windowsBrowserProgIds = {
|
|
3308
|
+
AppXq0fevzme2pys62n3e0fbqa7peapykr8v: {
|
|
3309
|
+
name: 'Edge',
|
|
3310
|
+
id: 'com.microsoft.edge.old'
|
|
3311
|
+
},
|
|
3312
|
+
MSEdgeDHTML: {
|
|
3313
|
+
name: 'Edge',
|
|
3314
|
+
id: 'com.microsoft.edge'
|
|
3315
|
+
},
|
|
3316
|
+
MSEdgeHTM: {
|
|
3317
|
+
name: 'Edge',
|
|
3318
|
+
id: 'com.microsoft.edge'
|
|
3319
|
+
},
|
|
3320
|
+
'IE.HTTP': {
|
|
3321
|
+
name: 'Internet Explorer',
|
|
3322
|
+
id: 'com.microsoft.ie'
|
|
3323
|
+
},
|
|
3324
|
+
FirefoxURL: {
|
|
3325
|
+
name: 'Firefox',
|
|
3326
|
+
id: 'org.mozilla.firefox'
|
|
3327
|
+
},
|
|
3328
|
+
ChromeHTML: {
|
|
3329
|
+
name: 'Chrome',
|
|
3330
|
+
id: 'com.google.chrome'
|
|
3331
|
+
},
|
|
3332
|
+
BraveHTML: {
|
|
3333
|
+
name: 'Brave',
|
|
3334
|
+
id: 'com.brave.Browser'
|
|
3335
|
+
},
|
|
3336
|
+
BraveBHTML: {
|
|
3337
|
+
name: 'Brave Beta',
|
|
3338
|
+
id: 'com.brave.Browser.beta'
|
|
3339
|
+
},
|
|
3340
|
+
BraveSSHTM: {
|
|
3341
|
+
name: 'Brave Nightly',
|
|
3342
|
+
id: 'com.brave.Browser.nightly'
|
|
3343
|
+
}
|
|
3344
|
+
};
|
|
3345
|
+
class UnknownBrowserError extends Error {
|
|
3346
|
+
}
|
|
3347
|
+
async function defaultBrowser(_execFileAsync = windows_execFileAsync) {
|
|
3348
|
+
let { stdout } = await _execFileAsync('reg', [
|
|
3349
|
+
'QUERY',
|
|
3350
|
+
' HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice',
|
|
3351
|
+
'/v',
|
|
3352
|
+
'ProgId'
|
|
3353
|
+
]), match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout);
|
|
3354
|
+
if (!match) throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`);
|
|
3355
|
+
let { id } = match.groups, browser = windowsBrowserProgIds[id];
|
|
3356
|
+
if (!browser) throw new UnknownBrowserError(`Unknown browser ID: ${id}`);
|
|
3357
|
+
return browser;
|
|
3358
|
+
}
|
|
3359
|
+
let default_browser_execFileAsync = external_node_util_promisify(execFile);
|
|
3360
|
+
async function default_browser_defaultBrowser() {
|
|
3361
|
+
if ('darwin' === node_process.platform) {
|
|
3362
|
+
let id = await defaultBrowserId();
|
|
3363
|
+
return {
|
|
3364
|
+
name: await bundleName(id),
|
|
3365
|
+
id
|
|
3366
|
+
};
|
|
3367
|
+
}
|
|
3368
|
+
if ('linux' === node_process.platform) {
|
|
3369
|
+
let { stdout } = await default_browser_execFileAsync('xdg-mime', [
|
|
3370
|
+
'query',
|
|
3371
|
+
'default',
|
|
3372
|
+
'x-scheme-handler/http'
|
|
3373
|
+
]), id = stdout.trim();
|
|
3374
|
+
return {
|
|
3375
|
+
name: id.replace(/.desktop$/, '').replace('-', ' ').toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x)=>x.toUpperCase()),
|
|
3376
|
+
id
|
|
3377
|
+
};
|
|
3378
|
+
}
|
|
3379
|
+
if ('win32' === node_process.platform) return defaultBrowser();
|
|
3380
|
+
throw Error('Only macOS, Linux, and Windows are supported');
|
|
3381
|
+
}
|
|
3382
|
+
let open_execFile = node_util.promisify(node_child_process.execFile), open_dirname = node_path.dirname(fileURLToPath(import.meta.url)), localXdgOpenPath = node_path.join(open_dirname, 'xdg-open'), { platform, arch } = node_process, getWslDrivesMountPoint = (()=>{
|
|
3383
|
+
let mountPoint, defaultMountPoint = '/mnt/';
|
|
3384
|
+
return async function() {
|
|
3385
|
+
if (mountPoint) return mountPoint;
|
|
3386
|
+
let configFilePath = '/etc/wsl.conf', isConfigFileExists = !1;
|
|
3387
|
+
try {
|
|
3388
|
+
await promises.access(configFilePath, promises_constants.F_OK), isConfigFileExists = !0;
|
|
3389
|
+
} catch {}
|
|
3390
|
+
if (!isConfigFileExists) return defaultMountPoint;
|
|
3391
|
+
let configContent = await promises.readFile(configFilePath, {
|
|
3392
|
+
encoding: 'utf8'
|
|
3393
|
+
}), configMountPoint = /(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(configContent);
|
|
3394
|
+
return configMountPoint ? mountPoint = (mountPoint = configMountPoint.groups.mountPoint.trim()).endsWith('/') ? mountPoint : `${mountPoint}/` : defaultMountPoint;
|
|
3395
|
+
};
|
|
3396
|
+
})(), getPowershellPathFromWsl = async ()=>{
|
|
3397
|
+
let mountPoint = await getWslDrivesMountPoint();
|
|
3398
|
+
return `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
|
|
3399
|
+
};
|
|
3400
|
+
async function getWindowsDefaultBrowserFromWsl() {
|
|
3401
|
+
let powershellPath = await getPowershellPathFromWsl(), encodedCommand = external_node_buffer_Buffer.from('(Get-ItemProperty -Path "HKCU:\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice").ProgId', 'utf16le').toString('base64'), { stdout } = await open_execFile(powershellPath, [
|
|
3402
|
+
'-NoProfile',
|
|
3403
|
+
'-NonInteractive',
|
|
3404
|
+
'-ExecutionPolicy',
|
|
3405
|
+
'Bypass',
|
|
3406
|
+
'-EncodedCommand',
|
|
3407
|
+
encodedCommand
|
|
3408
|
+
], {
|
|
3409
|
+
encoding: 'utf8'
|
|
3410
|
+
}), progId = stdout.trim(), browserMap = {
|
|
3411
|
+
ChromeHTML: 'com.google.chrome',
|
|
3412
|
+
MSEdgeHTM: 'com.microsoft.edge',
|
|
3413
|
+
FirefoxURL: 'org.mozilla.firefox'
|
|
3414
|
+
};
|
|
3415
|
+
return browserMap[progId] ? {
|
|
3416
|
+
id: browserMap[progId]
|
|
3417
|
+
} : {};
|
|
3418
|
+
}
|
|
3419
|
+
let pTryEach = async (array, mapper)=>{
|
|
3420
|
+
let latestError;
|
|
3421
|
+
for (let item of array)try {
|
|
3422
|
+
return await mapper(item);
|
|
3423
|
+
} catch (error) {
|
|
3424
|
+
latestError = error;
|
|
3425
|
+
}
|
|
3426
|
+
throw latestError;
|
|
3427
|
+
}, baseOpen = async (options)=>{
|
|
3428
|
+
let command;
|
|
3429
|
+
if (Array.isArray((options = {
|
|
3430
|
+
wait: !1,
|
|
3431
|
+
background: !1,
|
|
3432
|
+
newInstance: !1,
|
|
3433
|
+
allowNonzeroExitCode: !1,
|
|
3434
|
+
...options
|
|
3435
|
+
}).app)) return pTryEach(options.app, (singleApp)=>baseOpen({
|
|
3436
|
+
...options,
|
|
3437
|
+
app: singleApp
|
|
3438
|
+
}));
|
|
3439
|
+
let { name: app, arguments: appArguments = [] } = options.app ?? {};
|
|
3440
|
+
if (appArguments = [
|
|
3441
|
+
...appArguments
|
|
3442
|
+
], Array.isArray(app)) return pTryEach(app, (appName)=>baseOpen({
|
|
3443
|
+
...options,
|
|
3444
|
+
app: {
|
|
3445
|
+
name: appName,
|
|
3446
|
+
arguments: appArguments
|
|
3447
|
+
}
|
|
3448
|
+
}));
|
|
3449
|
+
if ('browser' === app || 'browserPrivate' === app) {
|
|
3450
|
+
let ids = {
|
|
3451
|
+
'com.google.chrome': 'chrome',
|
|
3452
|
+
'google-chrome.desktop': 'chrome',
|
|
3453
|
+
'org.mozilla.firefox': 'firefox',
|
|
3454
|
+
'firefox.desktop': 'firefox',
|
|
3455
|
+
'com.microsoft.msedge': 'edge',
|
|
3456
|
+
'com.microsoft.edge': 'edge',
|
|
3457
|
+
'com.microsoft.edgemac': 'edge',
|
|
3458
|
+
'microsoft-edge.desktop': 'edge'
|
|
3459
|
+
}, browser = is_wsl ? await getWindowsDefaultBrowserFromWsl() : await default_browser_defaultBrowser();
|
|
3460
|
+
if (browser.id in ids) {
|
|
3461
|
+
let browserName = ids[browser.id];
|
|
3462
|
+
return 'browserPrivate' === app && appArguments.push({
|
|
3463
|
+
chrome: '--incognito',
|
|
3464
|
+
firefox: '--private-window',
|
|
3465
|
+
edge: '--inPrivate'
|
|
3466
|
+
}[browserName]), baseOpen({
|
|
3467
|
+
...options,
|
|
3468
|
+
app: {
|
|
3469
|
+
name: apps[browserName],
|
|
3470
|
+
arguments: appArguments
|
|
3471
|
+
}
|
|
3472
|
+
});
|
|
3473
|
+
}
|
|
3474
|
+
throw Error(`${browser.name} is not supported as a default browser`);
|
|
3475
|
+
}
|
|
3476
|
+
let cliArguments = [], childProcessOptions = {};
|
|
3477
|
+
if ('darwin' === platform) command = 'open', options.wait && cliArguments.push('--wait-apps'), options.background && cliArguments.push('--background'), options.newInstance && cliArguments.push('--new'), app && cliArguments.push('-a', app);
|
|
3478
|
+
else if ('win32' !== platform && (!is_wsl || isInsideContainer() || app)) {
|
|
3479
|
+
if (app) command = app;
|
|
3480
|
+
else {
|
|
3481
|
+
let exeLocalXdgOpen = !1;
|
|
3482
|
+
try {
|
|
3483
|
+
await promises.access(localXdgOpenPath, promises_constants.X_OK), exeLocalXdgOpen = !0;
|
|
3484
|
+
} catch {}
|
|
3485
|
+
command = node_process.versions.electron ?? ('android' === platform || !open_dirname || '/' === open_dirname || !exeLocalXdgOpen) ? 'xdg-open' : localXdgOpenPath;
|
|
3486
|
+
}
|
|
3487
|
+
appArguments.length > 0 && cliArguments.push(...appArguments), options.wait || (childProcessOptions.stdio = 'ignore', childProcessOptions.detached = !0);
|
|
3488
|
+
} else {
|
|
3489
|
+
command = is_wsl ? await getPowershellPathFromWsl() : `${node_process.env.SYSTEMROOT || node_process.env.windir || 'C:\\Windows'}\\System32\\WindowsPowerShell\\v1.0\\powershell`, cliArguments.push('-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass', '-EncodedCommand'), is_wsl || (childProcessOptions.windowsVerbatimArguments = !0);
|
|
3490
|
+
let encodedArguments = [
|
|
3491
|
+
'Start'
|
|
3492
|
+
];
|
|
3493
|
+
options.wait && encodedArguments.push('-Wait'), app ? (encodedArguments.push(`"\`"${app}\`""`), options.target && appArguments.push(options.target)) : options.target && encodedArguments.push(`"${options.target}"`), appArguments.length > 0 && encodedArguments.push('-ArgumentList', (appArguments = appArguments.map((argument)=>`"\`"${argument}\`""`)).join(',')), options.target = external_node_buffer_Buffer.from(encodedArguments.join(' '), 'utf16le').toString('base64');
|
|
3494
|
+
}
|
|
3495
|
+
'darwin' === platform && appArguments.length > 0 && cliArguments.push('--args', ...appArguments), options.target && cliArguments.push(options.target);
|
|
3496
|
+
let subprocess = node_child_process.spawn(command, cliArguments, childProcessOptions);
|
|
3497
|
+
return options.wait ? new Promise((resolve, reject)=>{
|
|
3498
|
+
subprocess.once('error', reject), subprocess.once('close', (exitCode)=>{
|
|
3499
|
+
if (!options.allowNonzeroExitCode && exitCode > 0) return void reject(Error(`Exited with code ${exitCode}`));
|
|
3500
|
+
resolve(subprocess);
|
|
3501
|
+
});
|
|
3502
|
+
}) : (subprocess.unref(), subprocess);
|
|
3503
|
+
};
|
|
3504
|
+
function detectArchBinary(binary) {
|
|
3505
|
+
if ('string' == typeof binary || Array.isArray(binary)) return binary;
|
|
3506
|
+
let { [arch]: archBinary } = binary;
|
|
3507
|
+
if (!archBinary) throw Error(`${arch} is not supported`);
|
|
3508
|
+
return archBinary;
|
|
3509
|
+
}
|
|
3510
|
+
function detectPlatformBinary({ [platform]: platformBinary }, { wsl }) {
|
|
3511
|
+
if (wsl && is_wsl) return detectArchBinary(wsl);
|
|
3512
|
+
if (!platformBinary) throw Error(`${platform} is not supported`);
|
|
3513
|
+
return detectArchBinary(platformBinary);
|
|
3514
|
+
}
|
|
3515
|
+
let apps = {};
|
|
3516
|
+
defineLazyProperty(apps, 'chrome', ()=>detectPlatformBinary({
|
|
3517
|
+
darwin: 'google chrome',
|
|
3518
|
+
win32: 'chrome',
|
|
3519
|
+
linux: [
|
|
3520
|
+
'google-chrome',
|
|
3521
|
+
'google-chrome-stable',
|
|
3522
|
+
'chromium'
|
|
3523
|
+
]
|
|
3524
|
+
}, {
|
|
3525
|
+
wsl: {
|
|
3526
|
+
ia32: '/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe',
|
|
3527
|
+
x64: [
|
|
3528
|
+
'/mnt/c/Program Files/Google/Chrome/Application/chrome.exe',
|
|
3529
|
+
'/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe'
|
|
3530
|
+
]
|
|
3531
|
+
}
|
|
3532
|
+
})), defineLazyProperty(apps, 'firefox', ()=>detectPlatformBinary({
|
|
3533
|
+
darwin: 'firefox',
|
|
3534
|
+
win32: 'C:\\Program Files\\Mozilla Firefox\\firefox.exe',
|
|
3535
|
+
linux: 'firefox'
|
|
3536
|
+
}, {
|
|
3537
|
+
wsl: '/mnt/c/Program Files/Mozilla Firefox/firefox.exe'
|
|
3538
|
+
})), defineLazyProperty(apps, 'edge', ()=>detectPlatformBinary({
|
|
3539
|
+
darwin: 'microsoft edge',
|
|
3540
|
+
win32: 'msedge',
|
|
3541
|
+
linux: [
|
|
3542
|
+
'microsoft-edge',
|
|
3543
|
+
'microsoft-edge-dev'
|
|
3544
|
+
]
|
|
3545
|
+
}, {
|
|
3546
|
+
wsl: '/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe'
|
|
3547
|
+
})), defineLazyProperty(apps, 'browser', ()=>'browser'), defineLazyProperty(apps, 'browserPrivate', ()=>'browserPrivate');
|
|
3548
|
+
let normalizeUrl = (url)=>url.replace(/([^:]\/)\/+/g, '$1'), joinUrlSegments = (s1, s2)=>s1 && s2 ? addTrailingSlash(s1) + removeLeadingSlash(s2) : s1 || s2 || '', stripBase = (path, base)=>{
|
|
3222
3549
|
if (path === base) return '/';
|
|
3223
3550
|
let trailingSlashBase = addTrailingSlash(base);
|
|
3224
3551
|
return path.startsWith(trailingSlashBase) ? path.slice(trailingSlashBase.length - 1) : path;
|
|
@@ -3403,19 +3730,27 @@ async function openBrowser(url) {
|
|
|
3403
3730
|
}
|
|
3404
3731
|
}
|
|
3405
3732
|
try {
|
|
3406
|
-
let
|
|
3733
|
+
let options = browser ? {
|
|
3407
3734
|
app: {
|
|
3408
3735
|
name: apps[browser] ?? browser,
|
|
3409
3736
|
arguments: null == browserArgs ? void 0 : browserArgs.split(' ')
|
|
3410
3737
|
}
|
|
3411
3738
|
} : {};
|
|
3412
|
-
return await
|
|
3739
|
+
return (await ((target, options)=>{
|
|
3740
|
+
if ('string' != typeof target) throw TypeError('Expected a `target`');
|
|
3741
|
+
return baseOpen({
|
|
3742
|
+
...options,
|
|
3743
|
+
target
|
|
3744
|
+
});
|
|
3745
|
+
})(url, options)).on('error', (err)=>{
|
|
3746
|
+
logger.error('Failed to launch browser in child process', err);
|
|
3747
|
+
}), !0;
|
|
3413
3748
|
} catch (err) {
|
|
3414
|
-
return logger.error('Failed to
|
|
3749
|
+
return logger.error('Failed to launch browser.'), logger.error(err), !1;
|
|
3415
3750
|
}
|
|
3416
3751
|
}
|
|
3417
3752
|
let openedURLs = [], replacePortPlaceholder = (url, port)=>url.replace(/<port>/g, String(port));
|
|
3418
|
-
async function
|
|
3753
|
+
async function server_open_open({ https, port, routes, config, clearCache }) {
|
|
3419
3754
|
let { targets, before } = ((config)=>{
|
|
3420
3755
|
let { open } = config.server;
|
|
3421
3756
|
return 'boolean' == typeof open ? {
|
|
@@ -3431,7 +3766,6 @@ async function open_open({ https, port, routes, config, clearCache }) {
|
|
|
3431
3766
|
before: open.before
|
|
3432
3767
|
};
|
|
3433
3768
|
})(config);
|
|
3434
|
-
if ('true' === process.env.CSB) return;
|
|
3435
3769
|
clearCache && (openedURLs = []);
|
|
3436
3770
|
let urls = [], host = await getHostInUrl(config.server.host), baseUrl = `${https ? 'https' : 'http'}://${host}:${port}`;
|
|
3437
3771
|
for (let url of (targets.length ? urls.push(...targets.map((target)=>(function(str, base) {
|
|
@@ -4950,7 +5284,7 @@ async function devServer_createDevServer(options, createCompiler, config, { comp
|
|
|
4950
5284
|
protocol,
|
|
4951
5285
|
printUrls: config.server.printUrls,
|
|
4952
5286
|
trailingLineBreak: !cliShortcutsEnabled
|
|
4953
|
-
}), openPage = async ()=>
|
|
5287
|
+
}), openPage = async ()=>server_open_open({
|
|
4954
5288
|
https,
|
|
4955
5289
|
port,
|
|
4956
5290
|
routes,
|
|
@@ -5229,7 +5563,7 @@ async function startProdServer(context, config, { getPortSilently } = {}) {
|
|
|
5229
5563
|
protocol,
|
|
5230
5564
|
printUrls: serverConfig.printUrls,
|
|
5231
5565
|
trailingLineBreak: !cliShortcutsEnabled
|
|
5232
|
-
}), openPage = async ()=>
|
|
5566
|
+
}), openPage = async ()=>server_open_open({
|
|
5233
5567
|
https,
|
|
5234
5568
|
port,
|
|
5235
5569
|
routes,
|
|
@@ -5287,7 +5621,7 @@ async function applyDefaultPlugins(pluginManager, context) {
|
|
|
5287
5621
|
...chain.get('experiments'),
|
|
5288
5622
|
rspackFuture: {
|
|
5289
5623
|
bundlerInfo: {
|
|
5290
|
-
force:
|
|
5624
|
+
force: !1
|
|
5291
5625
|
}
|
|
5292
5626
|
}
|
|
5293
5627
|
}), process.env.RSPACK_CONFIG_VALIDATE ||= 'loose-silent';
|
|
@@ -6124,7 +6458,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
6124
6458
|
let { config, browserslist } = environment, cacheRoot = node_path.join(api.context.cachePath, '.swc'), rule = chain.module.rule(CHAIN_ID.RULE.JS).test(SCRIPT_REGEX).type("javascript/auto").dependency({
|
|
6125
6459
|
not: 'url'
|
|
6126
6460
|
}).resourceQuery({
|
|
6127
|
-
not: /raw
|
|
6461
|
+
not: /raw/
|
|
6128
6462
|
});
|
|
6129
6463
|
chain.module.rule(CHAIN_ID.RULE.JS_RAW).test(SCRIPT_REGEX).type('asset/source').resourceQuery(/raw/);
|
|
6130
6464
|
let dataUriRule = chain.module.rule(CHAIN_ID.RULE.JS_DATA_URI).mimetype({
|
|
@@ -6491,7 +6825,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
6491
6825
|
let config = api.getNormalizedConfig();
|
|
6492
6826
|
if (config.server.open) {
|
|
6493
6827
|
var _api_context_devServer;
|
|
6494
|
-
|
|
6828
|
+
server_open_open({
|
|
6495
6829
|
https: null == (_api_context_devServer = api.context.devServer) ? void 0 : _api_context_devServer.https,
|
|
6496
6830
|
port,
|
|
6497
6831
|
routes,
|
|
@@ -7299,11 +7633,11 @@ async function runCLI() {
|
|
|
7299
7633
|
].includes(level) && (logger.level = level);
|
|
7300
7634
|
}
|
|
7301
7635
|
let { npm_execpath } = process.env;
|
|
7302
|
-
(!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && logger.log(), logger.greet(` Rsbuild v1.4.
|
|
7636
|
+
(!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && logger.log(), logger.greet(` Rsbuild v1.4.2\n`);
|
|
7303
7637
|
try {
|
|
7304
7638
|
!function() {
|
|
7305
7639
|
let cli = ((name = "")=>new CAC(name))('rsbuild');
|
|
7306
|
-
cli.help(), cli.version("1.4.
|
|
7640
|
+
cli.help(), cli.version("1.4.2"), cli.option('--base <base>', 'specify the base path of the server').option('-c, --config <config>', 'specify the configuration file, can be a relative or absolute path').option('--config-loader <loader>', 'specify the loader to load the config file, can be `jiti` or `native`', {
|
|
7307
7641
|
default: 'jiti'
|
|
7308
7642
|
}).option('-r, --root <root>', 'specify the project root directory, can be an absolute path or a path relative to cwd').option('-m, --mode <mode>', 'specify the build mode, can be `development`, `production` or `none`').option('--log-level <level>', 'specify the log level, can be `info`, `warn`, `error` or `silent`').option('--env-mode <mode>', 'specify the env mode to load the `.env.[mode]` file').option('--environment <name>', 'specify the name of environment to build', {
|
|
7309
7643
|
type: [
|
|
@@ -7361,5 +7695,5 @@ async function runCLI() {
|
|
|
7361
7695
|
logger.error('Failed to start Rsbuild CLI.'), logger.error(err);
|
|
7362
7696
|
}
|
|
7363
7697
|
}
|
|
7364
|
-
let src_version = "1.4.
|
|
7698
|
+
let src_version = "1.4.2";
|
|
7365
7699
|
export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, createRsbuild, defaultAllowedOrigins, defineConfig, ensureAssetPrefix, loadConfig_loadConfig as loadConfig, loadEnv, logger, mergeRsbuildConfig, rspack, runCLI, src_version as version };
|
|
@@ -13,16 +13,15 @@ export declare const getRsbuildInspectConfig: ({ normalizedConfig, inspectOption
|
|
|
13
13
|
}>;
|
|
14
14
|
environmentConfigs: InspectConfigResult["origin"]["environmentConfigs"];
|
|
15
15
|
};
|
|
16
|
-
|
|
16
|
+
type RawConfig = {
|
|
17
|
+
name: string;
|
|
18
|
+
content: string;
|
|
19
|
+
};
|
|
20
|
+
export declare function outputInspectConfigFiles({ rawBundlerConfigs, rawEnvironmentConfigs, inspectOptions, rawExtraConfigs, configType, }: {
|
|
17
21
|
configType: string;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}>;
|
|
22
|
-
rawBundlerConfigs: Array<{
|
|
23
|
-
name: string;
|
|
24
|
-
content: string;
|
|
25
|
-
}>;
|
|
22
|
+
rawExtraConfigs?: RawConfig[];
|
|
23
|
+
rawEnvironmentConfigs: RawConfig[];
|
|
24
|
+
rawBundlerConfigs: RawConfig[];
|
|
26
25
|
inspectOptions: InspectConfigOptions & {
|
|
27
26
|
outputPath: string;
|
|
28
27
|
};
|
|
@@ -33,3 +32,4 @@ export declare function inspectConfig<B extends 'rspack' | 'webpack' = 'rspack'>
|
|
|
33
32
|
bundlerConfigs: B extends 'rspack' ? Rspack.Configuration[] : WebpackConfig[];
|
|
34
33
|
bundler?: 'rspack' | 'webpack';
|
|
35
34
|
}): Promise<InspectConfigResult<B>>;
|
|
35
|
+
export {};
|
|
@@ -85,6 +85,19 @@ export type InspectConfigOptions = {
|
|
|
85
85
|
* @default false
|
|
86
86
|
*/
|
|
87
87
|
writeToDisk?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Extra configurations to be output.
|
|
90
|
+
* - key: The name of the configuration
|
|
91
|
+
* - value: The configuration object
|
|
92
|
+
* @example
|
|
93
|
+
* extraConfigs: {
|
|
94
|
+
* // Output `rstest.config.mjs` file
|
|
95
|
+
* 'rstest': {
|
|
96
|
+
* // ...
|
|
97
|
+
* },
|
|
98
|
+
* }
|
|
99
|
+
*/
|
|
100
|
+
extraConfigs?: Record<string, unknown>;
|
|
88
101
|
};
|
|
89
102
|
export type InspectConfigResult<B extends 'rspack' | 'webpack' = 'rspack'> = {
|
|
90
103
|
rsbuildConfig: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/core",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"description": "The Rspack-based build tool.",
|
|
5
5
|
"homepage": "https://rsbuild.rs",
|
|
6
6
|
"bugs": {
|
|
@@ -46,17 +46,17 @@
|
|
|
46
46
|
"types.d.ts"
|
|
47
47
|
],
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@rspack/core": "1.4.
|
|
49
|
+
"@rspack/core": "1.4.1",
|
|
50
50
|
"@rspack/lite-tapable": "~1.0.1",
|
|
51
51
|
"@swc/helpers": "^0.5.17",
|
|
52
52
|
"core-js": "~3.43.0",
|
|
53
53
|
"jiti": "^2.4.2"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@rslib/core": "0.10.
|
|
56
|
+
"@rslib/core": "0.10.3",
|
|
57
57
|
"@types/connect": "3.4.38",
|
|
58
58
|
"@types/cors": "^2.8.19",
|
|
59
|
-
"@types/node": "^22.15.
|
|
59
|
+
"@types/node": "^22.15.33",
|
|
60
60
|
"@types/on-finished": "2.3.5",
|
|
61
61
|
"@types/webpack-bundle-analyzer": "4.7.0",
|
|
62
62
|
"@types/ws": "^8.18.1",
|
|
@@ -74,15 +74,15 @@
|
|
|
74
74
|
"launch-editor-middleware": "^2.10.0",
|
|
75
75
|
"mrmime": "^2.0.1",
|
|
76
76
|
"on-finished": "2.4.1",
|
|
77
|
-
"open": "^
|
|
77
|
+
"open": "^10.1.2",
|
|
78
78
|
"picocolors": "^1.1.1",
|
|
79
79
|
"postcss": "^8.5.6",
|
|
80
80
|
"postcss-load-config": "6.0.1",
|
|
81
81
|
"postcss-loader": "8.1.1",
|
|
82
|
-
"prebundle": "1.3.
|
|
82
|
+
"prebundle": "1.3.4",
|
|
83
83
|
"reduce-configs": "^1.1.0",
|
|
84
84
|
"rsbuild-dev-middleware": "0.3.0",
|
|
85
|
-
"rslog": "^1.2.
|
|
85
|
+
"rslog": "^1.2.8",
|
|
86
86
|
"rspack-chain": "^1.2.6",
|
|
87
87
|
"rspack-manifest-plugin": "5.0.3",
|
|
88
88
|
"sirv": "^3.0.1",
|