@rsbuild/core 1.3.22 → 1.4.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -983,7 +983,7 @@
983
983
  6069: (module, __unused_webpack_exports, __nccwpck_require__) => {
984
984
  module.exports = __nccwpck_require__(3344).version;
985
985
  },
986
- 9847: (__unused_webpack_module, exports, __nccwpck_require__) => {
986
+ 2600: (__unused_webpack_module, exports, __nccwpck_require__) => {
987
987
  const qs = __nccwpck_require__(3480);
988
988
  function parse(req) {
989
989
  let raw = req.url;
@@ -992,18 +992,24 @@
992
992
  if (prev && prev.raw === raw) return prev;
993
993
  let pathname = raw,
994
994
  search = "",
995
- query;
995
+ query,
996
+ hash;
996
997
  if (raw.length > 1) {
997
- let idx = raw.indexOf("?", 1);
998
+ let idx = raw.indexOf("#", 1);
998
999
  if (idx !== -1) {
999
- search = raw.substring(idx);
1000
+ hash = raw.substring(idx);
1000
1001
  pathname = raw.substring(0, idx);
1002
+ }
1003
+ idx = pathname.indexOf("?", 1);
1004
+ if (idx !== -1) {
1005
+ search = pathname.substring(idx);
1006
+ pathname = pathname.substring(0, idx);
1001
1007
  if (search.length > 1) {
1002
1008
  query = qs.parse(search.substring(1));
1003
1009
  }
1004
1010
  }
1005
1011
  }
1006
- return (req._parsedUrl = { pathname, search, query, raw });
1012
+ return (req._parsedUrl = { pathname, search, query, hash, raw });
1007
1013
  }
1008
1014
  exports.parse = parse;
1009
1015
  },
@@ -1542,7 +1548,7 @@
1542
1548
  exports.simple = simple;
1543
1549
  });
1544
1550
  },
