@rsbuild/core 1.2.19 → 1.3.0-beta.0

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.
@@ -1,19 +1,19 @@
1
1
  (() => {
2
2
  var __webpack_modules__ = {
3
- 7302: (module, __unused_webpack_exports, __nccwpck_require__) => {
3
+ 6654: (module, __unused_webpack_exports, __nccwpck_require__) => {
4
4
  "use strict";
5
- const loader = __nccwpck_require__(2540);
5
+ const loader = __nccwpck_require__(3812);
6
6
  module.exports = loader.default;
7
7
  module.exports.defaultGetLocalIdent =
8
- __nccwpck_require__(4485).defaultGetLocalIdent;
8
+ __nccwpck_require__(9741).defaultGetLocalIdent;
9
9
  },
10
- 2540: (__unused_webpack_module, exports, __nccwpck_require__) => {
10
+ 3812: (__unused_webpack_module, exports, __nccwpck_require__) => {
11
11
  "use strict";
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports["default"] = loader;
14
14
  var _postcss = _interopRequireDefault(__nccwpck_require__(9409));
15
- var _plugins = __nccwpck_require__(35);
16
- var _utils = __nccwpck_require__(4485);
15
+ var _plugins = __nccwpck_require__(3355);
16
+ var _utils = __nccwpck_require__(9741);
17
17
  function _interopRequireDefault(obj) {
18
18
  return obj && obj.__esModule ? obj : { default: obj };
19
19
  }
@@ -236,7 +236,7 @@
236
236
  callback(null, `${importCode}${moduleCode}${exportCode}`);
237
237
  }
238
238
  },
239
- 35: (__unused_webpack_module, exports, __nccwpck_require__) => {
239
+ 3355: (__unused_webpack_module, exports, __nccwpck_require__) => {
240
240
  "use strict";
241
241
  Object.defineProperty(exports, "__esModule", { value: true });
242
242
  Object.defineProperty(exports, "icssParser", {
@@ -258,20 +258,22 @@
258
258
  },
259
259
  });
260
260
  var _postcssImportParser = _interopRequireDefault(
261
- __nccwpck_require__(7608),
261
+ __nccwpck_require__(4432),
262
262
  );
263
- var _postcssIcssParser = _interopRequireDefault(__nccwpck_require__(301));
264
- var _postcssUrlParser = _interopRequireDefault(__nccwpck_require__(2700));
263
+ var _postcssIcssParser = _interopRequireDefault(
264
+ __nccwpck_require__(6949),
265
+ );
266
+ var _postcssUrlParser = _interopRequireDefault(__nccwpck_require__(5316));
265
267
  function _interopRequireDefault(obj) {
266
268
  return obj && obj.__esModule ? obj : { default: obj };
267
269
  }
268
270
  },
269
- 301: (__unused_webpack_module, exports, __nccwpck_require__) => {
271
+ 6949: (__unused_webpack_module, exports, __nccwpck_require__) => {
270
272
  "use strict";
271
273
  Object.defineProperty(exports, "__esModule", { value: true });
272
274
  exports["default"] = void 0;
273
275
  var _icssUtils = __nccwpck_require__(4531);
274
- var _utils = __nccwpck_require__(4485);
276
+ var _utils = __nccwpck_require__(9741);
275
277
  const plugin = (options = {}) => ({
276
278
  postcssPlugin: "postcss-icss-parser",
277
279
  async OnceExit(root) {
@@ -370,14 +372,14 @@
370
372
  plugin.postcss = true;
371
373
  var _default = (exports["default"] = plugin);
372
374
  },
373
- 7608: (__unused_webpack_module, exports, __nccwpck_require__) => {
375
+ 4432: (__unused_webpack_module, exports, __nccwpck_require__) => {
374
376
  "use strict";
375
377
  Object.defineProperty(exports, "__esModule", { value: true });
376
378
  exports["default"] = void 0;
377
379
  var _postcssValueParser = _interopRequireDefault(
378
380
  __nccwpck_require__(2948),
379
381
  );
380
- var _utils = __nccwpck_require__(4485);
382
+ var _utils = __nccwpck_require__(9741);
381
383
  function _interopRequireDefault(obj) {
382
384
  return obj && obj.__esModule ? obj : { default: obj };
383
385
  }
@@ -682,14 +684,14 @@
682
684
  plugin.postcss = true;
683
685
  var _default = (exports["default"] = plugin);
684
686
  },
685
- 2700: (__unused_webpack_module, exports, __nccwpck_require__) => {
687
+ 5316: (__unused_webpack_module, exports, __nccwpck_require__) => {
686
688
  "use strict";
687
689
  Object.defineProperty(exports, "__esModule", { value: true });
688
690
  exports["default"] = void 0;
689
691
  var _postcssValueParser = _interopRequireDefault(
690
692
  __nccwpck_require__(2948),
691
693
  );
692
- var _utils = __nccwpck_require__(4485);
694
+ var _utils = __nccwpck_require__(9741);
693
695
  function _interopRequireDefault(obj) {
694
696
  return obj && obj.__esModule ? obj : { default: obj };
695
697
  }
@@ -1032,7 +1034,7 @@
1032
1034
  plugin.postcss = true;
1033
1035
  var _default = (exports["default"] = plugin);
1034
1036
  },
1035
- 4485: (__unused_webpack_module, exports, __nccwpck_require__) => {
1037
+ 9741: (__unused_webpack_module, exports, __nccwpck_require__) => {
1036
1038
  "use strict";
1037
1039
  Object.defineProperty(exports, "__esModule", { value: true });
1038
1040
  exports.WEBPACK_IGNORE_COMMENT_REGEXP = void 0;
@@ -8096,6 +8098,6 @@
8096
8098
  }
8097
8099
  if (typeof __nccwpck_require__ !== "undefined")
8098
8100
  __nccwpck_require__.ab = __dirname + "/";
8099
- var __webpack_exports__ = __nccwpck_require__(7302);
8101
+ var __webpack_exports__ = __nccwpck_require__(6654);
8100
8102
  module.exports = __webpack_exports__;
8101
8103
  })();
@@ -1,8 +1,8 @@
1
1
  (() => {
2
2
  var __webpack_modules__ = {
3
- 555: (module, __unused_webpack_exports, __nccwpck_require__) => {
3
+ 709: (module, __unused_webpack_exports, __nccwpck_require__) => {
4
4
  "use strict";
5
- const { HtmlWebpackChildCompiler } = __nccwpck_require__(360);
5
+ const { HtmlWebpackChildCompiler } = __nccwpck_require__(158);
6
6
  const compilerMap = new WeakMap();
7
7
  class CachedChildCompilation {
8
8
  constructor(compiler) {
@@ -304,7 +304,7 @@
304
304
  }
305
305
  module.exports = { CachedChildCompilation };
306
306
  },
307
- 360: (module) => {
307
+ 158: (module) => {
308
308
  "use strict";
309
309
  class HtmlWebpackChildCompiler {
310
310
  constructor(templates) {
@@ -473,7 +473,7 @@
473
473
  }
474
474
  module.exports = { HtmlWebpackChildCompiler };
475
475
  },
476
- 16: (module) => {
476
+ 270: (module) => {
477
477
  "use strict";
478
478
  module.exports = {};
479
479
  module.exports.none = (chunks) => chunks;
@@ -492,7 +492,7 @@
492
492
  };
493
493
  module.exports.auto = module.exports.none;
494
494
  },
495
- 223: (module) => {
495
+ 9: (module) => {
496
496
  "use strict";
497
497
  module.exports = function (err) {
498
498
  return {
@@ -513,7 +513,7 @@
513
513
  };
514
514
  };
515
515
  },
516
- 910: (module, __unused_webpack_exports, __nccwpck_require__) => {
516
+ 256: (module, __unused_webpack_exports, __nccwpck_require__) => {
517
517
  "use strict";
518
518
  const { AsyncSeriesWaterfallHook } = __nccwpck_require__(408);
519
519
  const htmlWebpackPluginHooksMap = new WeakMap();
@@ -539,7 +539,7 @@
539
539
  }
540
540
  module.exports = { getHtmlRspackPluginHooks };
541
541
  },
542
- 315: (module) => {
542
+ 85: (module) => {
543
543
  const voidTags = [
544
544
  "area",
545
545
  "base",
@@ -607,19 +607,19 @@
607
607
  htmlTagObjectToString,
608
608
  };
609
609
  },
610
- 850: (module, __unused_webpack_exports, __nccwpck_require__) => {
610
+ 312: (module, __unused_webpack_exports, __nccwpck_require__) => {
611
611
  "use strict";
612
612
  const promisify = __nccwpck_require__(23).promisify;
613
613
  const vm = __nccwpck_require__(154);
614
614
  const fs = __nccwpck_require__(896);
615
615
  const path = __nccwpck_require__(928);
616
- const { CachedChildCompilation } = __nccwpck_require__(555);
616
+ const { CachedChildCompilation } = __nccwpck_require__(709);
617
617
  const { createHtmlTagObject, htmlTagObjectToString, HtmlTagArray } =
618
- __nccwpck_require__(315);
619
- const prettyError = __nccwpck_require__(223);
620
- const chunkSorter = __nccwpck_require__(16);
618
+ __nccwpck_require__(85);
619
+ const prettyError = __nccwpck_require__(9);
620
+ const chunkSorter = __nccwpck_require__(270);
621
621
  const getHtmlRspackPluginHooks =
622
- __nccwpck_require__(910).getHtmlRspackPluginHooks;
622
+ __nccwpck_require__(256).getHtmlRspackPluginHooks;
623
623
  class HtmlRspackPlugin {
624
624
  constructor(userOptions = {}) {
625
625
  this.version = HtmlRspackPlugin.version;
@@ -1578,6 +1578,6 @@
1578
1578
  }
1579
1579
  if (typeof __nccwpck_require__ !== "undefined")
1580
1580
  __nccwpck_require__.ab = __dirname + "/";
1581
- var __webpack_exports__ = __nccwpck_require__(850);
1581
+ var __webpack_exports__ = __nccwpck_require__(312);
1582
1582
  module.exports = __webpack_exports__;
1583
1583
  })();
@@ -1,15 +1,15 @@
1
1
  (() => {
2
2
  "use strict";
3
3
  var __webpack_modules__ = {
4
- 290: (module, __unused_webpack_exports, __nccwpck_require__) => {
5
- module.exports = __nccwpck_require__(896)["default"];
4
+ 875: (module, __unused_webpack_exports, __nccwpck_require__) => {
5
+ module.exports = __nccwpck_require__(757)["default"];
6
6
  },
7
- 896: (__unused_webpack_module, exports, __nccwpck_require__) => {
7
+ 757: (__unused_webpack_module, exports, __nccwpck_require__) => {
8
8
  var __webpack_unused_export__;
9
9
  __webpack_unused_export__ = { value: true };
10
10
  exports["default"] = loader;
11
11
  var _path = _interopRequireDefault(__nccwpck_require__(928));
12
- var _utils = __nccwpck_require__(681);
12
+ var _utils = __nccwpck_require__(208);
13
13
  function _interopRequireDefault(obj) {
14
14
  return obj && obj.__esModule ? obj : { default: obj };
15
15
  }
@@ -179,7 +179,7 @@
179
179
  callback(null, result.css, map, { ast });
180
180
  }
181
181
  },
182
- 681: (module, exports, __nccwpck_require__) => {
182
+ 208: (module, exports, __nccwpck_require__) => {
183
183
  module = __nccwpck_require__.nmd(module);
184
184
  Object.defineProperty(exports, "__esModule", { value: true });
185
185
  exports.exec = exec;
@@ -716,6 +716,6 @@
716
716
  })();
717
717
  if (typeof __nccwpck_require__ !== "undefined")
718
718
  __nccwpck_require__.ab = __dirname + "/";
719
- var __webpack_exports__ = __nccwpck_require__(290);
719
+ var __webpack_exports__ = __nccwpck_require__(875);
720
720
  module.exports = __webpack_exports__;
721
721
  })();
@@ -1,7 +1,7 @@
1
1
  (() => {
2
2
  "use strict";
3
3
  var __webpack_modules__ = {
4
- 664: (__unused_webpack_module, exports, __nccwpck_require__) => {
4
+ 394: (__unused_webpack_module, exports, __nccwpck_require__) => {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.transformFiles =
7
7
  exports.reduceChunk =
@@ -120,7 +120,7 @@
120
120
  .map(standardizeFilePaths);
121
121
  exports.transformFiles = transformFiles;
122
122
  },
123
- 289: (__unused_webpack_module, exports, __nccwpck_require__) => {
123
+ 379: (__unused_webpack_module, exports, __nccwpck_require__) => {
124
124
  Object.defineProperty(exports, "__esModule", { value: true });
125
125
  exports.normalModuleLoaderHook =
126
126
  exports.getCompilerHooks =
@@ -130,7 +130,7 @@
130
130
  const fs_1 = __nccwpck_require__(896);
131
131
  const path_1 = __nccwpck_require__(928);
132
132
  const lite_tapable_1 = __nccwpck_require__(408);
133
- const helpers_1 = __nccwpck_require__(664);
133
+ const helpers_1 = __nccwpck_require__(394);
134
134
  const compilerHookMap = new WeakMap();
135
135
  const getCompilerHooks = (compiler) => {
136
136
  let hooks = compilerHookMap.get(compiler);
@@ -312,7 +312,7 @@
312
312
  exports.getCompilerHooks =
313
313
  void 0;
314
314
  const path_1 = __nccwpck_require__(928);
315
- const hooks_1 = __nccwpck_require__(289);
315
+ const hooks_1 = __nccwpck_require__(379);
316
316
  Object.defineProperty(exports, "getCompilerHooks", {
317
317
  enumerable: true,
318
318
  get: function () {
@@ -13,12 +13,15 @@ const { HTMLElement = class {
13
13
  }, customElements } = 'undefined' != typeof window ? window : globalThis;
14
14
  class ErrorOverlay extends HTMLElement {
15
15
  constructor(html){
16
- super(), _define_property(this, "close", ()=>{
16
+ var _this;
17
+ var _root_querySelector, _root_querySelector1;
18
+ super(), _this = this, _define_property(this, "close", function() {
19
+ let immediate = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : false;
17
20
  const remove = ()=>{
18
21
  var _this_parentNode;
19
- return null === (_this_parentNode = this.parentNode) || void 0 === _this_parentNode ? void 0 : _this_parentNode.removeChild(this);
22
+ return null === (_this_parentNode = _this.parentNode) || void 0 === _this_parentNode ? void 0 : _this_parentNode.removeChild(_this);
20
23
  };
21
- if (this.animate) this.animate([
24
+ if (_this.animate && true !== immediate) _this.animate([
22
25
  {
23
26
  opacity: 1
24
27
  },
@@ -39,9 +42,9 @@ class ErrorOverlay extends HTMLElement {
39
42
  mode: 'open'
40
43
  });
41
44
  root.innerHTML = html;
42
- root.querySelector('.close').addEventListener('click', this.close);
45
+ null === (_root_querySelector = root.querySelector('.close')) || void 0 === _root_querySelector || _root_querySelector.addEventListener('click', this.close);
43
46
  this.addEventListener('click', this.close);
44
- root.querySelector('.container').addEventListener('click', (e)=>{
47
+ null === (_root_querySelector1 = root.querySelector('.container')) || void 0 === _root_querySelector1 || _root_querySelector1.addEventListener('click', (e)=>{
45
48
  if (e.target) {
46
49
  const { file } = e.target.dataset;
47
50
  if (file) fetch(`/__open-in-editor?file=${encodeURIComponent(file)}`);
@@ -62,7 +65,7 @@ function createOverlay(html) {
62
65
  document.body.appendChild(new ErrorOverlay(html));
63
66
  }
64
67
  function clearOverlay() {
65
- document.querySelectorAll(overlayId).forEach((n)=>n.close());
68
+ document.querySelectorAll(overlayId).forEach((n)=>n.close(true));
66
69
  }
67
70
  if ('undefined' != typeof document) (0, __WEBPACK_EXTERNAL_MODULE__hmr_702ad2d3__.registerOverlay)(createOverlay, clearOverlay);
68
71
  else console.info('[Rsbuild] Failed to display error overlay as document is not available, you can disable the `dev.client.overlay` option.');
package/dist/index.cjs CHANGED
@@ -1327,7 +1327,7 @@ var __webpack_exports__ = {};
1327
1327
  warnings: getAllStatsWarnings(statsData)
1328
1328
  }, verbose);
1329
1329
  if (warnings.length) {
1330
- let title = index_js_default().bold(index_js_default().yellow('Compile Warning: \n'));
1330
+ let title = index_js_default().bold(index_js_default().yellow('Compile warning: \n'));
1331
1331
  return {
1332
1332
  message: `${title}${warnings.join('\n\n')}\n`,
1333
1333
  level: 'warning'
@@ -1541,10 +1541,14 @@ var __webpack_exports__ = {};
1541
1541
  x,
1542
1542
  y
1543
1543
  ];
1544
- if (pair.some(Array.isArray)) return [
1544
+ if (pair.some(Array.isArray)) return 'output.copy' !== path || pair.every(Array.isArray) ? [
1545
1545
  ...castArray(x),
1546
1546
  ...castArray(y)
1547
- ];
1547
+ ] : Array.isArray(x) ? merge({
1548
+ patterns: x
1549
+ }, y, path) : merge(x, {
1550
+ patterns: y
1551
+ }, path);
1548
1552
  if (pair.some(isFunction)) return pair;
1549
1553
  if (!isPlainObject(x) || !isPlainObject(y)) return y;
1550
1554
  let merged = {};
@@ -2378,7 +2382,7 @@ var __webpack_exports__ = {};
2378
2382
  async function createContext(options, userConfig) {
2379
2383
  let { cwd } = options, rootPath = userConfig.root ? getAbsolutePath(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;
2380
2384
  return {
2381
- version: "1.2.19",
2385
+ version: "1.3.0-beta.0",
2382
2386
  rootPath,
2383
2387
  distPath: '',
2384
2388
  cachePath,
@@ -2596,8 +2600,7 @@ var __webpack_exports__ = {};
2596
2600
  MINI_CSS_EXTRACT: 'mini-css-extract',
2597
2601
  VUE_LOADER_PLUGIN: 'vue-loader-plugin',
2598
2602
  REACT_FAST_REFRESH: 'react-fast-refresh',
2599
- SUBRESOURCE_INTEGRITY: 'subresource-integrity',
2600
- AUTO_SET_ROOT_SIZE: 'auto-set-root-size'
2603
+ SUBRESOURCE_INTEGRITY: 'subresource-integrity'
2601
2604
  },
2602
2605
  MINIMIZER: {
2603
2606
  JS: 'js',
@@ -2769,7 +2772,10 @@ var __webpack_exports__ = {};
2769
2772
  cache: {
2770
2773
  type: 'persistent',
2771
2774
  version: cacheVersion,
2772
- directory: cacheDirectory,
2775
+ storage: {
2776
+ type: 'filesystem',
2777
+ directory: cacheDirectory
2778
+ },
2773
2779
  buildDependencies: Object.values(buildDependencies).flat()
2774
2780
  }
2775
2781
  })) : chain.cache({
@@ -3103,7 +3109,7 @@ var __webpack_exports__ = {};
3103
3109
  groupAssetsByChunk: !1,
3104
3110
  groupAssetsByExtension: !1,
3105
3111
  groupAssetsByEmitStatus: !1
3106
- }), exclude = options.exclude ?? excludeAsset, filteredAssets = origin.assets.filter((asset)=>{
3112
+ }), exclude = options.exclude ?? excludeAsset, filteredAssets = (origin.assets || []).filter((asset)=>{
3107
3113
  let assetInfo = {
3108
3114
  name: asset.name,
3109
3115
  size: asset.size
@@ -3628,7 +3634,7 @@ var __webpack_exports__ = {};
3628
3634
  for (let file of chunkFiles){
3629
3635
  file.isInitial ? file.path.endsWith('.css') ? initialCSS.push(file.path) : initialJS.push(file.path) : file.path.endsWith('.css') ? asyncCSS.push(file.path) : asyncJS.push(file.path);
3630
3636
  let relatedLICENSE = licenseMap.get(file.path);
3631
- for (let auxiliaryFile of (relatedLICENSE && assets.add(relatedLICENSE), file.chunk.auxiliaryFiles))assets.add(auxiliaryFile);
3637
+ if (relatedLICENSE && assets.add(relatedLICENSE), file.chunk) for (let auxiliaryFile of file.chunk.auxiliaryFiles)assets.add(auxiliaryFile);
3632
3638
  }
3633
3639
  let entryManifest = {};
3634
3640
  assets.size && (entryManifest.assets = Array.from(assets));
@@ -4650,65 +4656,27 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
4650
4656
  chain.optimization.splitChunks(splitChunksOptions);
4651
4657
  });
4652
4658
  }
4653
- }), getAssetName = (url, assetPrefix)=>url.startsWith(assetPrefix) ? removeLeadingSlash(url.replace(assetPrefix, '')) : removeLeadingSlash(url), isSriLinkRel = (rel)=>'string' == typeof rel && [
4654
- 'stylesheet',
4655
- 'preload',
4656
- 'modulepreload'
4657
- ].includes(rel), pluginSri = ()=>({
4659
+ }), pluginSri = ()=>({
4658
4660
  name: 'rsbuild:sri',
4659
4661
  setup (api) {
4660
- let placeholder = 'RSBUILD_INTEGRITY_PLACEHOLDER:', getAlgorithm = (environment)=>{
4661
- let { config } = environment, { sri } = config.security;
4662
- if (!('auto' === sri.enable ? 'production' === config.mode : sri.enable)) return null;
4662
+ api.modifyBundlerChain((chain, { environment, CHAIN_ID })=>{
4663
+ if ('webpack' === api.context.bundlerType) return;
4664
+ let { config, htmlPaths } = environment;
4665
+ if (0 === Object.keys(htmlPaths).length) return;
4666
+ let { sri } = config.security;
4667
+ if (!('auto' === sri.enable ? 'production' === config.mode : sri.enable)) return;
4668
+ let crossorigin = chain.output.get('crossOriginLoading');
4669
+ (!1 === crossorigin || void 0 === crossorigin) && chain.output.crossOriginLoading('anonymous');
4663
4670
  let { algorithm = 'sha384' } = sri;
4664
- return algorithm;
4665
- };
4666
- api.modifyHTMLTags({
4667
- order: 'post',
4668
- handler (tags, { assetPrefix, environment }) {
4669
- if (!getAlgorithm(environment)) return tags;
4670
- for (let tag of [
4671
- ...tags.headTags,
4672
- ...tags.bodyTags
4673
- ]){
4674
- let url = '';
4675
- if (!tag.attrs || ("script" === tag.tag && 'string' == typeof tag.attrs.src ? url = tag.attrs.src : 'link' === tag.tag && isSriLinkRel(tag.attrs.rel) && 'string' == typeof tag.attrs.href && (url = tag.attrs.href), !url)) continue;
4676
- let assetName = getAssetName(url, assetPrefix);
4677
- assetName && (tag.attrs.integrity ??= `${placeholder}${assetName}`);
4678
- }
4679
- return tags;
4680
- }
4681
- });
4682
- let replaceIntegrity = (htmlContent, assets, algorithm, integrityCache)=>{
4683
- let matches = htmlContent.matchAll(/integrity="RSBUILD_INTEGRITY_PLACEHOLDER:([^"]+)"/g), replacedHtml = htmlContent, calcIntegrity = (algorithm, assetName, data)=>{
4684
- if (integrityCache.has(assetName)) return integrityCache.get(assetName);
4685
- let hash = external_node_crypto_default().createHash(algorithm).update(data).digest().toString('base64'), integrity = `${algorithm}-${hash}`;
4686
- return integrityCache.set(assetName, integrity), integrity;
4687
- };
4688
- for (let match of matches){
4689
- let assetName = match[1];
4690
- if (assetName) {
4691
- if (assets[assetName]) {
4692
- let integrity = calcIntegrity(algorithm, assetName, assets[assetName].buffer());
4693
- replacedHtml = replacedHtml.replaceAll(`integrity="${placeholder}${assetName}"`, `integrity="${integrity}"`);
4694
- } else rslog_index_js_namespaceObject.logger.debug(`[rsbuild:sri] failed to generate integrity for ${assetName}.`), replacedHtml = replacedHtml.replace(`integrity="${placeholder}${assetName}"`, '');
4671
+ chain.plugin(CHAIN_ID.PLUGIN.SUBRESOURCE_INTEGRITY).use(core_namespaceObject.rspack.experiments.SubresourceIntegrityPlugin, [
4672
+ {
4673
+ enabled: !0,
4674
+ hashFuncNames: [
4675
+ algorithm
4676
+ ],
4677
+ htmlPlugin: external_node_path_default().join(COMPILED_PATH, 'html-rspack-plugin/index.js')
4695
4678
  }
4696
- }
4697
- return replacedHtml;
4698
- };
4699
- api.processAssets({
4700
- stage: 'report'
4701
- }, ({ assets, sources, environment })=>{
4702
- let { htmlPaths } = environment;
4703
- if (0 === Object.keys(htmlPaths).length) return;
4704
- let algorithm = getAlgorithm(environment);
4705
- if (!algorithm) return;
4706
- let integrityCache = new Map();
4707
- for (let asset of Object.keys(assets)){
4708
- if (!HTML_REGEX.test(asset)) continue;
4709
- let htmlContent = assets[asset].source();
4710
- htmlContent.includes(placeholder) && (assets[asset] = new sources.RawSource(replaceIntegrity(htmlContent, assets, algorithm, integrityCache)));
4711
- }
4679
+ ]);
4712
4680
  });
4713
4681
  }
4714
4682
  }), swc_require = (0, external_node_module_namespaceObject.createRequire)(__rslib_import_meta_url__), builtinSwcLoaderName = 'builtin:swc-loader', pluginSwc = ()=>({
@@ -7454,12 +7422,12 @@ ${section.body}` : section.body).join("\n\n"));
7454
7422
  }
7455
7423
  }(), process.title = 'rsbuild-node';
7456
7424
  let { npm_execpath } = process.env;
7457
- (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), rslog_index_js_namespaceObject.logger.greet(` Rsbuild v1.2.19\n`);
7425
+ (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), rslog_index_js_namespaceObject.logger.greet(` Rsbuild v1.3.0-beta.0\n`);
7458
7426
  }();
7459
7427
  try {
7460
7428
  !function() {
7461
7429
  let cli = cac_dist('rsbuild');
7462
- cli.help(), cli.version("1.2.19"), applyCommonOptions(cli);
7430
+ cli.help(), cli.version("1.3.0-beta.0"), applyCommonOptions(cli);
7463
7431
  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');
7464
7432
  applyServerOptions(devCommand), applyServerOptions(previewCommand), devCommand.action(async (options)=>{
7465
7433
  try {
@@ -7510,7 +7478,7 @@ ${section.body}` : section.body).join("\n\n"));
7510
7478
  rslog_index_js_namespaceObject.logger.error('Failed to start Rsbuild CLI.'), rslog_index_js_namespaceObject.logger.error(err);
7511
7479
  }
7512
7480
  }
7513
- let src_rslib_entry_version = "1.2.19";
7481
+ let src_rslib_entry_version = "1.3.0-beta.0";
7514
7482
  })();
7515
7483
  var __webpack_export_target__ = exports;
7516
7484
  for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
package/dist/index.js CHANGED
@@ -1233,7 +1233,7 @@ function formatStats(statsData, hasErrors) {
1233
1233
  warnings: getAllStatsWarnings(statsData)
1234
1234
  }, verbose);
1235
1235
  if (warnings.length) {
1236
- let title = __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.bold(__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('Compile Warning: \n'));
1236
+ let title = __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.bold(__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('Compile warning: \n'));
1237
1237
  return {
1238
1238
  message: `${title}${warnings.join('\n\n')}\n`,
1239
1239
  level: 'warning'
@@ -1443,10 +1443,14 @@ let configCache = {}, OVERRIDE_PATHS = [
1443
1443
  x,
1444
1444
  y
1445
1445
  ];
1446
- if (pair.some(Array.isArray)) return [
1446
+ if (pair.some(Array.isArray)) return 'output.copy' !== path || pair.every(Array.isArray) ? [
1447
1447
  ...castArray(x),
1448
1448
  ...castArray(y)
1449
- ];
1449
+ ] : Array.isArray(x) ? merge({
1450
+ patterns: x
1451
+ }, y, path) : merge(x, {
1452
+ patterns: y
1453
+ }, path);
1450
1454
  if (pair.some(isFunction)) return pair;
1451
1455
  if (!isPlainObject(x) || !isPlainObject(y)) return y;
1452
1456
  let merged = {};
@@ -2280,7 +2284,7 @@ async function updateEnvironmentContext(context, configs) {
2280
2284
  async function createContext(options, userConfig) {
2281
2285
  let { cwd } = options, rootPath = userConfig.root ? getAbsolutePath(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;
2282
2286
  return {
2283
- version: "1.2.19",
2287
+ version: "1.3.0-beta.0",
2284
2288
  rootPath,
2285
2289
  distPath: '',
2286
2290
  cachePath,
@@ -2498,8 +2502,7 @@ let configChain_CHAIN_ID = {
2498
2502
  MINI_CSS_EXTRACT: 'mini-css-extract',
2499
2503
  VUE_LOADER_PLUGIN: 'vue-loader-plugin',
2500
2504
  REACT_FAST_REFRESH: 'react-fast-refresh',
2501
- SUBRESOURCE_INTEGRITY: 'subresource-integrity',
2502
- AUTO_SET_ROOT_SIZE: 'auto-set-root-size'
2505
+ SUBRESOURCE_INTEGRITY: 'subresource-integrity'
2503
2506
  },
2504
2507
  MINIMIZER: {
2505
2508
  JS: 'js',
@@ -2670,7 +2673,10 @@ let pluginCache = ()=>({
2670
2673
  cache: {
2671
2674
  type: 'persistent',
2672
2675
  version: cacheVersion,
2673
- directory: cacheDirectory,
2676
+ storage: {
2677
+ type: 'filesystem',
2678
+ directory: cacheDirectory
2679
+ },
2674
2680
  buildDependencies: Object.values(buildDependencies).flat()
2675
2681
  }
2676
2682
  })) : chain.cache({
@@ -3002,7 +3008,7 @@ async function printFileSizes(options, stats, rootPath, environmentName) {
3002
3008
  groupAssetsByChunk: !1,
3003
3009
  groupAssetsByExtension: !1,
3004
3010
  groupAssetsByEmitStatus: !1
3005
- }), exclude = options.exclude ?? excludeAsset, filteredAssets = origin.assets.filter((asset)=>{
3011
+ }), exclude = options.exclude ?? excludeAsset, filteredAssets = (origin.assets || []).filter((asset)=>{
3006
3012
  let assetInfo = {
3007
3013
  name: asset.name,
3008
3014
  size: asset.size
@@ -3527,7 +3533,7 @@ let generateManifest = (htmlPaths, manifestOptions)=>(_seed, files)=>{
3527
3533
  for (let file of chunkFiles){
3528
3534
  file.isInitial ? file.path.endsWith('.css') ? initialCSS.push(file.path) : initialJS.push(file.path) : file.path.endsWith('.css') ? asyncCSS.push(file.path) : asyncJS.push(file.path);
3529
3535
  let relatedLICENSE = licenseMap.get(file.path);
3530
- for (let auxiliaryFile of (relatedLICENSE && assets.add(relatedLICENSE), file.chunk.auxiliaryFiles))assets.add(auxiliaryFile);
3536
+ if (relatedLICENSE && assets.add(relatedLICENSE), file.chunk) for (let auxiliaryFile of file.chunk.auxiliaryFiles)assets.add(auxiliaryFile);
3531
3537
  }
3532
3538
  let entryManifest = {};
3533
3539
  assets.size && (entryManifest.assets = Array.from(assets));
@@ -4540,65 +4546,27 @@ let resourceHints_generateLinks = (options, rel)=>options.map((option)=>({
4540
4546
  chain.optimization.splitChunks(splitChunksOptions);
4541
4547
  });
4542
4548
  }
4543
- }), getAssetName = (url, assetPrefix)=>url.startsWith(assetPrefix) ? removeLeadingSlash(url.replace(assetPrefix, '')) : removeLeadingSlash(url), isSriLinkRel = (rel)=>'string' == typeof rel && [
4544
- 'stylesheet',
4545
- 'preload',
4546
- 'modulepreload'
4547
- ].includes(rel), pluginSri = ()=>({
4549
+ }), pluginSri = ()=>({
4548
4550
  name: 'rsbuild:sri',
4549
4551
  setup (api) {
4550
- let placeholder = 'RSBUILD_INTEGRITY_PLACEHOLDER:', getAlgorithm = (environment)=>{
4551
- let { config } = environment, { sri } = config.security;
4552
- if (!('auto' === sri.enable ? 'production' === config.mode : sri.enable)) return null;
4552
+ api.modifyBundlerChain((chain, { environment, CHAIN_ID })=>{
4553
+ if ('webpack' === api.context.bundlerType) return;
4554
+ let { config, htmlPaths } = environment;
4555
+ if (0 === Object.keys(htmlPaths).length) return;
4556
+ let { sri } = config.security;
4557
+ if (!('auto' === sri.enable ? 'production' === config.mode : sri.enable)) return;
4558
+ let crossorigin = chain.output.get('crossOriginLoading');
4559
+ (!1 === crossorigin || void 0 === crossorigin) && chain.output.crossOriginLoading('anonymous');
4553
4560
  let { algorithm = 'sha384' } = sri;
4554
- return algorithm;
4555
- };
4556
- api.modifyHTMLTags({
4557
- order: 'post',
4558
- handler (tags, { assetPrefix, environment }) {
4559
- if (!getAlgorithm(environment)) return tags;
4560
- for (let tag of [
4561
- ...tags.headTags,
4562
- ...tags.bodyTags
4563
- ]){
4564
- let url = '';
4565
- if (!tag.attrs || ("script" === tag.tag && 'string' == typeof tag.attrs.src ? url = tag.attrs.src : 'link' === tag.tag && isSriLinkRel(tag.attrs.rel) && 'string' == typeof tag.attrs.href && (url = tag.attrs.href), !url)) continue;
4566
- let assetName = getAssetName(url, assetPrefix);
4567
- assetName && (tag.attrs.integrity ??= `${placeholder}${assetName}`);
4568
- }
4569
- return tags;
4570
- }
4571
- });
4572
- let replaceIntegrity = (htmlContent, assets, algorithm, integrityCache)=>{
4573
- let matches = htmlContent.matchAll(/integrity="RSBUILD_INTEGRITY_PLACEHOLDER:([^"]+)"/g), replacedHtml = htmlContent, calcIntegrity = (algorithm, assetName, data)=>{
4574
- if (integrityCache.has(assetName)) return integrityCache.get(assetName);
4575
- let hash = __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__.default.createHash(algorithm).update(data).digest().toString('base64'), integrity = `${algorithm}-${hash}`;
4576
- return integrityCache.set(assetName, integrity), integrity;
4577
- };
4578
- for (let match of matches){
4579
- let assetName = match[1];
4580
- if (assetName) {
4581
- if (assets[assetName]) {
4582
- let integrity = calcIntegrity(algorithm, assetName, assets[assetName].buffer());
4583
- replacedHtml = replacedHtml.replaceAll(`integrity="${placeholder}${assetName}"`, `integrity="${integrity}"`);
4584
- } else __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug(`[rsbuild:sri] failed to generate integrity for ${assetName}.`), replacedHtml = replacedHtml.replace(`integrity="${placeholder}${assetName}"`, '');
4561
+ chain.plugin(CHAIN_ID.PLUGIN.SUBRESOURCE_INTEGRITY).use(__WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack.experiments.SubresourceIntegrityPlugin, [
4562
+ {
4563
+ enabled: !0,
4564
+ hashFuncNames: [
4565
+ algorithm
4566
+ ],
4567
+ htmlPlugin: __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.join(COMPILED_PATH, 'html-rspack-plugin/index.js')
4585
4568
  }
4586
- }
4587
- return replacedHtml;
4588
- };
4589
- api.processAssets({
4590
- stage: 'report'
4591
- }, ({ assets, sources, environment })=>{
4592
- let { htmlPaths } = environment;
4593
- if (0 === Object.keys(htmlPaths).length) return;
4594
- let algorithm = getAlgorithm(environment);
4595
- if (!algorithm) return;
4596
- let integrityCache = new Map();
4597
- for (let asset of Object.keys(assets)){
4598
- if (!HTML_REGEX.test(asset)) continue;
4599
- let htmlContent = assets[asset].source();
4600
- htmlContent.includes(placeholder) && (assets[asset] = new sources.RawSource(replaceIntegrity(htmlContent, assets, algorithm, integrityCache)));
4601
- }
4569
+ ]);
4602
4570
  });
4603
4571
  }
4604
4572
  }), swc_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__.createRequire)(import.meta.url), builtinSwcLoaderName = 'builtin:swc-loader', pluginSwc = ()=>({
@@ -7335,12 +7303,12 @@ async function runCLI() {
7335
7303
  }
7336
7304
  }(), process.title = 'rsbuild-node';
7337
7305
  let { npm_execpath } = process.env;
7338
- (!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.2.19\n`);
7306
+ (!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.0-beta.0\n`);
7339
7307
  }();
7340
7308
  try {
7341
7309
  !function() {
7342
7310
  let cli = cac_dist('rsbuild');
7343
- cli.help(), cli.version("1.2.19"), applyCommonOptions(cli);
7311
+ cli.help(), cli.version("1.3.0-beta.0"), applyCommonOptions(cli);
7344
7312
  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');
7345
7313
  applyServerOptions(devCommand), applyServerOptions(previewCommand), devCommand.action(async (options)=>{
7346
7314
  try {
@@ -7391,6 +7359,6 @@ async function runCLI() {
7391
7359
  __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);
7392
7360
  }
7393
7361
  }
7394
- let src_version = "1.2.19";
7362
+ let src_version = "1.3.0-beta.0";
7395
7363
  var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger, __webpack_exports__rspack = __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack;
7396
7364
  export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, createRsbuild, defineConfig, ensureAssetPrefix, config_loadConfig as loadConfig, loadEnv, mergeRsbuildConfig, runCLI, src_version as version, __webpack_exports__logger as logger, __webpack_exports__rspack as rspack };
@@ -118,10 +118,8 @@ export declare const CHAIN_ID: {
118
118
  readonly VUE_LOADER_PLUGIN: "vue-loader-plugin";
119
119
  /** ReactFastRefreshPlugin */
120
120
  readonly REACT_FAST_REFRESH: "react-fast-refresh";
121
- /** WebpackSRIPlugin */
121
+ /** SubresourceIntegrityPlugin */
122
122
  readonly SUBRESOURCE_INTEGRITY: "subresource-integrity";
123
- /** AutoSetRootFontSizePlugin */
124
- readonly AUTO_SET_ROOT_SIZE: "auto-set-root-size";
125
123
  };
126
124
  /** Predefined minimizers */
127
125
  readonly MINIMIZER: {
@@ -7,9 +7,19 @@ import type { InternalContext, NormalizedConfig, OutputStructure, PrintUrls, Rou
7
7
  */
8
8
  export type UpgradeEvent = (req: IncomingMessage, socket: Socket, head: any) => void;
9
9
  export type StartServerResult = {
10
+ /**
11
+ * The URLs that server is listening on.
12
+ */
10
13
  urls: string[];
14
+ /**
15
+ * The actual port used by the server.
16
+ */
11
17
  port: number;
12
18
  server: {
19
+ /**
20
+ * Close the server.
21
+ * In development mode, this will call the `onCloseDevServer` hook.
22
+ */
13
23
  close: () => Promise<void>;
14
24
  };
15
25
  };
@@ -337,7 +337,16 @@ export interface ServerConfig {
337
337
  export type NormalizedServerConfig = ServerConfig & Required<Pick<ServerConfig, 'htmlFallback' | 'port' | 'host' | 'compress' | 'strictPort' | 'printUrls' | 'open' | 'base' | 'cors' | 'middlewareMode'>>;
338
338
  export type SriAlgorithm = 'sha256' | 'sha384' | 'sha512';
339
339
  export type SriOptions = {
340
+ /**
341
+ * Specifies the algorithm used to compute the integrity hash.
342
+ * @default 'sha384'
343
+ */
340
344
  algorithm?: SriAlgorithm;
345
+ /**
346
+ * Whether to enable SRI.
347
+ * `'auto'` means it's enabled in production mode and disabled in development mode.
348
+ * @default false
349
+ */
341
350
  enable?: boolean | 'auto';
342
351
  };
343
352
  export interface SecurityConfig {
@@ -116,8 +116,8 @@ export type CreateRsbuildOptions = {
116
116
  */
117
117
  rsbuildConfig?: RsbuildConfig | (() => Promise<RsbuildConfig>);
118
118
  /**
119
- * Whether to call `loadEnv` to load environment variables and define them
120
- * as global variables.
119
+ * Whether to call `loadEnv` to load env variables and define them
120
+ * as global variables via `source.define`.
121
121
  * @default false
122
122
  */
123
123
  loadEnv?: boolean | LoadEnvOptions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/core",
3
- "version": "1.2.19",
3
+ "version": "1.3.0-beta.0",
4
4
  "description": "The Rspack-based build tool.",
5
5
  "homepage": "https://rsbuild.dev",
6
6
  "bugs": {
@@ -46,14 +46,14 @@
46
46
  "types.d.ts"
47
47
  ],
48
48
  "dependencies": {
49
- "@rspack/core": "1.2.8",
49
+ "@rspack/core": "1.3.0-beta.0",
50
50
  "@rspack/lite-tapable": "~1.0.1",
51
51
  "@swc/helpers": "^0.5.15",
52
52
  "core-js": "~3.41.0",
53
53
  "jiti": "^2.4.2"
54
54
  },
55
55
  "devDependencies": {
56
- "@rslib/core": "0.5.3",
56
+ "@rslib/core": "0.5.4",
57
57
  "@types/connect": "3.4.38",
58
58
  "@types/node": "^22.13.10",
59
59
  "@types/on-finished": "2.3.4",