@rsbuild/core 1.6.9 → 1.6.10

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/0~open.js CHANGED
@@ -3,7 +3,7 @@ import { __webpack_require__ } from "./rslib-runtime.js";
3
3
  import node_child_process, { execFile } from "node:child_process";
4
4
  import promises, { constants } from "node:fs/promises";
5
5
  import { Buffer } from "node:buffer";
6
- import { node_fs, node_process, node_os, external_node_util_promisify } from "./506.js";
6
+ import { node_fs, node_process, node_os, external_node_util_promisify } from "./131.js";
7
7
  function hasDockerEnv() {
8
8
  try {
9
9
  return node_fs.statSync('/.dockerenv'), !0;
@@ -1,12 +1,13 @@
1
- /*! For license information please see 506.js.LICENSE.txt */
2
- let swcHelpersPath, pluginHelper_htmlPlugin, cssExtractPlugin, hmrClientPath, overlayClientPath;
3
- let __WEBPACK_EXTERNAL_createRequire_require = __WEBPACK_EXTERNAL_createRequire(import.meta.url);
4
- import * as __WEBPACK_EXTERNAL_MODULE_async_hooks__ from "async_hooks";
5
- import * as __WEBPACK_EXTERNAL_MODULE_fs__ from "fs";
6
- import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
7
- import * as __WEBPACK_EXTERNAL_MODULE_os__ from "os";
8
- import * as __WEBPACK_EXTERNAL_MODULE_path__ from "path";
9
- import * as __WEBPACK_EXTERNAL_MODULE_url__ from "url";
1
+ /*! For license information please see 131.js.LICENSE.txt */
2
+ "use strict";
3
+ let swcHelpersPath, pluginHelper_htmlPlugin, cssExtractPlugin;
4
+ let __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
5
+ import * as __rspack_external_async_hooks from "async_hooks";
6
+ import * as __rspack_external_fs from "fs";
7
+ import * as __rspack_external_node_path_c5b9b54f from "node:path";
8
+ import * as __rspack_external_os from "os";
9
+ import * as __rspack_external_path from "path";
10
+ import * as __rspack_external_url from "url";
10
11
  import { __webpack_require__ } from "./rslib-runtime.js";
11
12
  import { EventEmitter } from "events";
12
13
  import node_fs, { existsSync } from "node:fs";
@@ -663,9 +664,9 @@ __webpack_require__.add({
663
664
  return path.dirname(p) || path.sep;
664
665
  }
665
666
  let jsonLoader = (_, content)=>JSON.parse(content), defaultLoadersSync = Object.freeze({
666
- '.js': __WEBPACK_EXTERNAL_createRequire_require,
667
- '.json': __WEBPACK_EXTERNAL_createRequire_require,
668
- '.cjs': __WEBPACK_EXTERNAL_createRequire_require,
667
+ '.js': __rspack_createRequire_require,
668
+ '.json': __rspack_createRequire_require,
669
+ '.cjs': __rspack_createRequire_require,
669
670
  noExt: jsonLoader
670
671
  });
671
672
  module.exports.defaultLoadersSync = defaultLoadersSync;
@@ -675,7 +676,7 @@ __webpack_require__.add({
675
676
  return (await import(fileUrl)).default;
676
677
  } catch (e) {
677
678
  try {
678
- return __WEBPACK_EXTERNAL_createRequire_require(id);
679
+ return __rspack_createRequire_require(id);
679
680
  } catch (requireE) {
680
681
  if ('ERR_REQUIRE_ESM' === requireE.code || requireE instanceof SyntaxError && requireE.toString().includes('Cannot use import statement outside a module')) throw e;
681
682
  throw requireE;
@@ -1587,28 +1588,28 @@ __webpack_require__.add({
1587
1588
  };
1588
1589
  },
1589
1590
  async_hooks: function(module) {
1590
- module.exports = __WEBPACK_EXTERNAL_MODULE_async_hooks__;
1591
+ module.exports = __rspack_external_async_hooks;
1591
1592
  },
1592
1593
  fs: function(module) {
1593
- module.exports = __WEBPACK_EXTERNAL_MODULE_fs__;
1594
+ module.exports = __rspack_external_fs;
1594
1595
  },
1595
1596
  "node:module": function(module) {
1596
- module.exports = __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__;
1597
+ module.exports = __rspack_external_node_module_ab9f2194;
1597
1598
  },
1598
1599
  "node:path": function(module) {
1599
- module.exports = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__;
1600
+ module.exports = __rspack_external_node_path_c5b9b54f;
1600
1601
  },
1601
1602
  "node:url": function(module) {
1602
- module.exports = __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__;
1603
+ module.exports = __rspack_external_node_url_e96de089;
1603
1604
  },
1604
1605
  os: function(module) {
1605
- module.exports = __WEBPACK_EXTERNAL_MODULE_os__;
1606
+ module.exports = __rspack_external_os;
1606
1607
  },
1607
1608
  path: function(module) {
1608
- module.exports = __WEBPACK_EXTERNAL_MODULE_path__;
1609
+ module.exports = __rspack_external_path;
1609
1610
  },
1610
1611
  url: function(module) {
1611
- module.exports = __WEBPACK_EXTERNAL_MODULE_url__;
1612
+ module.exports = __rspack_external_url;
1612
1613
  }
1613
1614
  });
1614
1615
  var superClass, superClass1, provider_helpers_namespaceObject = {};
@@ -2775,7 +2776,7 @@ function partition(array, predicate) {
2775
2776
  falsy
2776
2777
  ];
2777
2778
  }
2778
- let upperFirst = (str)=>str ? str.charAt(0).toUpperCase() + str.slice(1) : '', createVirtualModule = (content)=>`data:text/javascript,${content}`;
2779
+ let upperFirst = (str)=>str ? str.charAt(0).toUpperCase() + str.slice(1) : '', createVirtualModule = (content)=>`data:text/javascript,${encodeURIComponent(content)}`;
2779
2780
  function isWebTarget(target) {
2780
2781
  let targets = helpers_castArray(target);
2781
2782
  return targets.includes('web') || targets.includes('web-worker');
@@ -4083,7 +4084,7 @@ function createPublicContext(context) {
4083
4084
  async function createContext(options, userConfig) {
4084
4085
  let { cwd } = options, rootPath = userConfig.root ? ensureAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = (0, external_node_path_.join)(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0, bundlerType = userConfig.provider ? 'webpack' : 'rspack';
4085
4086
  return {
4086
- version: "1.6.9",
4087
+ version: "1.6.10",
4087
4088
  rootPath,
4088
4089
  distPath: '',
4089
4090
  cachePath,
@@ -4566,11 +4567,12 @@ async function initConfigs({ context, pluginManager, rsbuildOptions }) {
4566
4567
  let normalizedConfig = await initRsbuildConfig({
4567
4568
  context,
4568
4569
  pluginManager
4569
- }), rspackConfigs = await Promise.all(Object.entries(normalizedConfig.environments).map(([environmentName, config])=>generateRspackConfig({
4570
- target: config.output.target,
4571
- context,
4572
- environmentName
4573
- })));
4570
+ }), rspackConfigs = [];
4571
+ for (let [environmentName, config] of Object.entries(normalizedConfig.environments))rspackConfigs.push(await generateRspackConfig({
4572
+ target: config.output.target,
4573
+ context,
4574
+ environmentName
4575
+ }));
4574
4576
  if (isDebug()) {
4575
4577
  let inspect = async ()=>{
4576
4578
  await inspectConfig_inspectConfig({
@@ -4618,9 +4620,9 @@ function printBuildLog(compiler, context, lazyModules) {
4618
4620
  }
4619
4621
  let removedFiles = compiler.removedFiles ? Array.from(compiler.removedFiles) : null;
4620
4622
  if (removedFiles?.length) {
4623
+ if (removedFiles.every((item)=>item.includes('virtual'))) return void logger.start(`building ${color.dim('virtual modules')}`);
4621
4624
  let fileInfo = formatFileList(removedFiles, context.rootPath);
4622
- logger.start(`building ${color.dim(`removed ${fileInfo}`)}`);
4623
- return;
4625
+ return void logger.start(`building ${color.dim(`removed ${fileInfo}`)}`);
4624
4626
  }
4625
4627
  logger.start('build started...');
4626
4628
  }
@@ -6405,30 +6407,29 @@ function setupWriteToDisk(compilers, writeToDisk) {
6405
6407
  }), compiler.__hasRsbuildAssetEmittedCallback = !0);
6406
6408
  });
6407
6409
  }
6408
- let noop = ()=>{}, assets_middleware_require = (0, external_node_module_.createRequire)(import.meta.url);
6409
- function getClientPaths(devConfig) {
6410
- let clientPaths = [];
6411
- return (devConfig.hmr || devConfig.liveReload) && (hmrClientPath || (hmrClientPath = assets_middleware_require.resolve('@rsbuild/core/client/hmr')), clientPaths.push(hmrClientPath), devConfig.client?.overlay && (overlayClientPath || (overlayClientPath = assets_middleware_require.resolve('@rsbuild/core/client/overlay')), clientPaths.push(overlayClientPath))), clientPaths;
6412
- }
6413
- let isTsError = (error)=>'message' in error && error.stack?.includes('ts-checker-rspack-plugin');
6410
+ let noop = ()=>{}, isTsError = (error)=>'message' in error && error.stack?.includes('ts-checker-rspack-plugin');
6414
6411
  function applyHMREntry({ config, compiler, token, resolvedHost, resolvedPort }) {
6415
6412
  if (!((compiler)=>{
6416
6413
  let { target } = compiler.options;
6417
6414
  return !!target && (Array.isArray(target) ? target.includes('web') : 'web' === target);
6418
- })(compiler)) return;
6419
- let clientPaths = getClientPaths(config.dev);
6420
- if (!clientPaths.length) return;
6415
+ })(compiler) || !config.dev.hmr && !config.dev.liveReload) return;
6421
6416
  let clientConfig = {
6422
6417
  ...config.dev.client
6423
6418
  };
6424
- for (let clientPath of ('<port>' === clientConfig.port && (clientConfig.port = resolvedPort), new compiler.webpack.DefinePlugin({
6425
- RSBUILD_WEB_SOCKET_TOKEN: JSON.stringify(token),
6426
- RSBUILD_CLIENT_CONFIG: JSON.stringify(clientConfig),
6427
- RSBUILD_SERVER_HOST: JSON.stringify(resolvedHost),
6428
- RSBUILD_SERVER_PORT: JSON.stringify(resolvedPort),
6429
- RSBUILD_DEV_LIVE_RELOAD: config.dev.liveReload,
6430
- RSBUILD_DEV_BROWSER_LOGS: config.dev.browserLogs
6431
- }).apply(compiler), clientPaths))new compiler.webpack.EntryPlugin(compiler.context, clientPath, {
6419
+ '<port>' === clientConfig.port && (clientConfig.port = resolvedPort);
6420
+ let hmrEntry = `import { init } from '@rsbuild/core/client/hmr';
6421
+ ${config.dev.client.overlay ? "import '@rsbuild/core/client/overlay';" : ''}
6422
+
6423
+ init({
6424
+ token: '${token}',
6425
+ config: ${JSON.stringify(clientConfig)},
6426
+ serverHost: ${JSON.stringify(resolvedHost)},
6427
+ serverPort: ${resolvedPort},
6428
+ liveReload: ${config.dev.liveReload},
6429
+ browserLogs: ${!!config.dev.browserLogs}
6430
+ });
6431
+ `;
6432
+ new compiler.webpack.EntryPlugin(compiler.context, createVirtualModule(hmrEntry), {
6432
6433
  name: void 0
6433
6434
  }).apply(compiler);
6434
6435
  }
@@ -6700,13 +6701,18 @@ function ansiHTML(text) {
6700
6701
  return ansiCodes.length > 0 && (ret += Array(ansiCodes.length + 1).join('</span>')), ret;
6701
6702
  }
6702
6703
  function convertLinksInHtml(text, root) {
6703
- let pathRegex = /(?:\.\.?[/\\]|[a-zA-Z]:\\|\/)[^:]*:\d+:\d+/g, urlRegex = /(https?:\/\/(?:[\w-]+\.)+[a-z0-9](?:[\w-.~:/?#[\]@!$&'*+,;=])*)/gi;
6704
+ let PATH_RE = /(?:\.\.?[/\\]|(file:\/\/\/)?[a-zA-Z]:\\|(file:\/\/)?\/)[^:]*:\d+:\d+/g, URL_RE = /(https?:\/\/(?:[\w-]+\.)+[a-z0-9](?:[\w-.~:/?#[\]@!$&'*+,;=])*)/gi, NODE_INTERNAL_RE = /node:internal[/\\]/, FILE_URI_WINDOWS_RE = /^file:\/\/\/([A-Za-z]:)/, FILE_URI_UNIX_RE = /^file:\/\//;
6704
6705
  return text.split('\n').map((line)=>{
6705
- let replacedLine = line.replace(pathRegex, (file)=>{
6706
- let hasClosingSpan = file.includes('</span>') && !file.includes('<span'), filePath = hasClosingSpan ? file.replace('</span>', '') : file, isAbsolute = external_node_path_.default.isAbsolute(filePath), absolutePath = root && !isAbsolute ? external_node_path_.default.join(root, filePath) : filePath, relativePath = root && isAbsolute ? toRelativePath(root, filePath) : filePath;
6706
+ if (NODE_INTERNAL_RE.test(line)) return line;
6707
+ let replacedLine = line.replace(PATH_RE, (file)=>{
6708
+ let hasClosingSpan = (file = ((file)=>{
6709
+ if (!file.startsWith('file://')) return file;
6710
+ let windows = file.replace(FILE_URI_WINDOWS_RE, '$1');
6711
+ return windows !== file ? windows : file.replace(FILE_URI_UNIX_RE, '');
6712
+ })(file)).includes('</span>') && !file.includes('<span'), filePath = hasClosingSpan ? file.replace('</span>', '') : file, isAbsolute = external_node_path_.default.isAbsolute(filePath), absolutePath = root && !isAbsolute ? external_node_path_.default.join(root, filePath) : filePath, relativePath = root && isAbsolute ? toRelativePath(root, filePath) : filePath;
6707
6713
  return `<a class="file-link" data-file="${absolutePath}">${relativePath}</a>${hasClosingSpan ? '</span>' : ''}`;
6708
6714
  });
6709
- return replacedLine.replace(urlRegex, (url)=>`<a class="url-link" href="${url}" target="_blank" rel="noopener noreferrer">${url}</a>`);
6715
+ return replacedLine.replace(URL_RE, (url)=>`<a class="url-link" href="${url}" target="_blank" rel="noopener noreferrer">${url}</a>`);
6710
6716
  }).join('\n');
6711
6717
  }
6712
6718
  function genOverlayHTML(errors, root) {
@@ -6755,7 +6761,8 @@ function genOverlayHTML(errors, root) {
6755
6761
  margin: 0;
6756
6762
  font-size: 14px;
6757
6763
  font-family: inherit;
6758
- overflow-x: scroll;
6764
+ white-space: pre-wrap;
6765
+ word-break: break-all;
6759
6766
  scrollbar-width: none;
6760
6767
  }
6761
6768
  .content::-webkit-scrollbar {
@@ -7123,7 +7130,10 @@ let ENCODING_REGEX = /\bgzip\b/, CONTENT_TYPE_REGEX = /text|javascript|\/json|xm
7123
7130
  }
7124
7131
  };
7125
7132
  res.writeHead = (status, reason, headers)=>{
7126
- if (reason) for (let [key, value] of Object.entries(headers || reason))res.setHeader(key, value);
7133
+ if ('string' == typeof reason) {
7134
+ if (headers) for (let [key, value] of Object.entries(headers))res.setHeader(key, value);
7135
+ res.statusMessage = reason;
7136
+ } else if (reason) for (let [key, value] of Object.entries(reason))void 0 !== value && res.setHeader(key, value);
7127
7137
  return writeHeadStatus = status, res;
7128
7138
  }, res.write = (...args)=>(start(), gzip ? gzip.write(...args) : write.apply(res, args)), res.end = (...args)=>(start(), gzip ? gzip.end(...args) : end.apply(res, args)), res.on = (type, listener)=>(started ? gzip && 'drain' === type ? gzip.on(type, listener) : on(type, listener) : listeners.push([
7129
7139
  type,
@@ -9708,7 +9718,7 @@ let applyServerOptions = (command)=>{
9708
9718
  };
9709
9719
  function setupCommands() {
9710
9720
  let cli = ((name = "")=>new CAC(name))('rsbuild');
9711
- cli.version("1.6.9"), 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)', {
9721
+ cli.version("1.6.10"), 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)', {
9712
9722
  default: 'auto'
9713
9723
  }).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', {
9714
9724
  type: [
@@ -9777,7 +9787,7 @@ function initNodeEnv() {
9777
9787
  }
9778
9788
  function showGreeting() {
9779
9789
  let { npm_execpath, npm_lifecycle_event, NODE_RUN_SCRIPT_NAME } = process.env, isBun = npm_execpath?.includes('.bun');
9780
- logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v1.6.9\n`);
9790
+ logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v1.6.10\n`);
9781
9791
  }
9782
9792
  function setupLogLevel() {
9783
9793
  let logLevelIndex = process.argv.findIndex((item)=>'--log-level' === item || '--logLevel' === item);
@@ -9798,9 +9808,9 @@ function runCLI() {
9798
9808
  logger.error('Failed to start Rsbuild CLI.'), logger.error(err);
9799
9809
  }
9800
9810
  }
9801
- let src_version = "1.6.9";
9802
- import * as __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__ from "node:module";
9803
- import { createRequire as __WEBPACK_EXTERNAL_createRequire } from "node:module";
9804
- import * as __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__ from "node:url";
9811
+ let src_version = "1.6.10";
9812
+ import * as __rspack_external_node_module_ab9f2194 from "node:module";
9813
+ import { createRequire as __rspack_createRequire } from "node:module";
9814
+ import * as __rspack_external_node_url_e96de089 from "node:url";
9805
9815
  import { fileURLToPath as __webpack_fileURLToPath__ } from "node:url";
9806
9816
  export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, createRsbuild, defaultAllowedOrigins, defineConfig, ensureAssetPrefix, external_node_util_promisify, loadConfig_loadConfig as loadConfig, loadEnv, logger, mergeRsbuildConfig, node_fs, node_os, node_process, rspack_rspack as rspack, runCLI, src_version as version };
package/dist/136.mjs ADDED
@@ -0,0 +1,42 @@
1
+ import { createRequire } from "node:module";
2
+ import { dirname, join } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ let constants_dirname = dirname(fileURLToPath(import.meta.url));
5
+ process.platform, join(constants_dirname), join(constants_dirname, '../static');
6
+ let COMPILED_PATH = join(constants_dirname, '../compiled'), vendors_require = createRequire(import.meta.url), requireCompiledPackage = (name)=>vendors_require(`${COMPILED_PATH}/${name}/index.js`);
7
+ requireCompiledPackage('picocolors');
8
+ let transformLoader = async function transform(source, map) {
9
+ let callback = this.async(), bypass = ()=>{
10
+ callback(null, source, map);
11
+ }, { id: transformId, getEnvironment } = this.getOptions();
12
+ if (!transformId) return void bypass();
13
+ let transform = this._compiler?.__rsbuildTransformer?.[transformId];
14
+ if (!transform) return void bypass();
15
+ try {
16
+ var generatedSourceMap;
17
+ let result = await transform({
18
+ code: source,
19
+ context: this.context,
20
+ resource: this.resource,
21
+ resourcePath: this.resourcePath,
22
+ resourceQuery: this.resourceQuery,
23
+ environment: getEnvironment(),
24
+ addDependency: this.addDependency.bind(this),
25
+ addMissingDependency: this.addMissingDependency.bind(this),
26
+ addContextDependency: this.addContextDependency.bind(this),
27
+ emitFile: this.emitFile.bind(this),
28
+ importModule: this.importModule.bind(this),
29
+ resolve: this.resolve.bind(this)
30
+ });
31
+ if (null == result) return void bypass();
32
+ if ('string' == typeof result || Buffer.isBuffer(result)) return void callback(null, result, map);
33
+ let mergedMap = (generatedSourceMap = result.map, map && generatedSourceMap ? requireCompiledPackage('@jridgewell/remapping')([
34
+ generatedSourceMap,
35
+ map
36
+ ], ()=>null) : generatedSourceMap ?? map);
37
+ callback(null, result.code, mergedMap);
38
+ } catch (error) {
39
+ error instanceof Error ? callback(error) : callback(Error(String(error)));
40
+ }
41
+ };
42
+ export default transformLoader;
@@ -1,191 +1,190 @@
1
- const config = RSBUILD_CLIENT_CONFIG;
2
- const serverHost = RSBUILD_SERVER_HOST;
3
- const serverPort = RSBUILD_SERVER_PORT;
4
- const queuedMessages = [];
5
- let lastHash;
6
- let hasBuildErrors = false;
7
- function formatURL(fallback) {
8
- const { location } = self;
9
- const hostname = (fallback ? serverHost : config.host) || location.hostname;
10
- const port = (fallback ? serverPort : config.port) || location.port;
11
- const protocol = config.protocol || ('https:' === location.protocol ? 'wss' : 'ws');
12
- const pathname = config.path;
13
- if ('undefined' != typeof URL) {
14
- const url = new URL('http://localhost');
15
- url.port = String(port);
16
- url.hostname = hostname;
17
- url.protocol = protocol;
18
- url.pathname = pathname;
19
- url.searchParams.append('token', RSBUILD_WEB_SOCKET_TOKEN);
20
- return url.toString();
21
- }
22
- const colon = -1 === protocol.indexOf(':') ? ':' : '';
23
- return `${protocol}${colon}//${hostname}:${port}${pathname}?token=${RSBUILD_WEB_SOCKET_TOKEN}`;
24
- }
25
- function clearBuildErrors() {
26
- if (console.clear && hasBuildErrors) console.clear();
27
- hasBuildErrors = false;
28
- }
29
1
  let createOverlay;
30
2
  let clearOverlay;
31
3
  const registerOverlay = (createFn, clearFn)=>{
32
4
  createOverlay = createFn;
33
5
  clearOverlay = clearFn;
34
6
  };
35
- function handleSuccess() {
36
- clearBuildErrors();
37
- tryApplyUpdates();
38
- }
39
- function handleWarnings({ text }) {
40
- clearBuildErrors();
41
- for(let i = 0; i < text.length; i++){
42
- if (5 === i) {
43
- console.warn('[rsbuild] Additional warnings detected. View complete log in terminal for details.');
44
- break;
7
+ function init({ token, config, serverHost, serverPort, liveReload, browserLogs }) {
8
+ const queuedMessages = [];
9
+ let lastHash;
10
+ let hasBuildErrors = false;
11
+ function formatURL(fallback) {
12
+ const { location } = self;
13
+ const hostname = (fallback ? serverHost : config.host) || location.hostname;
14
+ const port = (fallback ? serverPort : config.port) || location.port;
15
+ const protocol = config.protocol || ('https:' === location.protocol ? 'wss' : 'ws');
16
+ const pathname = config.path;
17
+ if ('undefined' != typeof URL) {
18
+ const url = new URL('http://localhost');
19
+ url.port = String(port);
20
+ url.hostname = hostname;
21
+ url.protocol = protocol;
22
+ url.pathname = pathname;
23
+ url.searchParams.append('token', token);
24
+ return url.toString();
45
25
  }
46
- console.warn(text[i]);
26
+ const colon = -1 === protocol.indexOf(':') ? ':' : '';
27
+ return `${protocol}${colon}//${hostname}:${port}${pathname}?token=${token}`;
47
28
  }
48
- tryApplyUpdates();
49
- }
50
- function handleErrors({ text, html }) {
51
- clearBuildErrors();
52
- hasBuildErrors = true;
53
- for (const error of text)console.error(error);
54
- if (createOverlay) createOverlay(html);
55
- }
56
- const shouldUpdate = ()=>lastHash !== __webpack_hash__;
57
- const handleApplyUpdates = (err, updatedModules)=>{
58
- const forcedReload = err || !updatedModules;
59
- if (forcedReload) {
60
- if (err) console.error('[rsbuild] HMR update failed, performing full reload: ', err);
61
- reloadPage();
62
- return;
29
+ function clearBuildErrors() {
30
+ if (console.clear && hasBuildErrors) console.clear();
31
+ hasBuildErrors = false;
63
32
  }
64
- tryApplyUpdates();
65
- };
66
- function tryApplyUpdates() {
67
- if (!shouldUpdate()) return;
68
- if (import.meta.webpackHot) {
69
- if ('idle' !== import.meta.webpackHot.status()) return;
70
- import.meta.webpackHot.check(true).then((updatedModules)=>{
71
- handleApplyUpdates(null, updatedModules);
72
- }, (err)=>{
73
- handleApplyUpdates(err, null);
74
- });
75
- return;
33
+ function handleSuccess() {
34
+ clearBuildErrors();
35
+ tryApplyUpdates();
76
36
  }
77
- reloadPage();
78
- }
79
- let socket = null;
80
- let reconnectCount = 0;
81
- let pingIntervalId;
82
- const isSocketReady = ()=>socket && socket.readyState === socket.OPEN;
83
- const socketSend = (data)=>{
84
- if (isSocketReady()) socket.send(JSON.stringify(data));
85
- };
86
- function onOpen() {
87
- console.info('[rsbuild] WebSocket connected.');
88
- reconnectCount = 0;
89
- pingIntervalId = setInterval(()=>{
90
- socketSend({
91
- type: 'ping'
92
- });
93
- }, 30000);
94
- if (queuedMessages.length) {
95
- queuedMessages.forEach(socketSend);
96
- queuedMessages.length = 0;
37
+ function handleWarnings({ text }) {
38
+ clearBuildErrors();
39
+ for(let i = 0; i < text.length; i++){
40
+ if (5 === i) {
41
+ console.warn('[rsbuild] Additional warnings detected. View complete log in terminal for details.');
42
+ break;
43
+ }
44
+ console.warn(text[i]);
45
+ }
46
+ tryApplyUpdates();
97
47
  }
98
- }
99
- function onMessage(e) {
100
- const message = JSON.parse(e.data);
101
- switch(message.type){
102
- case 'hash':
103
- lastHash = message.data;
104
- if (clearOverlay && shouldUpdate()) clearOverlay();
105
- break;
106
- case 'ok':
107
- handleSuccess();
108
- break;
109
- case 'static-changed':
110
- case 'content-changed':
48
+ function handleErrors({ text, html }) {
49
+ clearBuildErrors();
50
+ hasBuildErrors = true;
51
+ for (const error of text)console.error(error);
52
+ if (createOverlay) createOverlay(html);
53
+ }
54
+ const shouldUpdate = ()=>lastHash !== __webpack_hash__;
55
+ const handleApplyUpdates = (err, updatedModules)=>{
56
+ const forcedReload = err || !updatedModules;
57
+ if (forcedReload) {
58
+ if (err) console.error('[rsbuild] HMR update failed, performing full reload: ', err);
111
59
  reloadPage();
112
- break;
113
- case 'warnings':
114
- handleWarnings(message.data);
115
- break;
116
- case 'errors':
117
- handleErrors(message.data);
118
- break;
60
+ return;
61
+ }
62
+ tryApplyUpdates();
63
+ };
64
+ function tryApplyUpdates() {
65
+ if (!shouldUpdate()) return;
66
+ if (import.meta.webpackHot) {
67
+ if ('idle' !== import.meta.webpackHot.status()) return;
68
+ import.meta.webpackHot.check(true).then((updatedModules)=>{
69
+ handleApplyUpdates(null, updatedModules);
70
+ }, (err)=>{
71
+ handleApplyUpdates(err, null);
72
+ });
73
+ return;
74
+ }
75
+ reloadPage();
119
76
  }
120
- }
121
- function onClose() {
122
- if (reconnectCount >= config.reconnect) {
123
- if (config.reconnect > 0) console.warn('[rsbuild] WebSocket connection failed after maximum retry attempts.');
124
- return;
125
- }
126
- if (0 === reconnectCount) console.info('[rsbuild] WebSocket connection lost. Reconnecting...');
127
- removeListeners();
128
- socket = null;
129
- reconnectCount++;
130
- setTimeout(connect, 1000 * 1.5 ** reconnectCount);
131
- }
132
- function onSocketError() {
133
- if (formatURL() !== formatURL(true)) {
134
- console.error('[rsbuild] WebSocket connection failed. Trying direct connection fallback.');
77
+ let socket = null;
78
+ let reconnectCount = 0;
79
+ let pingIntervalId;
80
+ const isSocketReady = ()=>socket && socket.readyState === socket.OPEN;
81
+ const socketSend = (data)=>{
82
+ if (isSocketReady()) socket.send(JSON.stringify(data));
83
+ };
84
+ function onOpen() {
85
+ console.info('[rsbuild] WebSocket connected.');
86
+ reconnectCount = 0;
87
+ pingIntervalId = setInterval(()=>{
88
+ socketSend({
89
+ type: 'ping'
90
+ });
91
+ }, 30000);
92
+ if (queuedMessages.length) {
93
+ queuedMessages.forEach(socketSend);
94
+ queuedMessages.length = 0;
95
+ }
96
+ }
97
+ function onMessage(e) {
98
+ const message = JSON.parse(e.data);
99
+ switch(message.type){
100
+ case 'hash':
101
+ lastHash = message.data;
102
+ if (clearOverlay && shouldUpdate()) clearOverlay();
103
+ break;
104
+ case 'ok':
105
+ handleSuccess();
106
+ break;
107
+ case 'static-changed':
108
+ case 'content-changed':
109
+ reloadPage();
110
+ break;
111
+ case 'warnings':
112
+ handleWarnings(message.data);
113
+ break;
114
+ case 'errors':
115
+ handleErrors(message.data);
116
+ break;
117
+ }
118
+ }
119
+ function onClose() {
120
+ if (reconnectCount >= config.reconnect) {
121
+ if (config.reconnect > 0) console.warn('[rsbuild] WebSocket connection failed after maximum retry attempts.');
122
+ return;
123
+ }
124
+ if (0 === reconnectCount) console.info('[rsbuild] WebSocket connection lost. Reconnecting...');
135
125
  removeListeners();
136
126
  socket = null;
137
- connect(true);
127
+ reconnectCount++;
128
+ setTimeout(connect, 1000 * 1.5 ** reconnectCount);
138
129
  }
139
- }
140
- function sendError(message, stack) {
141
- const messageInfo = {
142
- type: 'client-error',
143
- message,
144
- stack
145
- };
146
- if (isSocketReady()) socketSend(messageInfo);
147
- else queuedMessages.push(messageInfo);
148
- }
149
- function onUnhandledRejection({ reason }) {
150
- let message;
151
- let stack;
152
- if (reason instanceof Error) {
153
- message = reason.name ? `${reason.name}: ${reason.message}` : reason.message;
154
- stack = reason.stack;
155
- } else if ('string' == typeof reason) message = reason;
156
- else try {
157
- message = JSON.stringify(reason);
158
- } catch (_) {
159
- return;
160
- }
161
- sendError(`Uncaught (in promise) ${message}`, stack);
162
- }
163
- function connect(fallback = false) {
164
- if (0 === reconnectCount) console.info('[rsbuild] WebSocket connecting...');
165
- const socketUrl = formatURL(fallback);
166
- socket = new WebSocket(socketUrl);
167
- socket.addEventListener('open', onOpen);
168
- socket.addEventListener('close', onClose);
169
- socket.addEventListener('message', onMessage);
170
- if (!fallback) socket.addEventListener('error', onSocketError);
171
- }
172
- function removeListeners() {
173
- clearInterval(pingIntervalId);
174
- if (socket) {
175
- socket.removeEventListener('open', onOpen);
176
- socket.removeEventListener('close', onClose);
177
- socket.removeEventListener('message', onMessage);
178
- socket.removeEventListener('error', onSocketError);
130
+ function onSocketError() {
131
+ if (formatURL() !== formatURL(true)) {
132
+ console.error('[rsbuild] WebSocket connection failed. Trying direct connection fallback.');
133
+ removeListeners();
134
+ socket = null;
135
+ connect(true);
136
+ }
179
137
  }
138
+ function sendError(message, stack) {
139
+ const messageInfo = {
140
+ type: 'client-error',
141
+ message,
142
+ stack
143
+ };
144
+ if (isSocketReady()) socketSend(messageInfo);
145
+ else queuedMessages.push(messageInfo);
146
+ }
147
+ function onUnhandledRejection({ reason }) {
148
+ let message;
149
+ let stack;
150
+ if (reason instanceof Error) {
151
+ message = reason.name ? `${reason.name}: ${reason.message}` : reason.message;
152
+ stack = reason.stack;
153
+ } else if ('string' == typeof reason) message = reason;
154
+ else try {
155
+ message = JSON.stringify(reason);
156
+ } catch (_) {
157
+ return;
158
+ }
159
+ sendError(`Uncaught (in promise) ${message}`, stack);
160
+ }
161
+ function connect(fallback = false) {
162
+ if (0 === reconnectCount) console.info('[rsbuild] WebSocket connecting...');
163
+ const socketUrl = formatURL(fallback);
164
+ socket = new WebSocket(socketUrl);
165
+ socket.addEventListener('open', onOpen);
166
+ socket.addEventListener('close', onClose);
167
+ socket.addEventListener('message', onMessage);
168
+ if (!fallback) socket.addEventListener('error', onSocketError);
169
+ }
170
+ function removeListeners() {
171
+ clearInterval(pingIntervalId);
172
+ if (socket) {
173
+ socket.removeEventListener('open', onOpen);
174
+ socket.removeEventListener('close', onClose);
175
+ socket.removeEventListener('message', onMessage);
176
+ socket.removeEventListener('error', onSocketError);
177
+ }
178
+ }
179
+ function reloadPage() {
180
+ if (liveReload) window.location.reload();
181
+ }
182
+ if (browserLogs && 'undefined' != typeof window) {
183
+ window.addEventListener('error', ({ message, error })=>{
184
+ sendError(message, error instanceof Error ? error.stack : void 0);
185
+ });
186
+ window.addEventListener('unhandledrejection', onUnhandledRejection);
187
+ }
188
+ connect();
180
189
  }
181
- function reloadPage() {
182
- if (RSBUILD_DEV_LIVE_RELOAD) window.location.reload();
183
- }
184
- if (RSBUILD_DEV_BROWSER_LOGS && 'undefined' != typeof window) {
185
- window.addEventListener('error', ({ message, error })=>{
186
- sendError(message, error instanceof Error ? error.stack : void 0);
187
- });
188
- window.addEventListener('unhandledrejection', onUnhandledRejection);
189
- }
190
- connect();
191
- export { registerOverlay };
190
+ export { init, registerOverlay };
package/dist/index.cjs CHANGED
@@ -1712,7 +1712,7 @@ __webpack_require__.m = __webpack_modules__, __webpack_require__.n = (module)=>{
1712
1712
  var __webpack_exports__ = {};
1713
1713
  for(var __webpack_i__ in (()=>{
1714
1714
  "use strict";
1715
- let swcHelpersPath, pluginHelper_htmlPlugin, cssExtractPlugin, hmrClientPath, overlayClientPath;
1715
+ let swcHelpersPath, pluginHelper_htmlPlugin, cssExtractPlugin;
1716
1716
  __webpack_require__.r(__webpack_exports__), __webpack_require__.d(__webpack_exports__, {
1717
1717
  PLUGIN_SWC_NAME: ()=>PLUGIN_SWC_NAME,
1718
1718
  ensureAssetPrefix: ()=>ensureAssetPrefix,
@@ -2894,7 +2894,7 @@ ${section.body}` : section.body).join("\n\n"));
2894
2894
  falsy
2895
2895
  ];
2896
2896
  }
2897
- let upperFirst = (str)=>str ? str.charAt(0).toUpperCase() + str.slice(1) : '', createVirtualModule = (content)=>`data:text/javascript,${content}`;
2897
+ let upperFirst = (str)=>str ? str.charAt(0).toUpperCase() + str.slice(1) : '', createVirtualModule = (content)=>`data:text/javascript,${encodeURIComponent(content)}`;
2898
2898
  function isWebTarget(target) {
2899
2899
  let targets = helpers_castArray(target);
2900
2900
  return targets.includes('web') || targets.includes('web-worker');
@@ -4230,7 +4230,7 @@ ${section.body}` : section.body).join("\n\n"));
4230
4230
  async function createContext(options, userConfig) {
4231
4231
  let { cwd } = options, rootPath = userConfig.root ? ensureAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = (0, external_node_path_.join)(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0, bundlerType = userConfig.provider ? 'webpack' : 'rspack';
4232
4232
  return {
4233
- version: "1.6.9",
4233
+ version: "1.6.10",
4234
4234
  rootPath,
4235
4235
  distPath: '',
4236
4236
  cachePath,
@@ -4696,11 +4696,12 @@ ${section.body}` : section.body).join("\n\n"));
4696
4696
  let normalizedConfig = await initRsbuildConfig({
4697
4697
  context,
4698
4698
  pluginManager
4699
- }), rspackConfigs = await Promise.all(Object.entries(normalizedConfig.environments).map(([environmentName, config])=>generateRspackConfig({
4700
- target: config.output.target,
4701
- context,
4702
- environmentName
4703
- })));
4699
+ }), rspackConfigs = [];
4700
+ for (let [environmentName, config] of Object.entries(normalizedConfig.environments))rspackConfigs.push(await generateRspackConfig({
4701
+ target: config.output.target,
4702
+ context,
4703
+ environmentName
4704
+ }));
4704
4705
  if (isDebug()) {
4705
4706
  let inspect = async ()=>{
4706
4707
  await inspectConfig_inspectConfig({
@@ -4748,9 +4749,9 @@ ${section.body}` : section.body).join("\n\n"));
4748
4749
  }
4749
4750
  let removedFiles = compiler.removedFiles ? Array.from(compiler.removedFiles) : null;
4750
4751
  if (removedFiles?.length) {
4752
+ if (removedFiles.every((item)=>item.includes('virtual'))) return void logger.start(`building ${color.dim('virtual modules')}`);
4751
4753
  let fileInfo = formatFileList(removedFiles, context.rootPath);
4752
- logger.start(`building ${color.dim(`removed ${fileInfo}`)}`);
4753
- return;
4754
+ return void logger.start(`building ${color.dim(`removed ${fileInfo}`)}`);
4754
4755
  }
4755
4756
  logger.start('build started...');
4756
4757
  }
@@ -6545,30 +6546,29 @@ ${section.body}` : section.body).join("\n\n"));
6545
6546
  }), compiler.__hasRsbuildAssetEmittedCallback = !0);
6546
6547
  });
6547
6548
  }
6548
- let noop = ()=>{}, assets_middleware_require = (0, external_node_module_.createRequire)(__rslib_import_meta_url__);
6549
- function getClientPaths(devConfig) {
6550
- let clientPaths = [];
6551
- return (devConfig.hmr || devConfig.liveReload) && (hmrClientPath || (hmrClientPath = assets_middleware_require.resolve('@rsbuild/core/client/hmr')), clientPaths.push(hmrClientPath), devConfig.client?.overlay && (overlayClientPath || (overlayClientPath = assets_middleware_require.resolve('@rsbuild/core/client/overlay')), clientPaths.push(overlayClientPath))), clientPaths;
6552
- }
6553
- let isTsError = (error)=>'message' in error && error.stack?.includes('ts-checker-rspack-plugin');
6549
+ let noop = ()=>{}, isTsError = (error)=>'message' in error && error.stack?.includes('ts-checker-rspack-plugin');
6554
6550
  function applyHMREntry({ config, compiler, token, resolvedHost, resolvedPort }) {
6555
6551
  if (!((compiler)=>{
6556
6552
  let { target } = compiler.options;
6557
6553
  return !!target && (Array.isArray(target) ? target.includes('web') : 'web' === target);
6558
- })(compiler)) return;
6559
- let clientPaths = getClientPaths(config.dev);
6560
- if (!clientPaths.length) return;
6554
+ })(compiler) || !config.dev.hmr && !config.dev.liveReload) return;
6561
6555
  let clientConfig = {
6562
6556
  ...config.dev.client
6563
6557
  };
6564
- for (let clientPath of ('<port>' === clientConfig.port && (clientConfig.port = resolvedPort), new compiler.webpack.DefinePlugin({
6565
- RSBUILD_WEB_SOCKET_TOKEN: JSON.stringify(token),
6566
- RSBUILD_CLIENT_CONFIG: JSON.stringify(clientConfig),
6567
- RSBUILD_SERVER_HOST: JSON.stringify(resolvedHost),
6568
- RSBUILD_SERVER_PORT: JSON.stringify(resolvedPort),
6569
- RSBUILD_DEV_LIVE_RELOAD: config.dev.liveReload,
6570
- RSBUILD_DEV_BROWSER_LOGS: config.dev.browserLogs
6571
- }).apply(compiler), clientPaths))new compiler.webpack.EntryPlugin(compiler.context, clientPath, {
6558
+ '<port>' === clientConfig.port && (clientConfig.port = resolvedPort);
6559
+ let hmrEntry = `import { init } from '@rsbuild/core/client/hmr';
6560
+ ${config.dev.client.overlay ? "import '@rsbuild/core/client/overlay';" : ''}
6561
+
6562
+ init({
6563
+ token: '${token}',
6564
+ config: ${JSON.stringify(clientConfig)},
6565
+ serverHost: ${JSON.stringify(resolvedHost)},
6566
+ serverPort: ${resolvedPort},
6567
+ liveReload: ${config.dev.liveReload},
6568
+ browserLogs: ${!!config.dev.browserLogs}
6569
+ });
6570
+ `;
6571
+ new compiler.webpack.EntryPlugin(compiler.context, createVirtualModule(hmrEntry), {
6572
6572
  name: void 0
6573
6573
  }).apply(compiler);
6574
6574
  }
@@ -6841,13 +6841,18 @@ ${section.body}` : section.body).join("\n\n"));
6841
6841
  return ansiCodes.length > 0 && (ret += Array(ansiCodes.length + 1).join('</span>')), ret;
6842
6842
  }
6843
6843
  function convertLinksInHtml(text, root) {
6844
- let pathRegex = /(?:\.\.?[/\\]|[a-zA-Z]:\\|\/)[^:]*:\d+:\d+/g, urlRegex = /(https?:\/\/(?:[\w-]+\.)+[a-z0-9](?:[\w-.~:/?#[\]@!$&'*+,;=])*)/gi;
6844
+ let PATH_RE = /(?:\.\.?[/\\]|(file:\/\/\/)?[a-zA-Z]:\\|(file:\/\/)?\/)[^:]*:\d+:\d+/g, URL_RE = /(https?:\/\/(?:[\w-]+\.)+[a-z0-9](?:[\w-.~:/?#[\]@!$&'*+,;=])*)/gi, NODE_INTERNAL_RE = /node:internal[/\\]/, FILE_URI_WINDOWS_RE = /^file:\/\/\/([A-Za-z]:)/, FILE_URI_UNIX_RE = /^file:\/\//;
6845
6845
  return text.split('\n').map((line)=>{
6846
- let replacedLine = line.replace(pathRegex, (file)=>{
6847
- let hasClosingSpan = file.includes('</span>') && !file.includes('<span'), filePath = hasClosingSpan ? file.replace('</span>', '') : file, isAbsolute = external_node_path_default().isAbsolute(filePath), absolutePath = root && !isAbsolute ? external_node_path_default().join(root, filePath) : filePath, relativePath = root && isAbsolute ? toRelativePath(root, filePath) : filePath;
6846
+ if (NODE_INTERNAL_RE.test(line)) return line;
6847
+ let replacedLine = line.replace(PATH_RE, (file)=>{
6848
+ let hasClosingSpan = (file = ((file)=>{
6849
+ if (!file.startsWith('file://')) return file;
6850
+ let windows = file.replace(FILE_URI_WINDOWS_RE, '$1');
6851
+ return windows !== file ? windows : file.replace(FILE_URI_UNIX_RE, '');
6852
+ })(file)).includes('</span>') && !file.includes('<span'), filePath = hasClosingSpan ? file.replace('</span>', '') : file, isAbsolute = external_node_path_default().isAbsolute(filePath), absolutePath = root && !isAbsolute ? external_node_path_default().join(root, filePath) : filePath, relativePath = root && isAbsolute ? toRelativePath(root, filePath) : filePath;
6848
6853
  return `<a class="file-link" data-file="${absolutePath}">${relativePath}</a>${hasClosingSpan ? '</span>' : ''}`;
6849
6854
  });
6850
- return replacedLine = replacedLine.replace(urlRegex, (url)=>`<a class="url-link" href="${url}" target="_blank" rel="noopener noreferrer">${url}</a>`);
6855
+ return replacedLine = replacedLine.replace(URL_RE, (url)=>`<a class="url-link" href="${url}" target="_blank" rel="noopener noreferrer">${url}</a>`);
6851
6856
  }).join('\n');
6852
6857
  }
6853
6858
  function genOverlayHTML(errors, root) {
@@ -6896,7 +6901,8 @@ ${section.body}` : section.body).join("\n\n"));
6896
6901
  margin: 0;
6897
6902
  font-size: 14px;
6898
6903
  font-family: inherit;
6899
- overflow-x: scroll;
6904
+ white-space: pre-wrap;
6905
+ word-break: break-all;
6900
6906
  scrollbar-width: none;
6901
6907
  }
6902
6908
  .content::-webkit-scrollbar {
@@ -7264,7 +7270,10 @@ ${section.body}` : section.body).join("\n\n"));
7264
7270
  }
7265
7271
  };
7266
7272
  res.writeHead = (status, reason, headers)=>{
7267
- if (reason) for (let [key, value] of Object.entries(headers || reason))res.setHeader(key, value);
7273
+ if ('string' == typeof reason) {
7274
+ if (headers) for (let [key, value] of Object.entries(headers))res.setHeader(key, value);
7275
+ res.statusMessage = reason;
7276
+ } else if (reason) for (let [key, value] of Object.entries(reason))void 0 !== value && res.setHeader(key, value);
7268
7277
  return writeHeadStatus = status, res;
7269
7278
  }, res.write = (...args)=>(start(), gzip ? gzip.write(...args) : write.apply(res, args)), res.end = (...args)=>(start(), gzip ? gzip.end(...args) : end.apply(res, args)), res.on = (type, listener)=>(started ? gzip && 'drain' === type ? gzip.on(type, listener) : on(type, listener) : listeners.push([
7270
7279
  type,
@@ -9856,7 +9865,7 @@ try {
9856
9865
  };
9857
9866
  function setupCommands() {
9858
9867
  let cli = ((name = "")=>new CAC(name))('rsbuild');
9859
- cli.version("1.6.9"), 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)', {
9868
+ cli.version("1.6.10"), 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)', {
9860
9869
  default: 'auto'
9861
9870
  }).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', {
9862
9871
  type: [
@@ -9925,7 +9934,7 @@ try {
9925
9934
  }
9926
9935
  function showGreeting() {
9927
9936
  let { npm_execpath, npm_lifecycle_event, NODE_RUN_SCRIPT_NAME } = process.env, isBun = npm_execpath?.includes('.bun');
9928
- logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v1.6.9\n`);
9937
+ logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v1.6.10\n`);
9929
9938
  }
9930
9939
  function setupLogLevel() {
9931
9940
  let logLevelIndex = process.argv.findIndex((item)=>'--log-level' === item || '--logLevel' === item);
@@ -9946,7 +9955,7 @@ try {
9946
9955
  logger.error('Failed to start Rsbuild CLI.'), logger.error(err);
9947
9956
  }
9948
9957
  }
9949
- let src_version = "1.6.9";
9958
+ let src_version = "1.6.10";
9950
9959
  })(), exports.PLUGIN_CSS_NAME = __webpack_exports__.PLUGIN_CSS_NAME, exports.PLUGIN_SWC_NAME = __webpack_exports__.PLUGIN_SWC_NAME, exports.createRsbuild = __webpack_exports__.createRsbuild, exports.defaultAllowedOrigins = __webpack_exports__.defaultAllowedOrigins, exports.defineConfig = __webpack_exports__.defineConfig, exports.ensureAssetPrefix = __webpack_exports__.ensureAssetPrefix, exports.loadConfig = __webpack_exports__.loadConfig, exports.loadEnv = __webpack_exports__.loadEnv, exports.logger = __webpack_exports__.logger, exports.mergeRsbuildConfig = __webpack_exports__.mergeRsbuildConfig, exports.rspack = __webpack_exports__.rspack, exports.runCLI = __webpack_exports__.runCLI, exports.version = __webpack_exports__.version, __webpack_exports__)-1 === [
9951
9960
  "PLUGIN_CSS_NAME",
9952
9961
  "PLUGIN_SWC_NAME",
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, createRsbuild, defaultAllowedOrigins, defineConfig, ensureAssetPrefix, loadConfig, loadEnv, logger, mergeRsbuildConfig, rspack, runCLI, version } from "./506.js";
1
+ export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, createRsbuild, defaultAllowedOrigins, defineConfig, ensureAssetPrefix, loadConfig, loadEnv, logger, mergeRsbuildConfig, rspack, runCLI, version } from "./131.js";
@@ -1,36 +1 @@
1
- import { requireCompiledPackage } from "./476.mjs";
2
- let transformLoader = async function transform(source, map) {
3
- let callback = this.async(), bypass = ()=>{
4
- callback(null, source, map);
5
- }, { id: transformId, getEnvironment } = this.getOptions();
6
- if (!transformId) return void bypass();
7
- let transform = this._compiler?.__rsbuildTransformer?.[transformId];
8
- if (!transform) return void bypass();
9
- try {
10
- var generatedSourceMap;
11
- let result = await transform({
12
- code: source,
13
- context: this.context,
14
- resource: this.resource,
15
- resourcePath: this.resourcePath,
16
- resourceQuery: this.resourceQuery,
17
- environment: getEnvironment(),
18
- addDependency: this.addDependency.bind(this),
19
- addMissingDependency: this.addMissingDependency.bind(this),
20
- addContextDependency: this.addContextDependency.bind(this),
21
- emitFile: this.emitFile.bind(this),
22
- importModule: this.importModule.bind(this),
23
- resolve: this.resolve.bind(this)
24
- });
25
- if (null == result) return void bypass();
26
- if ('string' == typeof result || Buffer.isBuffer(result)) return void callback(null, result, map);
27
- let mergedMap = (generatedSourceMap = result.map, map && generatedSourceMap ? requireCompiledPackage('@jridgewell/remapping')([
28
- generatedSourceMap,
29
- map
30
- ], ()=>null) : generatedSourceMap ?? map);
31
- callback(null, result.code, mergedMap);
32
- } catch (error) {
33
- error instanceof Error ? callback(error) : callback(Error(String(error)));
34
- }
35
- };
36
- export default transformLoader;
1
+ export { default } from "./136.mjs";
@@ -1,37 +1,4 @@
1
- import { requireCompiledPackage } from "./476.mjs";
2
- let transformLoader = async function transform(source, map) {
3
- let callback = this.async(), bypass = ()=>{
4
- callback(null, source, map);
5
- }, { id: transformId, getEnvironment } = this.getOptions();
6
- if (!transformId) return void bypass();
7
- let transform = this._compiler?.__rsbuildTransformer?.[transformId];
8
- if (!transform) return void bypass();
9
- try {
10
- var generatedSourceMap;
11
- let result = await transform({
12
- code: source,
13
- context: this.context,
14
- resource: this.resource,
15
- resourcePath: this.resourcePath,
16
- resourceQuery: this.resourceQuery,
17
- environment: getEnvironment(),
18
- addDependency: this.addDependency.bind(this),
19
- addMissingDependency: this.addMissingDependency.bind(this),
20
- addContextDependency: this.addContextDependency.bind(this),
21
- emitFile: this.emitFile.bind(this),
22
- importModule: this.importModule.bind(this),
23
- resolve: this.resolve.bind(this)
24
- });
25
- if (null == result) return void bypass();
26
- if ('string' == typeof result || Buffer.isBuffer(result)) return void callback(null, result, map);
27
- let mergedMap = (generatedSourceMap = result.map, map && generatedSourceMap ? requireCompiledPackage('@jridgewell/remapping')([
28
- generatedSourceMap,
29
- map
30
- ], ()=>null) : generatedSourceMap ?? map);
31
- callback(null, result.code, mergedMap);
32
- } catch (error) {
33
- error instanceof Error ? callback(error) : callback(Error(String(error)));
34
- }
35
- }, raw = !0;
36
- export default transformLoader;
1
+ import { default as loader_transformLoader } from "./136.mjs";
2
+ let raw = !0;
3
+ export default loader_transformLoader;
37
4
  export { raw };
@@ -1 +1,10 @@
1
+ import type { NormalizedClientConfig } from '../types';
1
2
  export declare const registerOverlay: (createFn: (html: string) => void, clearFn: () => void) => void;
3
+ export declare function init({ token, config, serverHost, serverPort, liveReload, browserLogs, }: {
4
+ token: string;
5
+ config: NormalizedClientConfig;
6
+ serverHost: string;
7
+ serverPort: number;
8
+ liveReload: boolean;
9
+ browserLogs: boolean;
10
+ }): void;
@@ -1,3 +1,11 @@
1
+ /**
2
+ * The assets middleware is modified based on
3
+ * https://github.com/webpack/webpack-dev-middleware
4
+ *
5
+ * MIT Licensed
6
+ * Copyright JS Foundation and other contributors
7
+ * https://github.com/webpack/webpack-dev-middleware/blob/master/LICENSE
8
+ */
1
9
  import type { Compiler, MultiCompiler } from '@rspack/core';
2
10
  import type { InternalContext, NormalizedConfig, RequestHandler } from '../../types';
3
11
  import type { SocketServer } from '../socketServer';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/core",
3
- "version": "1.6.9",
3
+ "version": "1.6.10",
4
4
  "description": "The Rspack-based build tool.",
5
5
  "homepage": "https://rsbuild.rs",
6
6
  "bugs": {
@@ -55,7 +55,7 @@
55
55
  "devDependencies": {
56
56
  "@jridgewell/remapping": "^2.3.5",
57
57
  "@jridgewell/trace-mapping": "^0.3.31",
58
- "@rslib/core": "0.18.0",
58
+ "@rslib/core": "0.18.2",
59
59
  "@types/connect": "3.4.38",
60
60
  "@types/cors": "^2.8.19",
61
61
  "@types/node": "^24.10.1",
package/dist/476.mjs DELETED
@@ -1,8 +0,0 @@
1
- import { createRequire } from "node:module";
2
- import { dirname, join } from "node:path";
3
- import { fileURLToPath } from "node:url";
4
- let constants_dirname = dirname(fileURLToPath(import.meta.url));
5
- process.platform, join(constants_dirname), join(constants_dirname, '../static');
6
- let COMPILED_PATH = join(constants_dirname, '../compiled'), vendors_require = createRequire(import.meta.url), requireCompiledPackage = (name)=>vendors_require(`${COMPILED_PATH}/${name}/index.js`);
7
- requireCompiledPackage('picocolors');
8
- export { requireCompiledPackage };
File without changes