1545
- 8024: function (__unused_webpack_module, exports) {
1551
+ 2424: function (__unused_webpack_module, exports) {
1546
1552
  (function (global, factory) {
1547
1553
  true ? factory(exports) : 0;
1548
1554
  })(this, function (exports) {
@@ -1992,6 +1998,7 @@
1992
1998
  SCOPE_SUPER = 64,
1993
1999
  SCOPE_DIRECT_SUPER = 128,
1994
2000
  SCOPE_CLASS_STATIC_BLOCK = 256,
2001
+ SCOPE_CLASS_FIELD_INIT = 512,
1995
2002
  SCOPE_VAR = SCOPE_TOP | SCOPE_FUNCTION | SCOPE_CLASS_STATIC_BLOCK;
1996
2003
  function functionFlags(async, generator) {
1997
2004
  return (
@@ -2094,28 +2101,20 @@
2094
2101
  return (this.currentVarScope().flags & SCOPE_FUNCTION) > 0;
2095
2102
  };
2096
2103
  prototypeAccessors.inGenerator.get = function () {
2097
- return (
2098
- (this.currentVarScope().flags & SCOPE_GENERATOR) > 0 &&
2099
- !this.currentVarScope().inClassFieldInit
2100
- );
2104
+ return (this.currentVarScope().flags & SCOPE_GENERATOR) > 0;
2101
2105
  };
2102
2106
  prototypeAccessors.inAsync.get = function () {
2103
- return (
2104
- (this.currentVarScope().flags & SCOPE_ASYNC) > 0 &&
2105
- !this.currentVarScope().inClassFieldInit
2106
- );
2107
+ return (this.currentVarScope().flags & SCOPE_ASYNC) > 0;
2107
2108
  };
2108
2109
  prototypeAccessors.canAwait.get = function () {
2109
2110
  for (var i = this.scopeStack.length - 1; i >= 0; i--) {
2110
- var scope = this.scopeStack[i];
2111
- if (
2112
- scope.inClassFieldInit ||
2113
- scope.flags & SCOPE_CLASS_STATIC_BLOCK
2114
- ) {
2111
+ var ref = this.scopeStack[i];
2112
+ var flags = ref.flags;
2113
+ if (flags & (SCOPE_CLASS_STATIC_BLOCK | SCOPE_CLASS_FIELD_INIT)) {
2115
2114
  return false;
2116
2115
  }
2117
- if (scope.flags & SCOPE_FUNCTION) {
2118
- return (scope.flags & SCOPE_ASYNC) > 0;
2116
+ if (flags & SCOPE_FUNCTION) {
2117
+ return (flags & SCOPE_ASYNC) > 0;
2119
2118
  }
2120
2119
  }
2121
2120
  return (
@@ -2126,11 +2125,8 @@
2126
2125
  prototypeAccessors.allowSuper.get = function () {
2127
2126
  var ref = this.currentThisScope();
2128
2127
  var flags = ref.flags;
2129
- var inClassFieldInit = ref.inClassFieldInit;
2130
2128
  return (
2131
- (flags & SCOPE_SUPER) > 0 ||
2132
- inClassFieldInit ||
2133
- this.options.allowSuperOutsideMethod
2129
+ (flags & SCOPE_SUPER) > 0 || this.options.allowSuperOutsideMethod
2134
2130
  );
2135
2131
  };
2136
2132
  prototypeAccessors.allowDirectSuper.get = function () {
@@ -2140,13 +2136,17 @@
2140
2136
  return this.treatFunctionsAsVarInScope(this.currentScope());
2141
2137
  };
2142
2138
  prototypeAccessors.allowNewDotTarget.get = function () {
2143
- var ref = this.currentThisScope();
2144
- var flags = ref.flags;
2145
- var inClassFieldInit = ref.inClassFieldInit;
2146
- return (
2147
- (flags & (SCOPE_FUNCTION | SCOPE_CLASS_STATIC_BLOCK)) > 0 ||
2148
- inClassFieldInit
2149
- );
2139
+ for (var i = this.scopeStack.length - 1; i >= 0; i--) {
2140
+ var ref = this.scopeStack[i];
2141
+ var flags = ref.flags;
2142
+ if (
2143
+ flags & (SCOPE_CLASS_STATIC_BLOCK | SCOPE_CLASS_FIELD_INIT) ||
2144
+ (flags & SCOPE_FUNCTION && !(flags & SCOPE_ARROW))
2145
+ ) {
2146
+ return true;
2147
+ }
2148
+ }
2149
+ return false;
2150
2150
  };
2151
2151
  prototypeAccessors.inClassStaticBlock.get = function () {
2152
2152
  return (this.currentVarScope().flags & SCOPE_CLASS_STATIC_BLOCK) > 0;
@@ -3309,11 +3309,9 @@
3309
3309
  );
3310
3310
  }
3311
3311
  if (this.eat(types$1.eq)) {
3312
- var scope = this.currentThisScope();
3313
- var inClassFieldInit = scope.inClassFieldInit;
3314
- scope.inClassFieldInit = true;
3312
+ this.enterScope(SCOPE_CLASS_FIELD_INIT | SCOPE_SUPER);
3315
3313
  field.value = this.parseMaybeAssign();
3316
- scope.inClassFieldInit = inClassFieldInit;
3314
+ this.exitScope();
3317
3315
  } else {
3318
3316
  field.value = null;
3319
3317
  }
@@ -3459,6 +3457,9 @@
3459
3457
  }
3460
3458
  node.specifiers = [];
3461
3459
  node.source = null;
3460
+ if (this.options.ecmaVersion >= 16) {
3461
+ node.attributes = [];
3462
+ }
3462
3463
  } else {
3463
3464
  node.declaration = null;
3464
3465
  node.specifiers = this.parseExportSpecifiers(exports);
@@ -3483,6 +3484,9 @@
3483
3484
  }
3484
3485
  }
3485
3486
  node.source = null;
3487
+ if (this.options.ecmaVersion >= 16) {
3488
+ node.attributes = [];
3489
+ }
3486
3490
  }
3487
3491
  this.semicolon();
3488
3492
  }
@@ -5427,9 +5431,10 @@
5427
5431
  return this.finishNode(prop, "Property");
5428
5432
  };
5429
5433
  pp$5.parseGetterSetter = function (prop) {
5430
- prop.kind = prop.key.name;
5434
+ var kind = prop.key.name;
5431
5435
  this.parsePropertyName(prop);
5432
5436
  prop.value = this.parseMethod(false);
5437
+ prop.kind = kind;
5433
5438
  var paramCount = prop.kind === "get" ? 0 : 1;
5434
5439
  if (prop.value.params.length !== paramCount) {
5435
5440
  var start = prop.value.start;
@@ -5478,9 +5483,9 @@
5478
5483
  if (isPattern) {
5479
5484
  this.unexpected();
5480
5485
  }
5481
- prop.kind = "init";
5482
5486
  prop.method = true;
5483
5487
  prop.value = this.parseMethod(isGenerator, isAsync);
5488
+ prop.kind = "init";
5484
5489
  } else if (
5485
5490
  !isPattern &&
5486
5491
  !containsEsc &&
@@ -5508,7 +5513,6 @@
5508
5513
  if (prop.key.name === "await" && !this.awaitIdentPos) {
5509
5514
  this.awaitIdentPos = startPos;
5510
5515
  }
5511
- prop.kind = "init";
5512
5516
  if (isPattern) {
5513
5517
  prop.value = this.parseMaybeDefault(
5514
5518
  startPos,
@@ -5527,6 +5531,7 @@
5527
5531
  } else {
5528
5532
  prop.value = this.copyNode(prop.key);
5529
5533
  }
5534
+ prop.kind = "init";
5530
5535
  prop.shorthand = true;
5531
5536
  } else {
5532
5537
  this.unexpected();
@@ -5735,7 +5740,7 @@
5735
5740
  );
5736
5741
  }
5737
5742
  if (
5738
- this.currentThisScope().inClassFieldInit &&
5743
+ !(this.currentThisScope().flags & SCOPE_VAR) &&
5739
5744
  name === "arguments"
5740
5745
  ) {
5741
5746
  this.raiseRecoverable(
@@ -5863,6 +5868,9 @@
5863
5868
  pp$4.raise = function (pos, message) {
5864
5869
  var loc = getLineInfo(this.input, pos);
5865
5870
  message += " (" + loc.line + ":" + loc.column + ")";
5871
+ if (this.sourceFile) {
5872
+ message += " in " + this.sourceFile;
5873
+ }
5866
5874
  var err = new SyntaxError(message);
5867
5875
  err.pos = pos;
5868
5876
  err.loc = loc;
@@ -5881,7 +5889,6 @@
5881
5889
  this.var = [];
5882
5890
  this.lexical = [];
5883
5891
  this.functions = [];
5884
- this.inClassFieldInit = false;
5885
5892
  };
5886
5893
  pp$3.enterScope = function (flags) {
5887
5894
  this.scopeStack.push(new Scope(flags));
@@ -5965,7 +5972,10 @@
5965
5972
  pp$3.currentVarScope = function () {
5966
5973
  for (var i = this.scopeStack.length - 1; ; i--) {
5967
5974
  var scope = this.scopeStack[i];
5968
- if (scope.flags & SCOPE_VAR) {
5975
+ if (
5976
+ scope.flags &
5977
+ (SCOPE_VAR | SCOPE_CLASS_FIELD_INIT | SCOPE_CLASS_STATIC_BLOCK)
5978
+ ) {
5969
5979
  return scope;
5970
5980
  }
5971
5981
  }
@@ -5973,7 +5983,13 @@
5973
5983
  pp$3.currentThisScope = function () {
5974
5984
  for (var i = this.scopeStack.length - 1; ; i--) {
5975
5985
  var scope = this.scopeStack[i];
5976
- if (scope.flags & SCOPE_VAR && !(scope.flags & SCOPE_ARROW)) {
5986
+ if (
5987
+ scope.flags &
5988
+ (SCOPE_VAR |
5989
+ SCOPE_CLASS_FIELD_INIT |
5990
+ SCOPE_CLASS_STATIC_BLOCK) &&
5991
+ !(scope.flags & SCOPE_ARROW)
5992
+ ) {
5977
5993
  return scope;
5978
5994
  }
5979
5995
  }
@@ -8350,7 +8366,7 @@
8350
8366
  }
8351
8367
  return this.finishToken(type, word);
8352
8368
  };
8353
- var version = "8.14.0";
8369
+ var version = "8.14.1";
8354
8370
  Parser.acorn = {
8355
8371
  Parser,
8356
8372
  version,
@@ -9105,7 +9121,7 @@
9105
9121
  const fs = __nccwpck_require__(9896);
9106
9122
  const { join, normalize, resolve } = __nccwpck_require__(6928);
9107
9123
  const { totalist } = __nccwpck_require__(8794);
9108
- const { parse } = __nccwpck_require__(9847);
9124
+ const { parse } = __nccwpck_require__(2600);
9109
9125
  const { lookup } = __nccwpck_require__(2443);
9110
9126
  const noop = () => {};
9111
9127
  function isMatch(uri, arr) {
@@ -9736,7 +9752,7 @@
9736
9752
  9451: (module, __unused_webpack_exports, __nccwpck_require__) => {
9737
9753
  "use strict";
9738
9754
  const fs = __nccwpck_require__(9896);
9739
- const acorn = __nccwpck_require__(8024);
9755
+ const acorn = __nccwpck_require__(2424);
9740
9756
  const walk = __nccwpck_require__(9703);
9741
9757
  module.exports = { parseBundle };
9742
9758
  function parseBundle(bundlePath) {
package/dist/index.cjs CHANGED
@@ -2153,7 +2153,7 @@ for(var __webpack_i__ in (()=>{
2153
2153
  async function createContext(options, userConfig) {
2154
2154
  let { cwd } = options, rootPath = userConfig.root ? ensureAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = (0, external_node_path_namespaceObject.join)(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0, bundlerType = userConfig.provider ? 'webpack' : 'rspack';
2155
2155
  return {
2156
- version: "1.3.22",
2156
+ version: "1.4.0-beta.1",
2157
2157
  rootPath,
2158
2158
  distPath: '',
2159
2159
  cachePath,
@@ -2313,6 +2313,7 @@ for(var __webpack_i__ in (()=>{
2313
2313
  MEDIA: 'media',
2314
2314
  ADDITIONAL_ASSETS: 'additional-assets',
2315
2315
  JS: 'js',
2316
+ JS_RAW: 'js-raw',
2316
2317
  JS_DATA_URI: 'js-data-uri',
2317
2318
  TS: 'ts',
2318
2319
  CSS: 'css',
@@ -2955,7 +2956,7 @@ for(var __webpack_i__ in (()=>{
2955
2956
  let EXCLUDE_ASSET_REGEX = /\.(?:map|LICENSE\.txt|d\.ts)$/, excludeAsset = (asset)=>EXCLUDE_ASSET_REGEX.test(asset.name), getAssetColor = (size)=>size > 300000 ? index_js_default().red : size > 100000 ? index_js_default().yellow : index_js_default().green, calcFileSize = (len)=>{
2956
2957
  let val = len / 1000;
2957
2958
  return `${val.toFixed(val < 1 ? 2 : 1)} kB`;
2958
- }, coloringAssetName = (assetName)=>JS_REGEX.test(assetName) ? index_js_default().cyan(assetName) : CSS_REGEX.test(assetName) ? index_js_default().yellow(assetName) : HTML_REGEX.test(assetName) ? index_js_default().green(assetName) : index_js_default().magenta(assetName), COMPRESSIBLE_REGEX = /\.(?:js|css|html|json|svg|txt|xml|xhtml|wasm|manifest)$/i, isCompressible = (assetName)=>COMPRESSIBLE_REGEX.test(assetName);
2959
+ }, coloringAssetName = (assetName)=>JS_REGEX.test(assetName) ? index_js_default().cyan(assetName) : CSS_REGEX.test(assetName) ? index_js_default().yellow(assetName) : HTML_REGEX.test(assetName) ? index_js_default().green(assetName) : index_js_default().magenta(assetName), COMPRESSIBLE_REGEX = /\.(?:js|css|html|json|svg|txt|xml|xhtml|wasm|manifest|md)$/i, isCompressible = (assetName)=>COMPRESSIBLE_REGEX.test(assetName);
2959
2960
  async function printFileSizes(options, stats, rootPath, environmentName) {
2960
2961
  let logs = [], showTotal = !1 !== options.total, showDetail = !1 !== options.detail, exclude = options.exclude ?? excludeAsset;
2961
2962
  if (!showTotal && !showDetail) return logs;
@@ -3953,21 +3954,22 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
3953
3954
  let getJsAsyncPath = (jsPath, isServer, jsAsync)=>void 0 !== jsAsync ? jsAsync : isServer ? jsPath : jsPath ? `${jsPath}/async` : 'async', pluginOutput = ()=>({
3954
3955
  name: 'rsbuild:output',
3955
3956
  setup (api) {
3956
- api.modifyBundlerChain(async (chain, { CHAIN_ID, isProd, isServer, environment })=>{
3957
- let { distPath, config } = environment, publicPath = function({ isProd, config, context }) {
3957
+ api.modifyBundlerChain(async (chain, { CHAIN_ID, isDev, isProd, isServer, environment })=>{
3958
+ let { distPath, config } = environment, publicPath = function({ isDev, config, context }) {
3958
3959
  var _context_devServer, _context_devServer1, _context_devServer2;
3959
3960
  let { dev, output, server } = config, publicPath = DEFAULT_ASSET_PREFIX;
3960
- if (isProd) 'string' == typeof output.assetPrefix && (publicPath = output.assetPrefix);
3961
- else if ('string' == typeof dev.assetPrefix) publicPath = dev.assetPrefix;
3962
- else if (!0 === dev.assetPrefix) {
3963
- let protocol = (null == (_context_devServer1 = context.devServer) ? void 0 : _context_devServer1.https) ? 'https' : 'http', hostname = (null == (_context_devServer2 = context.devServer) ? void 0 : _context_devServer2.hostname) || DEFAULT_DEV_HOST;
3964
- publicPath = hostname === DEFAULT_DEV_HOST ? `${protocol}://localhost:<port>/` : `${protocol}://${hostname}:<port>/`, server.base && '/' !== server.base && (publicPath = urlJoin(publicPath, server.base));
3965
- }
3961
+ if (isDev) {
3962
+ if ('string' == typeof dev.assetPrefix) publicPath = dev.assetPrefix;
3963
+ else if (!0 === dev.assetPrefix) {
3964
+ let protocol = (null == (_context_devServer1 = context.devServer) ? void 0 : _context_devServer1.https) ? 'https' : 'http', hostname = (null == (_context_devServer2 = context.devServer) ? void 0 : _context_devServer2.hostname) || DEFAULT_DEV_HOST;
3965
+ publicPath = hostname === DEFAULT_DEV_HOST ? `${protocol}://localhost:<port>/` : `${protocol}://${hostname}:<port>/`, server.base && '/' !== server.base && (publicPath = urlJoin(publicPath, server.base));
3966
+ }
3967
+ } else 'string' == typeof output.assetPrefix && (publicPath = output.assetPrefix);
3966
3968
  let defaultPort = server.port ?? 3000;
3967
- return formatPublicPath(replacePortPlaceholder(publicPath, isProd ? defaultPort : (null == (_context_devServer = context.devServer) ? void 0 : _context_devServer.port) ?? defaultPort));
3969
+ return formatPublicPath(replacePortPlaceholder(publicPath, isDev ? (null == (_context_devServer = context.devServer) ? void 0 : _context_devServer.port) ?? defaultPort : defaultPort));
3968
3970
  }({
3969
3971
  config,
3970
- isProd,
3972
+ isDev,
3971
3973
  context: api.context
3972
3974
  }), jsPath = config.output.distPath.js, jsAsyncPath = getJsAsyncPath(jsPath, isServer, config.output.distPath.jsAsync), jsFilename = getFilename(config, 'js', isProd, isServer), isJsFilenameFn = 'function' == typeof jsFilename;
3973
3975
  if (chain.output.path(distPath).filename(isJsFilenameFn ? (...args)=>{
@@ -4018,7 +4020,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
4018
4020
  name: 'rsbuild:progress',
4019
4021
  setup (api) {
4020
4022
  'webpack' !== api.context.bundlerType && api.modifyBundlerChain(async (chain, { CHAIN_ID, environment })=>{
4021
- let { config } = environment, options = config.dev.progressBar ?? 'production' === config.mode;
4023
+ let { config } = environment, options = config.dev.progressBar;
4022
4024
  if (!options) return;
4023
4025
  let prefix = !0 !== options && void 0 !== options.id ? options.id : environment.name;
4024
4026
  chain.plugin(CHAIN_ID.PLUGIN.PROGRESS).use(core_namespaceObject.rspack.ProgressPlugin, [
@@ -4553,27 +4555,25 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
4553
4555
  var browserslist, target1;
4554
4556
  let { config, browserslist: browserslist1 } = environment, cacheRoot = external_node_path_default().join(api.context.cachePath, '.swc'), rule = chain.module.rule(CHAIN_ID.RULE.JS).test(SCRIPT_REGEX).type("javascript/auto").dependency({
4555
4557
  not: 'url'
4556
- }), dataUriRule = chain.module.rule(CHAIN_ID.RULE.JS_DATA_URI).mimetype({
4558
+ }).resourceQuery({
4559
+ not: /raw|inline/
4560
+ });
4561
+ chain.module.rule(CHAIN_ID.RULE.JS_RAW).test(SCRIPT_REGEX).type('asset/source').resourceQuery(/raw/);
4562
+ let dataUriRule = chain.module.rule(CHAIN_ID.RULE.JS_DATA_URI).mimetype({
4557
4563
  or: [
4558
4564
  "text/javascript",
4559
4565
  "application/javascript"
4560
4566
  ]
4561
4567
  });
4562
- if (!function({ rule, isDev, config, context, rsbuildTarget }) {
4568
+ if (!function({ rule, isDev, config, rsbuildTarget }) {
4563
4569
  for (let condition of (rule.include.add({
4564
- and: [
4565
- context.rootPath,
4566
- {
4567
- not: NODE_MODULES_REGEX
4568
- }
4569
- ]
4570
+ not: NODE_MODULES_REGEX
4570
4571
  }), rule.include.add(/\.(?:ts|tsx|jsx|mts|cts)$/), 'web' === rsbuildTarget && isDev && rule.include.add(/[\\/]@rsbuild[\\/]core[\\/]dist[\\/]/), config.source.include || []))rule.include.add(condition);
4571
4572
  for (let condition of config.source.exclude || [])rule.exclude.add(condition);
4572
4573
  }({
4573
4574
  rule,
4574
4575
  isDev,
4575
4576
  config,
4576
- context: api.context,
4577
4577
  rsbuildTarget: target
4578
4578
  }), 'webpack' === api.context.bundlerType) return;
4579
4579
  let swcConfig = {
@@ -4944,6 +4944,10 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
4944
4944
  };
4945
4945
  }, validateRsbuildConfig = (config)=>{
4946
4946
  if (config.server.base && !config.server.base.startsWith('/')) throw Error(`${index_js_default().dim('[rsbuild:config]')} The ${index_js_default().yellow('"server.base"')} option should start with a slash, for example: "/base"`);
4947
+ if (config.environments) {
4948
+ let names = Object.keys(config.environments), regexp = /^[\w$-]+$/;
4949
+ for (let name of names)regexp.test(name) || rslog_index_js_namespaceObject.logger.warn(`${index_js_default().dim('[rsbuild:config]')} Environment name "${index_js_default().yellow(name)}" contains invalid characters. Only letters, numbers, "-", "_", and "$" are allowed.`);
4950
+ }
4947
4951
  };
4948
4952
  async function initRsbuildConfig({ context, pluginManager }) {
4949
4953
  if (context.normalizedConfig) return context.normalizedConfig;
@@ -5675,7 +5679,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
5675
5679
  <pre class="content">${htmlItems.join('\n\n').trim()}</pre>
5676
5680
  <footer class="footer">
5677
5681
  <p><span>Fix error</span>, click outside, or press Esc to close the overlay.</p>
5678
- <p>Disable overlay by setting Rsbuild's <span><a class="config-link" target="_blank" rel="noopener noreferrer" href="https://rsbuild.dev/config/dev/client">dev.client.overlay</a></span> config to false.<p>
5682
+ <p>Disable overlay by setting Rsbuild's <span><a class="config-link" target="_blank" rel="noopener noreferrer" href="https://rsbuild.rs/config/dev/client">dev.client.overlay</a></span> config to false.<p>
5679
5683
  </footer>
5680
5684
  </div>
5681
5685
  </div>
@@ -6437,6 +6441,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6437
6441
  if (!compilationManager) throw Error(`${index_js_default().dim('[rsbuild:server]')} Can not call ${index_js_default().yellow('getStats')} when ${index_js_default().yellow('runCompile')} is false`);
6438
6442
  return await waitFirstCompileDone, lastStats[environment.index];
6439
6443
  },
6444
+ context: environment,
6440
6445
  loadBundle: async (entryName)=>{
6441
6446
  if (!compilationManager) throw Error(`${index_js_default().dim('[rsbuild:server]')} Can not call ${index_js_default().yellow('loadBundle')} when ${index_js_default().yellow('runCompile')} is false`);
6442
6447
  return await waitFirstCompileDone, cacheableLoadBundle(lastStats[environment.index], entryName, {
@@ -6560,7 +6565,9 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6560
6565
  }
6561
6566
  rslog_index_js_namespaceObject.logger.start('build started...');
6562
6567
  }(compiler, context), isCompiling = !0;
6563
- }), 'build' === context.action && compiler.hooks.run.tap('rsbuild:run', logRspackVersion);
6568
+ }), 'build' === context.action && compiler.hooks.run.tap('rsbuild:run', ()=>{
6569
+ rslog_index_js_namespaceObject.logger.info('build started...'), logRspackVersion();
6570
+ });
6564
6571
  let done = (stats)=>{
6565
6572
  let statsOptions = getStatsOptions(compiler), statsJson = stats.toJson({
6566
6573
  children: !0,
@@ -7603,11 +7610,11 @@ ${section.body}` : section.body).join("\n\n"));
7603
7610
  }
7604
7611
  process.title = 'rsbuild-node';
7605
7612
  let { npm_execpath } = process.env;
7606
- (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), rslog_index_js_namespaceObject.logger.greet(` Rsbuild v1.3.22\n`);
7613
+ (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), rslog_index_js_namespaceObject.logger.greet(` Rsbuild v1.4.0-beta.1\n`);
7607
7614
  try {
7608
7615
  !function() {
7609
7616
  let cli = cac_dist('rsbuild');
7610
- cli.help(), cli.version("1.3.22"), applyCommonOptions(cli);
7617
+ cli.help(), cli.version("1.4.0-beta.1"), applyCommonOptions(cli);
7611
7618
  let devCommand = cli.command('', 'starting the dev server').alias('dev'), buildCommand = cli.command('build', 'build the app for production'), previewCommand = cli.command('preview', 'preview the production build locally'), inspectCommand = cli.command('inspect', 'inspect the Rspack and Rsbuild configs');
7612
7619
  applyServerOptions(devCommand), applyServerOptions(previewCommand), devCommand.action(async (options)=>{
7613
7620
  try {
@@ -7658,7 +7665,7 @@ ${section.body}` : section.body).join("\n\n"));
7658
7665
  rslog_index_js_namespaceObject.logger.error('Failed to start Rsbuild CLI.'), rslog_index_js_namespaceObject.logger.error(err);
7659
7666
  }
7660
7667
  }
7661
- let src_version = "1.3.22";
7668
+ let src_version = "1.4.0-beta.1";
7662
7669
  })(), 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 === [
7663
7670
  "PLUGIN_CSS_NAME",
7664
7671
  "PLUGIN_SWC_NAME",
package/dist/index.js CHANGED
@@ -1969,7 +1969,7 @@ async function updateEnvironmentContext(context, configs) {
1969
1969
  async function createContext(options, userConfig) {
1970
1970
  let { cwd } = options, rootPath = userConfig.root ? ensureAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0, bundlerType = userConfig.provider ? 'webpack' : 'rspack';
1971
1971
  return {
1972
- version: "1.3.22",
1972
+ version: "1.4.0-beta.1",
1973
1973
  rootPath,
1974
1974
  distPath: '',
1975
1975
  cachePath,
@@ -2128,6 +2128,7 @@ let configChain_CHAIN_ID = {
2128
2128
  MEDIA: 'media',
2129
2129
  ADDITIONAL_ASSETS: 'additional-assets',
2130
2130
  JS: 'js',
2131
+ JS_RAW: 'js-raw',
2131
2132
  JS_DATA_URI: 'js-data-uri',
2132
2133
  TS: 'ts',
2133
2134
  CSS: 'css',
@@ -2768,7 +2769,7 @@ async function gzipSize(input) {
2768
2769
  let EXCLUDE_ASSET_REGEX = /\.(?:map|LICENSE\.txt|d\.ts)$/, excludeAsset = (asset)=>EXCLUDE_ASSET_REGEX.test(asset.name), getAssetColor = (size)=>size > 300000 ? __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.red : size > 100000 ? __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow : __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.green, calcFileSize = (len)=>{
2769
2770
  let val = len / 1000;
2770
2771
  return `${val.toFixed(val < 1 ? 2 : 1)} kB`;
2771
- }, coloringAssetName = (assetName)=>JS_REGEX.test(assetName) ? __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.cyan(assetName) : CSS_REGEX.test(assetName) ? __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(assetName) : HTML_REGEX.test(assetName) ? __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.green(assetName) : __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.magenta(assetName), COMPRESSIBLE_REGEX = /\.(?:js|css|html|json|svg|txt|xml|xhtml|wasm|manifest)$/i, isCompressible = (assetName)=>COMPRESSIBLE_REGEX.test(assetName);
2772
+ }, coloringAssetName = (assetName)=>JS_REGEX.test(assetName) ? __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.cyan(assetName) : CSS_REGEX.test(assetName) ? __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(assetName) : HTML_REGEX.test(assetName) ? __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.green(assetName) : __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.magenta(assetName), COMPRESSIBLE_REGEX = /\.(?:js|css|html|json|svg|txt|xml|xhtml|wasm|manifest|md)$/i, isCompressible = (assetName)=>COMPRESSIBLE_REGEX.test(assetName);
2772
2773
  async function printFileSizes(options, stats, rootPath, environmentName) {
2773
2774
  let logs = [], showTotal = !1 !== options.total, showDetail = !1 !== options.detail, exclude = options.exclude ?? excludeAsset;
2774
2775
  if (!showTotal && !showDetail) return logs;
@@ -3764,21 +3765,22 @@ async function open_open({ https, port, routes, config, clearCache }) {
3764
3765
  let getJsAsyncPath = (jsPath, isServer, jsAsync)=>void 0 !== jsAsync ? jsAsync : isServer ? jsPath : jsPath ? `${jsPath}/async` : 'async', pluginOutput = ()=>({
3765
3766
  name: 'rsbuild:output',
3766
3767
  setup (api) {
3767
- api.modifyBundlerChain(async (chain, { CHAIN_ID, isProd, isServer, environment })=>{
3768
- let { distPath, config } = environment, publicPath = function({ isProd, config, context }) {
3768
+ api.modifyBundlerChain(async (chain, { CHAIN_ID, isDev, isProd, isServer, environment })=>{
3769
+ let { distPath, config } = environment, publicPath = function({ isDev, config, context }) {
3769
3770
  var _context_devServer, _context_devServer1, _context_devServer2;
3770
3771
  let { dev, output, server } = config, publicPath = DEFAULT_ASSET_PREFIX;
3771
- if (isProd) 'string' == typeof output.assetPrefix && (publicPath = output.assetPrefix);
3772
- else if ('string' == typeof dev.assetPrefix) publicPath = dev.assetPrefix;
3773
- else if (!0 === dev.assetPrefix) {
3774
- let protocol = (null == (_context_devServer1 = context.devServer) ? void 0 : _context_devServer1.https) ? 'https' : 'http', hostname = (null == (_context_devServer2 = context.devServer) ? void 0 : _context_devServer2.hostname) || DEFAULT_DEV_HOST;
3775
- publicPath = hostname === DEFAULT_DEV_HOST ? `${protocol}://localhost:<port>/` : `${protocol}://${hostname}:<port>/`, server.base && '/' !== server.base && (publicPath = urlJoin(publicPath, server.base));
3776
- }
3772
+ if (isDev) {
3773
+ if ('string' == typeof dev.assetPrefix) publicPath = dev.assetPrefix;
3774
+ else if (!0 === dev.assetPrefix) {
3775
+ let protocol = (null == (_context_devServer1 = context.devServer) ? void 0 : _context_devServer1.https) ? 'https' : 'http', hostname = (null == (_context_devServer2 = context.devServer) ? void 0 : _context_devServer2.hostname) || DEFAULT_DEV_HOST;
3776
+ publicPath = hostname === DEFAULT_DEV_HOST ? `${protocol}://localhost:<port>/` : `${protocol}://${hostname}:<port>/`, server.base && '/' !== server.base && (publicPath = urlJoin(publicPath, server.base));
3777
+ }
3778
+ } else 'string' == typeof output.assetPrefix && (publicPath = output.assetPrefix);
3777
3779
  let defaultPort = server.port ?? 3000;
3778
- return formatPublicPath(replacePortPlaceholder(publicPath, isProd ? defaultPort : (null == (_context_devServer = context.devServer) ? void 0 : _context_devServer.port) ?? defaultPort));
3780
+ return formatPublicPath(replacePortPlaceholder(publicPath, isDev ? (null == (_context_devServer = context.devServer) ? void 0 : _context_devServer.port) ?? defaultPort : defaultPort));
3779
3781
  }({
3780
3782
  config,
3781
- isProd,
3783
+ isDev,
3782
3784
  context: api.context
3783
3785
  }), jsPath = config.output.distPath.js, jsAsyncPath = getJsAsyncPath(jsPath, isServer, config.output.distPath.jsAsync), jsFilename = getFilename(config, 'js', isProd, isServer), isJsFilenameFn = 'function' == typeof jsFilename;
3784
3786
  if (chain.output.path(distPath).filename(isJsFilenameFn ? (...args)=>{
@@ -3829,7 +3831,7 @@ let getJsAsyncPath = (jsPath, isServer, jsAsync)=>void 0 !== jsAsync ? jsAsync :
3829
3831
  name: 'rsbuild:progress',
3830
3832
  setup (api) {
3831
3833
  'webpack' !== api.context.bundlerType && api.modifyBundlerChain(async (chain, { CHAIN_ID, environment })=>{
3832
- let { config } = environment, options = config.dev.progressBar ?? 'production' === config.mode;
3834
+ let { config } = environment, options = config.dev.progressBar;
3833
3835
  if (!options) return;
3834
3836
  let prefix = !0 !== options && void 0 !== options.id ? options.id : environment.name;
3835
3837
  chain.plugin(CHAIN_ID.PLUGIN.PROGRESS).use(__WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack.ProgressPlugin, [
@@ -4361,27 +4363,25 @@ let pluginRspackProfile = ()=>({
4361
4363
  handler: async (chain, { CHAIN_ID, isDev, target, environment })=>{
4362
4364
  let { config, browserslist } = environment, cacheRoot = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.join(api.context.cachePath, '.swc'), rule = chain.module.rule(CHAIN_ID.RULE.JS).test(SCRIPT_REGEX).type("javascript/auto").dependency({
4363
4365
  not: 'url'
4364
- }), dataUriRule = chain.module.rule(CHAIN_ID.RULE.JS_DATA_URI).mimetype({
4366
+ }).resourceQuery({
4367
+ not: /raw|inline/
4368
+ });
4369
+ chain.module.rule(CHAIN_ID.RULE.JS_RAW).test(SCRIPT_REGEX).type('asset/source').resourceQuery(/raw/);
4370
+ let dataUriRule = chain.module.rule(CHAIN_ID.RULE.JS_DATA_URI).mimetype({
4365
4371
  or: [
4366
4372
  "text/javascript",
4367
4373
  "application/javascript"
4368
4374
  ]
4369
4375
  });
4370
- if (!function({ rule, isDev, config, context, rsbuildTarget }) {
4376
+ if (!function({ rule, isDev, config, rsbuildTarget }) {
4371
4377
  for (let condition of (rule.include.add({
4372
- and: [
4373
- context.rootPath,
4374
- {
4375
- not: NODE_MODULES_REGEX
4376
- }
4377
- ]
4378
+ not: NODE_MODULES_REGEX
4378
4379
  }), rule.include.add(/\.(?:ts|tsx|jsx|mts|cts)$/), 'web' === rsbuildTarget && isDev && rule.include.add(/[\\/]@rsbuild[\\/]core[\\/]dist[\\/]/), config.source.include || []))rule.include.add(condition);
4379
4380
  for (let condition of config.source.exclude || [])rule.exclude.add(condition);
4380
4381
  }({
4381
4382
  rule,
4382
4383
  isDev,
4383
4384
  config,
4384
- context: api.context,
4385
4385
  rsbuildTarget: target
4386
4386
  }), 'webpack' === api.context.bundlerType) return;
4387
4387
  let swcConfig = {
@@ -4752,6 +4752,10 @@ let initEnvironmentConfigs = (normalizedConfig, rootPath, specifiedEnvironments)
4752
4752
  };
4753
4753
  }, validateRsbuildConfig = (config)=>{
4754
4754
  if (config.server.base && !config.server.base.startsWith('/')) throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:config]')} The ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('"server.base"')} option should start with a slash, for example: "/base"`);
4755
+ if (config.environments) {
4756
+ let names = Object.keys(config.environments), regexp = /^[\w$-]+$/;
4757
+ for (let name of names)regexp.test(name) || __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:config]')} Environment name "${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(name)}" contains invalid characters. Only letters, numbers, "-", "_", and "$" are allowed.`);
4758
+ }
4755
4759
  };
4756
4760
  async function initRsbuildConfig({ context, pluginManager }) {
4757
4761
  if (context.normalizedConfig) return context.normalizedConfig;
@@ -5481,7 +5485,7 @@ class SocketServer {
5481
5485
  <pre class="content">${htmlItems.join('\n\n').trim()}</pre>
5482
5486
  <footer class="footer">
5483
5487
  <p><span>Fix error</span>, click outside, or press Esc to close the overlay.</p>
5484
- <p>Disable overlay by setting Rsbuild's <span><a class="config-link" target="_blank" rel="noopener noreferrer" href="https://rsbuild.dev/config/dev/client">dev.client.overlay</a></span> config to false.<p>
5488
+ <p>Disable overlay by setting Rsbuild's <span><a class="config-link" target="_blank" rel="noopener noreferrer" href="https://rsbuild.rs/config/dev/client">dev.client.overlay</a></span> config to false.<p>
5485
5489
  </footer>
5486
5490
  </div>
5487
5491
  </div>
@@ -6240,6 +6244,7 @@ async function devServer_createDevServer(options, createCompiler, config, { comp
6240
6244
  if (!compilationManager) throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:server]')} Can not call ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('getStats')} when ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('runCompile')} is false`);
6241
6245
  return await waitFirstCompileDone, lastStats[environment.index];
6242
6246
  },
6247
+ context: environment,
6243
6248
  loadBundle: async (entryName)=>{
6244
6249
  if (!compilationManager) throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:server]')} Can not call ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('loadBundle')} when ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('runCompile')} is false`);
6245
6250
  return await waitFirstCompileDone, cacheableLoadBundle(lastStats[environment.index], entryName, {
@@ -6363,7 +6368,9 @@ async function createCompiler_createCompiler(options) {
6363
6368
  }
6364
6369
  __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.start('build started...');
6365
6370
  }(compiler, context), isCompiling = !0;
6366
- }), 'build' === context.action && compiler.hooks.run.tap('rsbuild:run', logRspackVersion);
6371
+ }), 'build' === context.action && compiler.hooks.run.tap('rsbuild:run', ()=>{
6372
+ __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.info('build started...'), logRspackVersion();
6373
+ });
6367
6374
  let done = (stats)=>{
6368
6375
  let statsOptions = getStatsOptions(compiler), statsJson = stats.toJson({
6369
6376
  children: !0,
@@ -7404,11 +7411,11 @@ async function runCLI() {
7404
7411
  }
7405
7412
  process.title = 'rsbuild-node';
7406
7413
  let { npm_execpath } = process.env;
7407
- (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.greet(` Rsbuild v1.3.22\n`);
7414
+ (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.greet(` Rsbuild v1.4.0-beta.1\n`);
7408
7415
  try {
7409
7416
  !function() {
7410
7417
  let cli = cac_dist('rsbuild');
7411
- cli.help(), cli.version("1.3.22"), applyCommonOptions(cli);
7418
+ cli.help(), cli.version("1.4.0-beta.1"), applyCommonOptions(cli);
7412
7419
  let devCommand = cli.command('', 'starting the dev server').alias('dev'), buildCommand = cli.command('build', 'build the app for production'), previewCommand = cli.command('preview', 'preview the production build locally'), inspectCommand = cli.command('inspect', 'inspect the Rspack and Rsbuild configs');
7413
7420
  applyServerOptions(devCommand), applyServerOptions(previewCommand), devCommand.action(async (options)=>{
7414
7421
  try {
@@ -7459,6 +7466,6 @@ async function runCLI() {
7459
7466
  __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error('Failed to start Rsbuild CLI.'), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(err);
7460
7467
  }
7461
7468
  }
7462
- let src_version = "1.3.22";
7469
+ let src_version = "1.4.0-beta.1";
7463
7470
  var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger, __webpack_exports__rspack = __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack;
7464
7471
  export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, createRsbuild, defaultAllowedOrigins, defineConfig, ensureAssetPrefix, loadConfig_loadConfig as loadConfig, loadEnv, mergeRsbuildConfig, runCLI, src_version as version, __webpack_exports__logger as logger, __webpack_exports__rspack as rspack };
@@ -16,6 +16,8 @@ export declare const CHAIN_ID: {
16
16
  readonly ADDITIONAL_ASSETS: "additional-assets";
17
17
  /** Rule for js */
18
18
  readonly JS: "js";
19
+ /** Rule for raw js */
20
+ readonly JS_RAW: "js-raw";
19
21
  /** Rule for data uri encoded javascript */
20
22
  readonly JS_DATA_URI: "js-data-uri";
21
23
  /** Rule for ts */