@rsbuild/core 2.0.0-alpha.2 → 2.0.0-alpha.3

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,8 +1,8 @@
1
1
  (() => {
2
2
  var __webpack_modules__ = {
3
- 633: (module, __unused_webpack_exports, __nccwpck_require__) => {
3
+ 595: (module, __unused_webpack_exports, __nccwpck_require__) => {
4
4
  "use strict";
5
- const { HtmlWebpackChildCompiler } = __nccwpck_require__(906);
5
+ const { HtmlWebpackChildCompiler } = __nccwpck_require__(232);
6
6
  const compilerMap = new WeakMap();
7
7
  class CachedChildCompilation {
8
8
  constructor(compiler) {
@@ -311,7 +311,7 @@
311
311
  }
312
312
  module.exports = { CachedChildCompilation };
313
313
  },
314
- 906: (module) => {
314
+ 232: (module) => {
315
315
  "use strict";
316
316
  class HtmlWebpackChildCompiler {
317
317
  constructor(templates) {
@@ -480,7 +480,7 @@
480
480
  }
481
481
  module.exports = { HtmlWebpackChildCompiler };
482
482
  },
483
- 930: (module) => {
483
+ 528: (module) => {
484
484
  "use strict";
485
485
  module.exports = {};
486
486
  module.exports.none = (chunks) => chunks;
@@ -499,7 +499,7 @@
499
499
  };
500
500
  module.exports.auto = module.exports.none;
501
501
  },
502
- 525: (module) => {
502
+ 655: (module) => {
503
503
  "use strict";
504
504
  module.exports = function (err) {
505
505
  return {
@@ -513,14 +513,17 @@
513
513
  },
514
514
  toString: function () {
515
515
  if (err.message) {
516
- return `[html-rspack-plugin]: ` + err.message;
516
+ return (
517
+ `[html-rspack-plugin]: ` +
518
+ (err.stack || `${err.name}: ${err.message}`)
519
+ );
517
520
  }
518
521
  return err;
519
522
  },
520
523
  };
521
524
  };
522
525
  },
523
- 516: (module, __unused_webpack_exports, __nccwpck_require__) => {
526
+ 334: (module, __unused_webpack_exports, __nccwpck_require__) => {
524
527
  "use strict";
525
528
  const { AsyncSeriesWaterfallHook } = __nccwpck_require__(408);
526
529
  const htmlWebpackPluginHooksMap = new WeakMap();
@@ -546,7 +549,7 @@
546
549
  }
547
550
  module.exports = { getHtmlRspackPluginHooks };
548
551
  },
549
- 153: (module) => {
552
+ 915: (module) => {
550
553
  const voidTags = [
551
554
  "area",
552
555
  "base",
@@ -614,19 +617,19 @@
614
617
  htmlTagObjectToString,
615
618
  };
616
619
  },
617
- 12: (module, __unused_webpack_exports, __nccwpck_require__) => {
620
+ 802: (module, __unused_webpack_exports, __nccwpck_require__) => {
618
621
  "use strict";
619
622
  const promisify = __nccwpck_require__(23).promisify;
620
623
  const vm = __nccwpck_require__(154);
621
624
  const fs = __nccwpck_require__(896);
622
625
  const path = __nccwpck_require__(928);
623
- const { CachedChildCompilation } = __nccwpck_require__(633);
626
+ const { CachedChildCompilation } = __nccwpck_require__(595);
624
627
  const { createHtmlTagObject, htmlTagObjectToString, HtmlTagArray } =
625
- __nccwpck_require__(153);
626
- const prettyError = __nccwpck_require__(525);
627
- const chunkSorter = __nccwpck_require__(930);
628
+ __nccwpck_require__(915);
629
+ const prettyError = __nccwpck_require__(655);
630
+ const chunkSorter = __nccwpck_require__(528);
628
631
  const getHtmlRspackPluginHooks =
629
- __nccwpck_require__(516).getHtmlRspackPluginHooks;
632
+ __nccwpck_require__(334).getHtmlRspackPluginHooks;
630
633
  const WITH_PLACEHOLDER = "function __with_placeholder__";
631
634
  class HtmlRspackPlugin {
632
635
  constructor(userOptions = {}) {
@@ -1597,6 +1600,6 @@
1597
1600
  }
1598
1601
  if (typeof __nccwpck_require__ !== "undefined")
1599
1602
  __nccwpck_require__.ab = __dirname + "/";
1600
- var __webpack_exports__ = __nccwpck_require__(12);
1603
+ var __webpack_exports__ = __nccwpck_require__(802);
1601
1604
  module.exports = __webpack_exports__;
1602
1605
  })();
@@ -1 +1 @@
1
- {"name":"html-rspack-plugin","author":"Jan Nicklas <j.nicklas@me.com> (https://github.com/jantimon)","version":"6.1.4","funding":{"type":"opencollective","url":"https://opencollective.com/html-webpack-plugin"},"license":"MIT","types":"index.d.ts","type":"commonjs"}
1
+ {"name":"html-rspack-plugin","author":"Jan Nicklas <j.nicklas@me.com> (https://github.com/jantimon)","version":"6.1.6","funding":{"type":"opencollective","url":"https://opencollective.com/html-webpack-plugin"},"license":"MIT","types":"index.d.ts","type":"commonjs"}
@@ -1,15 +1,15 @@
1
1
  (() => {
2
2
  "use strict";
3
3
  var __webpack_modules__ = {
4
- 791: (module, __unused_webpack_exports, __nccwpck_require__) => {
5
- module.exports = __nccwpck_require__(601)["default"];
4
+ 254: (module, __unused_webpack_exports, __nccwpck_require__) => {
5
+ module.exports = __nccwpck_require__(684)["default"];
6
6
  },
7
- 601: (__unused_webpack_module, exports, __nccwpck_require__) => {
7
+ 684: (__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 _nodePath = _interopRequireDefault(__nccwpck_require__(760));
12
- var _utils = __nccwpck_require__(980);
12
+ var _utils = __nccwpck_require__(277);
13
13
  function _interopRequireDefault(e) {
14
14
  return e && e.__esModule ? e : { default: e };
15
15
  }
@@ -179,7 +179,7 @@
179
179
  callback(null, result.css, map, { ast });
180
180
  }
181
181
  },
182
- 980: (module, exports, __nccwpck_require__) => {
182
+ 277: (module, exports, __nccwpck_require__) => {
183
183
  module = __nccwpck_require__.nmd(module);
184
184
  Object.defineProperty(exports, "__esModule", { value: true });
185
185
  exports.exec = exec;
@@ -715,6 +715,6 @@
715
715
  })();
716
716
  if (typeof __nccwpck_require__ !== "undefined")
717
717
  __nccwpck_require__.ab = __dirname + "/";
718
- var __webpack_exports__ = __nccwpck_require__(791);
718
+ var __webpack_exports__ = __nccwpck_require__(254);
719
719
  module.exports = __webpack_exports__;
720
720
  })();
package/dist/131.js CHANGED
@@ -3446,7 +3446,7 @@ function createPublicContext(context) {
3446
3446
  async function createContext(options, userConfig) {
3447
3447
  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;
3448
3448
  return {
3449
- version: "2.0.0-alpha.2",
3449
+ version: "2.0.0-alpha.3",
3450
3450
  rootPath,
3451
3451
  distPath: '',
3452
3452
  cachePath,
@@ -3614,27 +3614,31 @@ let configChain_CHAIN_ID = {
3614
3614
  MEDIA: 'media',
3615
3615
  ADDITIONAL_ASSETS: 'additional-assets',
3616
3616
  JS: 'js',
3617
- JS_RAW: 'js-raw',
3618
3617
  JS_DATA_URI: 'js-data-uri',
3619
- TS: 'ts',
3620
3618
  CSS: 'css',
3621
- CSS_RAW: 'css-raw',
3622
- CSS_INLINE: 'css-inline',
3623
3619
  LESS: 'less',
3624
- LESS_RAW: 'less-raw',
3625
- LESS_INLINE: 'less-inline',
3626
3620
  SASS: 'sass',
3627
- SASS_RAW: 'sass-raw',
3628
- SASS_INLINE: 'sass-inline',
3629
3621
  STYLUS: 'stylus',
3630
- STYLUS_RAW: 'stylus-raw',
3631
- STYLUS_INLINE: 'stylus-inline',
3632
3622
  SVG: 'svg',
3633
3623
  VUE: 'vue',
3634
3624
  WASM: 'wasm',
3635
3625
  SVELTE: 'svelte'
3636
3626
  },
3637
3627
  ONE_OF: {
3628
+ JS_MAIN: 'js-main',
3629
+ JS_RAW: 'js-raw',
3630
+ CSS_MAIN: 'css-main',
3631
+ CSS_RAW: 'css-raw',
3632
+ CSS_INLINE: 'css-inline',
3633
+ LESS_MAIN: 'less-main',
3634
+ LESS_RAW: 'less-raw',
3635
+ LESS_INLINE: 'less-inline',
3636
+ SASS_MAIN: 'sass-main',
3637
+ SASS_RAW: 'sass-raw',
3638
+ SASS_INLINE: 'sass-inline',
3639
+ STYLUS_MAIN: 'stylus-main',
3640
+ STYLUS_RAW: 'stylus-raw',
3641
+ STYLUS_INLINE: 'stylus-inline',
3638
3642
  SVG: 'svg',
3639
3643
  SVG_RAW: 'svg-asset-raw',
3640
3644
  SVG_URL: 'svg-asset-url',
@@ -3823,7 +3827,8 @@ async function initRsbuildConfig({ context, pluginManager }) {
3823
3827
  let defaultConfig = {
3824
3828
  name: (0, external_node_path_.join)(rootPath, 'public'),
3825
3829
  copyOnBuild: 'auto',
3826
- watch: !1
3830
+ watch: !1,
3831
+ ignore: []
3827
3832
  };
3828
3833
  if (void 0 === publicDir) return [
3829
3834
  defaultConfig
@@ -5935,7 +5940,7 @@ function createMiddleware(context, ready, outputFileSystem) {
5935
5940
  }
5936
5941
  async function setupOutputFileSystem(writeToDisk, compilers) {
5937
5942
  if (!0 !== writeToDisk) {
5938
- let { createFsFromVolume, Volume } = await import("./memfs.js").then(__webpack_require__.t.bind(__webpack_require__, "../../node_modules/.pnpm/memfs@4.51.1/node_modules/memfs/lib/index.js", 23)), outputFileSystem = createFsFromVolume(new Volume());
5943
+ let { createFsFromVolume, Volume } = await import("./memfs.js").then(__webpack_require__.t.bind(__webpack_require__, "../../node_modules/.pnpm/memfs@4.56.10_tslib@2.8.1/node_modules/memfs/lib/index.js", 23)), outputFileSystem = createFsFromVolume(new Volume());
5939
5944
  for (let compiler of compilers)compiler.outputFileSystem = outputFileSystem;
5940
5945
  }
5941
5946
  let compiler = compilers.find((compiler)=>!!compiler.outputFileSystem);
@@ -6736,7 +6741,7 @@ function createProxyMiddleware(proxyOptions) {
6736
6741
  let applyDefaultMiddlewares = async ({ config, buildManager, context, devServerAPI, middlewares, postCallbacks })=>{
6737
6742
  let upgradeEvents = [], { server } = config;
6738
6743
  if (server.cors) {
6739
- let { default: corsMiddleware } = await import("./cors.js").then(__webpack_require__.t.bind(__webpack_require__, "../../node_modules/.pnpm/cors@2.8.5/node_modules/cors/lib/index.js", 23));
6744
+ let { default: corsMiddleware } = await import("./cors.js").then(__webpack_require__.t.bind(__webpack_require__, "../../node_modules/.pnpm/cors@2.8.6/node_modules/cors/lib/index.js", 23));
6740
6745
  middlewares.push(corsMiddleware('boolean' == typeof server.cors ? {} : server.cors));
6741
6746
  }
6742
6747
  let { headers } = server;
@@ -7419,7 +7424,7 @@ class RsbuildProdServer {
7419
7424
  async applyDefaultMiddlewares() {
7420
7425
  let { headers, proxy, historyApiFallback, compress, base, cors } = this.options.serverConfig;
7421
7426
  if (isVerbose() && this.middlewares.use(getRequestLoggerMiddleware()), cors) {
7422
- let { default: corsMiddleware } = await import("./cors.js").then(__webpack_require__.t.bind(__webpack_require__, "../../node_modules/.pnpm/cors@2.8.5/node_modules/cors/lib/index.js", 23));
7427
+ let { default: corsMiddleware } = await import("./cors.js").then(__webpack_require__.t.bind(__webpack_require__, "../../node_modules/.pnpm/cors@2.8.6/node_modules/cors/lib/index.js", 23));
7423
7428
  this.middlewares.use(corsMiddleware('boolean' == typeof cors ? {} : cors));
7424
7429
  }
7425
7430
  if (headers && this.middlewares.use((_req, res, next)=>{
@@ -8108,29 +8113,26 @@ try {
8108
8113
  api.modifyBundlerChain({
8109
8114
  order: 'pre',
8110
8115
  handler: async (chain, { target, isProd, CHAIN_ID, environment, environments })=>{
8111
- let rule = chain.module.rule(CHAIN_ID.RULE.CSS), inlineRule = chain.module.rule(CHAIN_ID.RULE.CSS_INLINE), { config } = environment;
8112
- rule.test(CSS_REGEX).type("javascript/auto").dependency({
8116
+ let cssRule = chain.module.rule(CHAIN_ID.RULE.CSS), { config } = environment;
8117
+ cssRule.test(CSS_REGEX).dependency({
8113
8118
  not: 'url'
8114
- }).resourceQuery({
8115
- not: [
8116
- RAW_QUERY_REGEX,
8117
- INLINE_QUERY_REGEX
8118
- ]
8119
- }), inlineRule.test(CSS_REGEX).type("javascript/auto").resourceQuery(INLINE_QUERY_REGEX), chain.module.rule(CHAIN_ID.RULE.CSS_RAW).test(CSS_REGEX).type('asset/source').resourceQuery(RAW_QUERY_REGEX);
8120
- let emitCss = config.output.emitCss ?? 'web' === target;
8119
+ });
8120
+ let inlineRule = cssRule.oneOf(CHAIN_ID.ONE_OF.CSS_INLINE).type("javascript/auto").resourceQuery(INLINE_QUERY_REGEX);
8121
+ cssRule.oneOf(CHAIN_ID.ONE_OF.CSS_RAW).type('asset/source').resourceQuery(RAW_QUERY_REGEX);
8122
+ let mainRule = cssRule.oneOf(CHAIN_ID.ONE_OF.CSS_MAIN).type("javascript/auto"), emitCss = config.output.emitCss ?? 'web' === target;
8121
8123
  if (emitCss) if (config.output.injectStyles) {
8122
8124
  let styleLoaderOptions = reduceConfigs({
8123
8125
  initial: {},
8124
8126
  config: config.tools.styleLoader
8125
8127
  });
8126
- rule.use(CHAIN_ID.USE.STYLE).loader(getCompiledPath('style-loader')).options(styleLoaderOptions);
8127
- } else rule.use(CHAIN_ID.USE.MINI_CSS_EXTRACT).loader((cssExtractPlugin || rspack_rspack.CssExtractRspackPlugin).loader).options(config.tools.cssExtract.loaderOptions);
8128
- else rule.use(CHAIN_ID.USE.IGNORE_CSS).loader(external_node_path_.default.join(dirname, 'ignoreCssLoader.mjs'));
8128
+ mainRule.use(CHAIN_ID.USE.STYLE).loader(getCompiledPath('style-loader')).options(styleLoaderOptions);
8129
+ } else mainRule.use(CHAIN_ID.USE.MINI_CSS_EXTRACT).loader((cssExtractPlugin || rspack_rspack.CssExtractRspackPlugin).loader).options(config.tools.cssExtract.loaderOptions);
8130
+ else mainRule.use(CHAIN_ID.USE.IGNORE_CSS).loader(external_node_path_.default.join(dirname, 'ignoreCssLoader.mjs'));
8129
8131
  let importLoaders = {
8130
8132
  normal: 0,
8131
8133
  inline: 0
8132
8134
  }, updateRules = (callback, options = {})=>{
8133
- options.skipNormal || callback(rule, 'normal'), callback(inlineRule, 'inline');
8135
+ options.skipMain || callback(mainRule, 'main'), callback(inlineRule, 'inline');
8134
8136
  }, cssLoaderPath = getCompiledPath('css-loader');
8135
8137
  if (updateRules((rule)=>{
8136
8138
  rule.use(CHAIN_ID.USE.CSS).loader(cssLoaderPath);
@@ -8145,7 +8147,7 @@ try {
8145
8147
  let minify = ('inline' === type || config.output.injectStyles) && minifyCss, lightningcssOptions = getLightningCSSLoaderOptions(config, browserslist, minify);
8146
8148
  rule.use(CHAIN_ID.USE.LIGHTNINGCSS).loader('builtin:lightningcss-loader').options(lightningcssOptions);
8147
8149
  }, {
8148
- skipNormal: !emitCss
8150
+ skipMain: !emitCss
8149
8151
  });
8150
8152
  }
8151
8153
  let postcssLoaderOptions = await getPostcssLoaderOptions({
@@ -8159,7 +8161,7 @@ try {
8159
8161
  updateRules((rule)=>{
8160
8162
  rule.use(CHAIN_ID.USE.POSTCSS).loader(postcssLoaderPath).options(postcssLoaderOptions);
8161
8163
  }, {
8162
- skipNormal: !emitCss
8164
+ skipMain: !emitCss
8163
8165
  });
8164
8166
  }
8165
8167
  let localIdentName = config.output.cssModules.localIdentName || (isProd ? '[local]-[hash:base64:6]' : '[path][name]__[local]-[hash:base64:6]'), cssLoaderOptions = (({ config, localIdentName, emitCss })=>{
@@ -8210,7 +8212,7 @@ try {
8210
8212
  }, rule.use(CHAIN_ID.USE.CSS).options(finalOptions), rule.sideEffects(!0), rule.resolve.preferRelative(!0);
8211
8213
  });
8212
8214
  let isStringExport = 'string' === cssLoaderOptions.exportType;
8213
- if (isStringExport && rule.uses.has(CHAIN_ID.USE.MINI_CSS_EXTRACT) && rule.uses.delete(CHAIN_ID.USE.MINI_CSS_EXTRACT), emitCss && !config.output.injectStyles && !isStringExport) {
8215
+ if (isStringExport && mainRule.uses.has(CHAIN_ID.USE.MINI_CSS_EXTRACT) && mainRule.uses.delete(CHAIN_ID.USE.MINI_CSS_EXTRACT), emitCss && !config.output.injectStyles && !isStringExport) {
8214
8216
  let extractPluginOptions = config.tools.cssExtract.pluginOptions, cssPath = config.output.distPath.css, cssFilename = getFilename(config, 'css', isProd), isCssFilenameFn = 'function' == typeof cssFilename, cssAsyncPath = config.output.distPath.cssAsync ?? (cssPath ? `${cssPath}/async` : 'async');
8215
8217
  chain.plugin(CHAIN_ID.PLUGIN.MINI_CSS_EXTRACT).use(cssExtractPlugin || rspack_rspack.CssExtractRspackPlugin, [
8216
8218
  {
@@ -8281,13 +8283,11 @@ try {
8281
8283
  api.modifyBundlerChain({
8282
8284
  order: 'pre',
8283
8285
  handler: (chain, { CHAIN_ID, isDev, isProd, target, environment })=>{
8284
- let { config, browserslist } = 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({
8286
+ let { config, browserslist } = environment, cacheRoot = external_node_path_.default.join(api.context.cachePath, '.swc'), rule = chain.module.rule(CHAIN_ID.RULE.JS).test(SCRIPT_REGEX).dependency({
8285
8287
  not: 'url'
8286
- }).resourceQuery({
8287
- not: RAW_QUERY_REGEX
8288
8288
  });
8289
- chain.module.rule(CHAIN_ID.RULE.JS_RAW).test(SCRIPT_REGEX).type('asset/source').resourceQuery(RAW_QUERY_REGEX);
8290
- let dataUriRule = chain.module.rule(CHAIN_ID.RULE.JS_DATA_URI).mimetype({
8289
+ rule.oneOf(CHAIN_ID.ONE_OF.JS_RAW).resourceQuery(RAW_QUERY_REGEX).type('asset/source');
8290
+ let mainRule = rule.oneOf(CHAIN_ID.ONE_OF.JS_MAIN).type("javascript/auto"), dataUriRule = chain.module.rule(CHAIN_ID.RULE.JS_DATA_URI).mimetype({
8291
8291
  or: [
8292
8292
  "text/javascript",
8293
8293
  "application/javascript"
@@ -8311,7 +8311,7 @@ try {
8311
8311
  swcConfig.env.mode = polyfill;
8312
8312
  let coreJsDir = applyCoreJs(swcConfig, polyfill, api.context.rootPath);
8313
8313
  if (coreJsDir) for (let item of [
8314
- rule,
8314
+ mainRule,
8315
8315
  dataUriRule
8316
8316
  ])item.resolve.alias.set('core-js', coreJsDir);
8317
8317
  }
@@ -8321,7 +8321,7 @@ try {
8321
8321
  config: config.tools.swc,
8322
8322
  mergeFn: cjs_default()
8323
8323
  });
8324
- mergedConfig.jsc?.target !== void 0 && mergedConfig.env?.targets !== void 0 && 1 === Object.keys(mergedConfig.env).length && delete mergedConfig.env, rule.use(CHAIN_ID.USE.SWC).loader(builtinSwcLoaderName).options(mergedConfig), dataUriRule.resolve.set('fullySpecified', !1).end().use(CHAIN_ID.USE.SWC).loader(builtinSwcLoaderName).options(cloneDeep(mergedConfig));
8324
+ mergedConfig.jsc?.target !== void 0 && mergedConfig.env?.targets !== void 0 && 1 === Object.keys(mergedConfig.env).length && delete mergedConfig.env, mainRule.use(CHAIN_ID.USE.SWC).loader(builtinSwcLoaderName).options(mergedConfig), dataUriRule.resolve.set('fullySpecified', !1).end().use(CHAIN_ID.USE.SWC).loader(builtinSwcLoaderName).options(cloneDeep(mergedConfig));
8325
8325
  }
8326
8326
  });
8327
8327
  }
@@ -8557,9 +8557,26 @@ try {
8557
8557
  });
8558
8558
  };
8559
8559
  api.onAfterStartDevServer(onStartServer), api.onAfterStartProdServer(onStartServer), api.onBeforeBuild(async ({ isFirstCompile, environments })=>{
8560
- if (isFirstCompile) for (let { name: publicDir, copyOnBuild } of api.getNormalizedConfig().server.publicDir){
8560
+ if (isFirstCompile) for (let { name: publicDir, copyOnBuild, ignore } of api.getNormalizedConfig().server.publicDir){
8561
+ let shouldCopy;
8561
8562
  if (!1 === copyOnBuild || !external_node_fs_.default.existsSync(publicDir)) continue;
8562
8563
  let distPaths = dedupeNestedPaths(Object.values(environments).filter(({ config })=>!0 === copyOnBuild || 'auto' === copyOnBuild && 'node' !== config.output.target).map(({ distPath })=>distPath));
8564
+ if (ignore?.length) {
8565
+ let { globSync } = await import("./tinyglobby.js").then((mod)=>({
8566
+ globSync: mod.globSync
8567
+ })), ignoredSet = new Set(globSync(ignore, {
8568
+ cwd: publicDir,
8569
+ absolute: !1,
8570
+ dot: !0,
8571
+ onlyFiles: !1
8572
+ }).map((item)=>item.replace(/\\/g, '/').replace(/\/$/, '')));
8573
+ shouldCopy = (source)=>{
8574
+ let relativePath = external_node_path_.default.relative(publicDir, source);
8575
+ if (!relativePath) return !0;
8576
+ let normalizedPath = relativePath.replace(/\\/g, '/');
8577
+ return !ignoredSet.has(normalizedPath);
8578
+ };
8579
+ }
8563
8580
  try {
8564
8581
  await Promise.all(distPaths.map(async (distPath)=>{
8565
8582
  isDeno && external_node_fs_.default.existsSync(distPath) && await external_node_fs_.default.promises.rm(distPath, {
@@ -8568,7 +8585,8 @@ try {
8568
8585
  }), await external_node_fs_.default.promises.cp(publicDir, distPath, {
8569
8586
  recursive: !0,
8570
8587
  dereference: !0,
8571
- mode: external_node_fs_.default.constants.COPYFILE_FICLONE
8588
+ mode: external_node_fs_.default.constants.COPYFILE_FICLONE,
8589
+ filter: shouldCopy
8572
8590
  });
8573
8591
  }));
8574
8592
  } catch (err) {
@@ -8585,7 +8603,7 @@ try {
8585
8603
  api.modifyBundlerChain(async (chain, { CHAIN_ID, environment, isDev })=>{
8586
8604
  let { output: { manifest }, dev: { writeToDisk } } = environment.config;
8587
8605
  if (!1 === manifest) return;
8588
- let manifestOptions = normalizeManifestObjectConfig(manifest), { RspackManifestPlugin } = await import("./manifest-plugin.js").then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-alpha.0_@module-federation+runtime-tools@0.22.1_@swc+helpers@0.5.18_/node_modules/rspack-manifest-plugin/dist/index.js")), { htmlPaths } = environment, filter = manifestOptions.filter ?? ((file)=>!file.name.endsWith('.LICENSE.txt'));
8606
+ let manifestOptions = normalizeManifestObjectConfig(manifest), { RspackManifestPlugin } = await import("./manifest-plugin.js").then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-alpha.0_@module-federation+runtime-tools@0.23.0_@swc+helpers@0.5.18_/node_modules/rspack-manifest-plugin/dist/index.js")), { htmlPaths } = environment, filter = manifestOptions.filter ?? ((file)=>!file.name.endsWith('.LICENSE.txt'));
8589
8607
  manifestFilenames.set(environment.name, manifestOptions.filename);
8590
8608
  let pluginOptions = {
8591
8609
  fileName: manifestOptions.filename,
@@ -8920,7 +8938,7 @@ async function createRsbuild(options = {}) {
8920
8938
  function defineConfig(config) {
8921
8939
  return config;
8922
8940
  }
8923
- async function loadConfig_loadConfig({ cwd = process.cwd(), path, envMode, meta, loader = 'jiti' } = {}) {
8941
+ async function loadConfig_loadConfig({ cwd = process.cwd(), path, envMode, meta, loader = 'auto' } = {}) {
8924
8942
  let configExport, configFilePath = ((root, customConfig)=>{
8925
8943
  if (customConfig) {
8926
8944
  let customConfigPath = (0, external_node_path_.isAbsolute)(customConfig) ? customConfig : (0, external_node_path_.join)(root, customConfig);
@@ -9094,7 +9112,7 @@ let applyServerOptions = (command)=>{
9094
9112
  };
9095
9113
  function setupCommands() {
9096
9114
  let cli = ((name = "")=>new CAC(name))('rsbuild');
9097
- cli.version("2.0.0-alpha.2"), 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)', {
9115
+ cli.version("2.0.0-alpha.3"), 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)', {
9098
9116
  default: 'auto'
9099
9117
  }).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', {
9100
9118
  type: [
@@ -9163,7 +9181,7 @@ function initNodeEnv() {
9163
9181
  }
9164
9182
  function showGreeting() {
9165
9183
  let { npm_execpath, npm_lifecycle_event, NODE_RUN_SCRIPT_NAME } = process.env, isBun = npm_execpath?.includes('.bun');
9166
- src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.0.0-alpha.2\n`);
9184
+ src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.0.0-alpha.3\n`);
9167
9185
  }
9168
9186
  function setupLogLevel() {
9169
9187
  let logLevelIndex = process.argv.findIndex((item)=>'--log-level' === item || '--logLevel' === item);
@@ -9184,5 +9202,5 @@ function runCLI() {
9184
9202
  src_logger.error('Failed to start Rsbuild CLI.'), src_logger.error(err), process.exit(1);
9185
9203
  }
9186
9204
  }
9187
- let src_version = "2.0.0-alpha.2";
9205
+ let src_version = "2.0.0-alpha.3";
9188
9206
  export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, createRsbuild, defaultAllowedOrigins, defineConfig, ensureAssetPrefix, external_node_os_type, external_node_util_promisify, loadConfig_loadConfig as loadConfig, loadEnv, mergeRsbuildConfig, node_os, node_process, rspack_rspack as rspack, runCLI, src_logger as logger, src_version as version };
@@ -1,6 +1,26 @@
1
1
  import { logger } from "./59.js";
2
2
  let createOverlay;
3
3
  let clearOverlay;
4
+ function setupCustomHMRListeners(customListenersMap) {
5
+ __webpack_require__.i.push(({ module })=>{
6
+ const newListeners = new Map();
7
+ const addToMap = (map, event, cb)=>{
8
+ const existing = map.get(event) || [];
9
+ existing.push(cb);
10
+ map.set(event, existing);
11
+ };
12
+ module.hot.on = (event, cb)=>{
13
+ addToMap(customListenersMap, event, cb);
14
+ addToMap(newListeners, event, cb);
15
+ };
16
+ module.hot.dispose(()=>{
17
+ for (const [event, staleFns] of newListeners){
18
+ const listeners = customListenersMap.get(event);
19
+ if (listeners) customListenersMap.set(event, listeners.filter((l)=>!staleFns.includes(l)));
20
+ }
21
+ });
22
+ });
23
+ }
4
24
  const registerOverlay = (createFn, clearFn)=>{
5
25
  createOverlay = createFn;
6
26
  clearOverlay = clearFn;
@@ -9,6 +29,7 @@ function init(token, config, serverHost, serverPort, liveReload, browserLogs, lo
9
29
  logger.level = logLevel;
10
30
  const queuedMessages = [];
11
31
  const clientErrors = [];
32
+ const customListenersMap = new Map();
12
33
  let lastHash;
13
34
  let hasBuildErrors = false;
14
35
  function formatURL(fallback) {
@@ -124,6 +145,17 @@ function init(token, config, serverHost, serverPort, liveReload, browserLogs, lo
124
145
  case 'resolved-client-error':
125
146
  handleResolvedClientError(message.data);
126
147
  break;
148
+ case 'custom':
149
+ {
150
+ const { event, data } = message.data;
151
+ if (event) {
152
+ const cbs = customListenersMap.get(event);
153
+ if (cbs) cbs.forEach((cb)=>{
154
+ cb(data);
155
+ });
156
+ }
157
+ break;
158
+ }
127
159
  }
128
160
  }
129
161
  function onClose() {
@@ -200,6 +232,7 @@ function init(token, config, serverHost, serverPort, liveReload, browserLogs, lo
200
232
  });
201
233
  window.addEventListener('unhandledrejection', onUnhandledRejection);
202
234
  }
235
+ if (module.hot) setupCustomHMRListeners(customListenersMap);
203
236
  connect();
204
237
  }
205
238
  export { init, registerOverlay };
package/dist/cors.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*! For license information please see cors.js.LICENSE.txt */
2
2
  import { __webpack_require__ } from "./rslib-runtime.js";
3
3
  __webpack_require__.add({
4
- "../../node_modules/.pnpm/cors@2.8.5/node_modules/cors/lib/index.js" (module, __unused_rspack_exports, __webpack_require__) {
4
+ "../../node_modules/.pnpm/cors@2.8.6/node_modules/cors/lib/index.js" (module, __unused_rspack_exports, __webpack_require__) {
5
5
  !function() {
6
6
  'use strict';
7
7
  var assign = __webpack_require__("../../node_modules/.pnpm/object-assign@4.1.1/node_modules/object-assign/index.js"), vary = __webpack_require__("../../node_modules/.pnpm/vary@1.1.2/node_modules/vary/index.js"), defaults = {
@@ -93,7 +93,7 @@ __webpack_require__.add({
93
93
  }
94
94
  function cors(options, req, res, next) {
95
95
  var headers = [];
96
- 'OPTIONS' === (req.method && req.method.toUpperCase && req.method.toUpperCase()) ? (headers.push(configureOrigin(options, req)), headers.push(configureCredentials(options, req)), headers.push(configureMethods(options, req)), headers.push(configureAllowedHeaders(options, req)), headers.push(configureMaxAge(options, req)), headers.push(configureExposedHeaders(options, req)), applyHeaders(headers, res), options.preflightContinue ? next() : (res.statusCode = options.optionsSuccessStatus, res.setHeader('Content-Length', '0'), res.end())) : (headers.push(configureOrigin(options, req)), headers.push(configureCredentials(options, req)), headers.push(configureExposedHeaders(options, req)), applyHeaders(headers, res), next());
96
+ 'OPTIONS' === (req.method && req.method.toUpperCase && req.method.toUpperCase()) ? (headers.push(configureOrigin(options, req)), headers.push(configureCredentials(options)), headers.push(configureMethods(options)), headers.push(configureAllowedHeaders(options, req)), headers.push(configureMaxAge(options)), headers.push(configureExposedHeaders(options)), applyHeaders(headers, res), options.preflightContinue ? next() : (res.statusCode = options.optionsSuccessStatus, res.setHeader('Content-Length', '0'), res.end())) : (headers.push(configureOrigin(options, req)), headers.push(configureCredentials(options)), headers.push(configureExposedHeaders(options)), applyHeaders(headers, res), next());
97
97
  }
98
98
  module.exports = function middlewareWrapper(o) {
99
99
  var optionsCallback = null;
@@ -2,7 +2,7 @@ import * as __rspack_external__rspack_lite_tapable_c6bdf810 from "@rspack/lite-t
2
2
  import { __webpack_require__ } from "./rslib-runtime.js";
3
3
  import "./131.js";
4
4
  __webpack_require__.add({
5
- "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-alpha.0_@module-federation+runtime-tools@0.22.1_@swc+helpers@0.5.18_/node_modules/rspack-manifest-plugin/dist/helpers.js" (__unused_rspack_module, exports, __webpack_require__) {
5
+ "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-alpha.0_@module-federation+runtime-tools@0.23.0_@swc+helpers@0.5.18_/node_modules/rspack-manifest-plugin/dist/helpers.js" (__unused_rspack_module, exports, __webpack_require__) {
6
6
  Object.defineProperty(exports, "__esModule", {
7
7
  value: !0
8
8
  }), exports.transformFiles = exports.reduceChunk = exports.reduceAssets = exports.generateManifest = void 0;
@@ -64,11 +64,11 @@ __webpack_require__.add({
64
64
  'sort'
65
65
  ].filter((fname)=>!!options[fname]).reduce((prev, fname)=>prev[fname](options[fname]), files).map(standardizeFilePaths);
66
66
  },
67
- "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-alpha.0_@module-federation+runtime-tools@0.22.1_@swc+helpers@0.5.18_/node_modules/rspack-manifest-plugin/dist/hooks.js" (__unused_rspack_module, exports, __webpack_require__) {
67
+ "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-alpha.0_@module-federation+runtime-tools@0.23.0_@swc+helpers@0.5.18_/node_modules/rspack-manifest-plugin/dist/hooks.js" (__unused_rspack_module, exports, __webpack_require__) {
68
68
  Object.defineProperty(exports, "__esModule", {
69
69
  value: !0
70
70
  }), exports.normalModuleLoaderHook = exports.getCompilerHooks = exports.emitHook = exports.beforeRunHook = void 0;
71
- let node_fs_1 = __webpack_require__("node:fs"), node_path_1 = __webpack_require__("node:path"), lite_tapable_1 = __webpack_require__("@rspack/lite-tapable"), helpers_1 = __webpack_require__("../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-alpha.0_@module-federation+runtime-tools@0.22.1_@swc+helpers@0.5.18_/node_modules/rspack-manifest-plugin/dist/helpers.js"), compilerHookMap = new WeakMap(), getCompilerHooks = (compiler)=>{
71
+ let node_fs_1 = __webpack_require__("node:fs"), node_path_1 = __webpack_require__("node:path"), lite_tapable_1 = __webpack_require__("@rspack/lite-tapable"), helpers_1 = __webpack_require__("../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-alpha.0_@module-federation+runtime-tools@0.23.0_@swc+helpers@0.5.18_/node_modules/rspack-manifest-plugin/dist/helpers.js"), compilerHookMap = new WeakMap(), getCompilerHooks = (compiler)=>{
72
72
  let hooks = compilerHookMap.get(compiler);
73
73
  return void 0 === hooks && (hooks = {
74
74
  afterEmit: new lite_tapable_1.SyncWaterfallHook([
@@ -122,9 +122,9 @@ __webpack_require__.add({
122
122
  }), emitFile.call(module, file, content, sourceMap));
123
123
  };
124
124
  },
125
- "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-alpha.0_@module-federation+runtime-tools@0.22.1_@swc+helpers@0.5.18_/node_modules/rspack-manifest-plugin/dist/index.js" (__unused_rspack_module, exports, __webpack_require__) {
125
+ "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-alpha.0_@module-federation+runtime-tools@0.23.0_@swc+helpers@0.5.18_/node_modules/rspack-manifest-plugin/dist/index.js" (__unused_rspack_module, exports, __webpack_require__) {
126
126
  exports.RspackManifestPlugin = void 0;
127
- let node_path_1 = __webpack_require__("node:path"), hooks_1 = __webpack_require__("../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-alpha.0_@module-federation+runtime-tools@0.22.1_@swc+helpers@0.5.18_/node_modules/rspack-manifest-plugin/dist/hooks.js"), emitCountMap = new Map(), defaults = {
127
+ let node_path_1 = __webpack_require__("node:path"), hooks_1 = __webpack_require__("../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-alpha.0_@module-federation+runtime-tools@0.23.0_@swc+helpers@0.5.18_/node_modules/rspack-manifest-plugin/dist/hooks.js"), emitCountMap = new Map(), defaults = {
128
128
  assetHookStage: 1 / 0,
129
129
  basePath: '',
130
130
  fileName: 'manifest.json',