@rsbuild/core 1.4.1 → 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/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.1",
2065
+ version: "1.4.2",
2063
2066
  rootPath,
2064
2067
  distPath: '',
2065
2068
  cachePath,
@@ -3227,7 +3230,322 @@ let getInlineTests = (config)=>{
3227
3230
  scriptTests,
3228
3231
  styleTests
3229
3232
  };
3230
- }, normalizeUrl = (url)=>url.replace(/([^:]\/)\/+/g, '$1'), joinUrlSegments = (s1, s2)=>s1 && s2 ? addTrailingSlash(s1) + removeLeadingSlash(s2) : s1 || s2 || '', stripBase = (path, base)=>{
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)=>{
3231
3549
  if (path === base) return '/';
3232
3550
  let trailingSlashBase = addTrailingSlash(base);
3233
3551
  return path.startsWith(trailingSlashBase) ? path.slice(trailingSlashBase.length - 1) : path;
@@ -3412,19 +3730,27 @@ async function openBrowser(url) {
3412
3730
  }
3413
3731
  }
3414
3732
  try {
3415
- let { default: open } = await import("../compiled/open/index.js"), { apps } = open, options = browser ? {
3733
+ let options = browser ? {
3416
3734
  app: {
3417
3735
  name: apps[browser] ?? browser,
3418
3736
  arguments: null == browserArgs ? void 0 : browserArgs.split(' ')
3419
3737
  }
3420
3738
  } : {};
3421
- return await open(url, options), !0;
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;
3422
3748
  } catch (err) {
3423
- return logger.error('Failed to open start URL.'), logger.error(err), !1;
3749
+ return logger.error('Failed to launch browser.'), logger.error(err), !1;
3424
3750
  }
3425
3751
  }
3426
3752
  let openedURLs = [], replacePortPlaceholder = (url, port)=>url.replace(/<port>/g, String(port));
3427
- async function open_open({ https, port, routes, config, clearCache }) {
3753
+ async function server_open_open({ https, port, routes, config, clearCache }) {
3428
3754
  let { targets, before } = ((config)=>{
3429
3755
  let { open } = config.server;
3430
3756
  return 'boolean' == typeof open ? {
@@ -3440,7 +3766,6 @@ async function open_open({ https, port, routes, config, clearCache }) {
3440
3766
  before: open.before
3441
3767
  };
3442
3768
  })(config);
3443
- if ('true' === process.env.CSB) return;
3444
3769
  clearCache && (openedURLs = []);
3445
3770
  let urls = [], host = await getHostInUrl(config.server.host), baseUrl = `${https ? 'https' : 'http'}://${host}:${port}`;
3446
3771
  for (let url of (targets.length ? urls.push(...targets.map((target)=>(function(str, base) {
@@ -4959,7 +5284,7 @@ async function devServer_createDevServer(options, createCompiler, config, { comp
4959
5284
  protocol,
4960
5285
  printUrls: config.server.printUrls,
4961
5286
  trailingLineBreak: !cliShortcutsEnabled
4962
- }), openPage = async ()=>open_open({
5287
+ }), openPage = async ()=>server_open_open({
4963
5288
  https,
4964
5289
  port,
4965
5290
  routes,
@@ -5238,7 +5563,7 @@ async function startProdServer(context, config, { getPortSilently } = {}) {
5238
5563
  protocol,
5239
5564
  printUrls: serverConfig.printUrls,
5240
5565
  trailingLineBreak: !cliShortcutsEnabled
5241
- }), openPage = async ()=>open_open({
5566
+ }), openPage = async ()=>server_open_open({
5242
5567
  https,
5243
5568
  port,
5244
5569
  routes,
@@ -5296,7 +5621,7 @@ async function applyDefaultPlugins(pluginManager, context) {
5296
5621
  ...chain.get('experiments'),
5297
5622
  rspackFuture: {
5298
5623
  bundlerInfo: {
5299
- force: !!config.security.sri.enable
5624
+ force: !1
5300
5625
  }
5301
5626
  }
5302
5627
  }), process.env.RSPACK_CONFIG_VALIDATE ||= 'loose-silent';
@@ -6133,7 +6458,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6133
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({
6134
6459
  not: 'url'
6135
6460
  }).resourceQuery({
6136
- not: /raw|inline/
6461
+ not: /raw/
6137
6462
  });
6138
6463
  chain.module.rule(CHAIN_ID.RULE.JS_RAW).test(SCRIPT_REGEX).type('asset/source').resourceQuery(/raw/);
6139
6464
  let dataUriRule = chain.module.rule(CHAIN_ID.RULE.JS_DATA_URI).mimetype({
@@ -6500,7 +6825,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6500
6825
  let config = api.getNormalizedConfig();
6501
6826
  if (config.server.open) {
6502
6827
  var _api_context_devServer;
6503
- open_open({
6828
+ server_open_open({
6504
6829
  https: null == (_api_context_devServer = api.context.devServer) ? void 0 : _api_context_devServer.https,
6505
6830
  port,
6506
6831
  routes,
@@ -7308,11 +7633,11 @@ async function runCLI() {
7308
7633
  ].includes(level) && (logger.level = level);
7309
7634
  }
7310
7635
  let { npm_execpath } = process.env;
7311
- (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && logger.log(), logger.greet(` Rsbuild v1.4.1\n`);
7636
+ (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && logger.log(), logger.greet(` Rsbuild v1.4.2\n`);
7312
7637
  try {
7313
7638
  !function() {
7314
7639
  let cli = ((name = "")=>new CAC(name))('rsbuild');
7315
- cli.help(), cli.version("1.4.1"), 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`', {
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`', {
7316
7641
  default: 'jiti'
7317
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', {
7318
7643
  type: [
@@ -7370,5 +7695,5 @@ async function runCLI() {
7370
7695
  logger.error('Failed to start Rsbuild CLI.'), logger.error(err);
7371
7696
  }
7372
7697
  }
7373
- let src_version = "1.4.1";
7698
+ let src_version = "1.4.2";
7374
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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/core",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "description": "The Rspack-based build tool.",
5
5
  "homepage": "https://rsbuild.rs",
6
6
  "bugs": {
@@ -74,12 +74,12 @@
74
74
  "launch-editor-middleware": "^2.10.0",
75
75
  "mrmime": "^2.0.1",
76
76
  "on-finished": "2.4.1",
77
- "open": "^8.4.0",
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.3",
82
+ "prebundle": "1.3.4",
83
83
  "reduce-configs": "^1.1.0",
84
84
  "rsbuild-dev-middleware": "0.3.0",
85
85
  "rslog": "^1.2.8",
@@ -1,153 +0,0 @@
1
- import { ChildProcess } from 'child_process';
2
-
3
- declare namespace open {
4
- interface Options {
5
- /**
6
- Wait for the opened app to exit before fulfilling the promise. If `false` it's fulfilled immediately when opening the app.
7
-
8
- Note that it waits for the app to exit, not just for the window to close.
9
-
10
- On Windows, you have to explicitly specify an app for it to be able to wait.
11
-
12
- @default false
13
- */
14
- readonly wait?: boolean;
15
-
16
- /**
17
- __macOS only__
18
-
19
- Do not bring the app to the foreground.
20
-
21
- @default false
22
- */
23
- readonly background?: boolean;
24
-
25
- /**
26
- __macOS only__
27
-
28
- Open a new instance of the app even it's already running.
29
-
30
- A new instance is always opened on other platforms.
31
-
32
- @default false
33
- */
34
- readonly newInstance?: boolean;
35
-
36
- /**
37
- Specify the `name` of the app to open the `target` with, and optionally, app `arguments`. `app` can be an array of apps to try to open and `name` can be an array of app names to try. If each app fails, the last error will be thrown.
38
-
39
- The app name is platform dependent. Don't hard code it in reusable modules. For example, Chrome is `google chrome` on macOS, `google-chrome` on Linux and `chrome` on Windows. If possible, use [`open.apps`](#openapps) which auto-detects the correct binary to use.
40
-
41
- You may also pass in the app's full path. For example on WSL, this can be `/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe` for the Windows installation of Chrome.
42
-
43
- The app `arguments` are app dependent. Check the app's documentation for what arguments it accepts.
44
- */
45
- readonly app?: App | readonly App[];
46
-
47
- /**
48
- Allow the opened app to exit with nonzero exit code when the `wait` option is `true`.
49
-
50
- We do not recommend setting this option. The convention for success is exit code zero.
51
-
52
- @default false
53
- */
54
- readonly allowNonzeroExitCode?: boolean;
55
- }
56
-
57
- interface OpenAppOptions extends Omit<Options, 'app'> {
58
- /**
59
- Arguments passed to the app.
60
-
61
- These arguments are app dependent. Check the app's documentation for what arguments it accepts.
62
- */
63
- readonly arguments?: readonly string[];
64
- }
65
-
66
- type AppName =
67
- | 'chrome'
68
- | 'firefox'
69
- | 'edge';
70
-
71
- type App = {
72
- name: string | readonly string[];
73
- arguments?: readonly string[];
74
- };
75
- }
76
-
77
- // eslint-disable-next-line no-redeclare
78
- declare const open: {
79
- /**
80
- Open stuff like URLs, files, executables. Cross-platform.
81
-
82
- Uses the command `open` on macOS, `start` on Windows and `xdg-open` on other platforms.
83
-
84
- There is a caveat for [double-quotes on Windows](https://github.com/sindresorhus/open#double-quotes-on-windows) where all double-quotes are stripped from the `target`.
85
-
86
- @param target - The thing you want to open. Can be a URL, file, or executable. Opens in the default app for the file type. For example, URLs open in your default browser.
87
- @returns The [spawned child process](https://nodejs.org/api/child_process.html#child_process_class_childprocess). You would normally not need to use this for anything, but it can be useful if you'd like to attach custom event listeners or perform other operations directly on the spawned process.
88
-
89
- @example
90
- ```
91
- import open = require('open');
92
-
93
- // Opens the image in the default image viewer
94
- await open('unicorn.png', {wait: true});
95
- console.log('The image viewer app closed');
96
-
97
- // Opens the url in the default browser
98
- await open('https://sindresorhus.com');
99
-
100
- // Opens the URL in a specified browser.
101
- await open('https://sindresorhus.com', {app: {name: 'firefox'}});
102
-
103
- // Specify app arguments.
104
- await open('https://sindresorhus.com', {app: {name: 'google chrome', arguments: ['--incognito']}});
105
- ```
106
- */
107
- (
108
- target: string,
109
- options?: open.Options
110
- ): Promise<ChildProcess>;
111
-
112
- /**
113
- An object containing auto-detected binary names for common apps. Useful to work around cross-platform differences.
114
-
115
- @example
116
- ```
117
- import open = require('open');
118
-
119
- await open('https://google.com', {
120
- app: {
121
- name: open.apps.chrome
122
- }
123
- });
124
- ```
125
- */
126
- apps: Record<open.AppName, string | readonly string[]>;
127
-
128
- /**
129
- Open an app. Cross-platform.
130
-
131
- Uses the command `open` on macOS, `start` on Windows and `xdg-open` on other platforms.
132
-
133
- @param name - The app you want to open. Can be either builtin supported `open.apps` names or other name supported in platform.
134
- @returns The [spawned child process](https://nodejs.org/api/child_process.html#child_process_class_childprocess). You would normally not need to use this for anything, but it can be useful if you'd like to attach custom event listeners or perform other operations directly on the spawned process.
135
-
136
- @example
137
- ```
138
- const {apps, openApp} = require('open');
139
-
140
- // Open Firefox
141
- await openApp(apps.firefox);
142
-
143
- // Open Chrome incognito mode
144
- await openApp(apps.chrome, {arguments: ['--incognito']});
145
-
146
- // Open Xcode
147
- await openApp('xcode');
148
- ```
149
- */
150
- openApp: (name: open.App['name'], options?: open.OpenAppOptions) => Promise<ChildProcess>;
151
- };
152
-
153
- export { open as default };