@rsbuild/core 2.0.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"name":"postcss","author":"Andrey Sitnik <andrey@sitnik.es>","version":"8.5.10","funding":[{"type":"opencollective","url":"https://opencollective.com/postcss/"},{"type":"tidelift","url":"https://tidelift.com/funding/github/npm/postcss"},{"type":"github","url":"https://github.com/sponsors/ai"}],"license":"MIT","types":"./lib/postcss.d.ts","type":"commonjs"}
1
+ {"name":"postcss","author":"Andrey Sitnik <andrey@sitnik.es>","version":"8.5.12","funding":[{"type":"opencollective","url":"https://opencollective.com/postcss/"},{"type":"tidelift","url":"https://tidelift.com/funding/github/npm/postcss"},{"type":"github","url":"https://github.com/sponsors/ai"}],"license":"MIT","types":"./lib/postcss.d.ts","type":"commonjs"}
@@ -1,15 +1,15 @@
1
1
  (() => {
2
2
  "use strict";
3
3
  var __webpack_modules__ = {
4
- 914: (module, __unused_webpack_exports, __nccwpck_require__) => {
5
- module.exports = __nccwpck_require__(616)["default"];
4
+ 629: (module, __unused_webpack_exports, __nccwpck_require__) => {
5
+ module.exports = __nccwpck_require__(735)["default"];
6
6
  },
7
- 616: (__unused_webpack_module, exports, __nccwpck_require__) => {
7
+ 735: (__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__(329);
12
+ var _utils = __nccwpck_require__(74);
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
- 329: (module, exports, __nccwpck_require__) => {
182
+ 74: (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__(914);
719
+ var __webpack_exports__ = __nccwpck_require__(629);
720
720
  module.exports = __webpack_exports__;
721
721
  })();
package/dist/753.js CHANGED
@@ -384,8 +384,8 @@ __webpack_require__.add({
384
384
  return (asyncHooks.AsyncResource && (res = new asyncHooks.AsyncResource(fn.name || 'bound-anonymous-fn')), res && res.runInAsyncScope) ? res.runInAsyncScope.bind(res, fn, null) : fn;
385
385
  }
386
386
  },
387
- "../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.10_yaml@2.8.2/node_modules/postcss-load-config/src/index.js" (module, __unused_rspack_exports, __webpack_require__) {
388
- let yaml, { resolve } = __webpack_require__("node:path?435f"), config = __webpack_require__("../../node_modules/.pnpm/lilconfig@3.1.3/node_modules/lilconfig/src/index.js"), loadOptions = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.10_yaml@2.8.2/node_modules/postcss-load-config/src/options.js"), loadPlugins = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.10_yaml@2.8.2/node_modules/postcss-load-config/src/plugins.js"), req = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.10_yaml@2.8.2/node_modules/postcss-load-config/src/req.js");
387
+ "../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.12_yaml@2.8.2/node_modules/postcss-load-config/src/index.js" (module, __unused_rspack_exports, __webpack_require__) {
388
+ let yaml, { resolve } = __webpack_require__("node:path?435f"), config = __webpack_require__("../../node_modules/.pnpm/lilconfig@3.1.3/node_modules/lilconfig/src/index.js"), loadOptions = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.12_yaml@2.8.2/node_modules/postcss-load-config/src/options.js"), loadPlugins = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.12_yaml@2.8.2/node_modules/postcss-load-config/src/plugins.js"), req = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.12_yaml@2.8.2/node_modules/postcss-load-config/src/req.js");
389
389
  async function processResult(ctx, result) {
390
390
  let obj, file = result.filepath || '', projectConfig = ((obj = result.config) && obj.__esModule ? obj : {
391
391
  default: obj
@@ -458,8 +458,8 @@ __webpack_require__.add({
458
458
  });
459
459
  };
460
460
  },
461
- "../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.10_yaml@2.8.2/node_modules/postcss-load-config/src/options.js" (module, __unused_rspack_exports, __webpack_require__) {
462
- let req = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.10_yaml@2.8.2/node_modules/postcss-load-config/src/req.js");
461
+ "../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.12_yaml@2.8.2/node_modules/postcss-load-config/src/options.js" (module, __unused_rspack_exports, __webpack_require__) {
462
+ let req = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.12_yaml@2.8.2/node_modules/postcss-load-config/src/req.js");
463
463
  module.exports = async function options(config, file) {
464
464
  if (config.parser && 'string' == typeof config.parser) try {
465
465
  config.parser = await req(config.parser, file);
@@ -479,8 +479,8 @@ __webpack_require__.add({
479
479
  return config;
480
480
  };
481
481
  },
482
- "../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.10_yaml@2.8.2/node_modules/postcss-load-config/src/plugins.js" (module, __unused_rspack_exports, __webpack_require__) {
483
- let req = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.10_yaml@2.8.2/node_modules/postcss-load-config/src/req.js");
482
+ "../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.12_yaml@2.8.2/node_modules/postcss-load-config/src/plugins.js" (module, __unused_rspack_exports, __webpack_require__) {
483
+ let req = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.12_yaml@2.8.2/node_modules/postcss-load-config/src/req.js");
484
484
  async function load(plugin, options, file) {
485
485
  try {
486
486
  if (null == options || 0 === Object.keys(options).length) return await req(plugin, file);
@@ -496,7 +496,7 @@ __webpack_require__.add({
496
496
  }), list;
497
497
  };
498
498
  },
499
- "../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.10_yaml@2.8.2/node_modules/postcss-load-config/src/req.js" (module, __unused_rspack_exports, __webpack_require__) {
499
+ "../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.12_yaml@2.8.2/node_modules/postcss-load-config/src/req.js" (module, __unused_rspack_exports, __webpack_require__) {
500
500
  let tsx, jiti;
501
501
  var __filename = __rspack_fileURLToPath(import.meta.url);
502
502
  let { createRequire } = __webpack_require__("node:module?1bcb"), { pathToFileURL } = __webpack_require__("node:url?b4ec"), TS_EXT_RE = /\.[mc]?ts$/, importError = [];
@@ -3467,7 +3467,7 @@ function createPublicContext(context) {
3467
3467
  async function createContext(options, userConfig, logger) {
3468
3468
  let { cwd } = options, rootPath = userConfig.root ? ensureAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = join(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0;
3469
3469
  return {
3470
- version: "2.0.1",
3470
+ version: "2.0.2",
3471
3471
  rootPath,
3472
3472
  distPath: '',
3473
3473
  cachePath,
@@ -3660,6 +3660,7 @@ let configChain_CHAIN_ID = {
3660
3660
  JS_RAW: 'js-raw',
3661
3661
  CSS_MAIN: 'css',
3662
3662
  CSS_RAW: 'css-raw',
3663
+ CSS_URL: 'css-url',
3663
3664
  CSS_INLINE: 'css-inline',
3664
3665
  SVG: 'svg',
3665
3666
  SVG_RAW: 'svg-asset-raw',
@@ -3671,6 +3672,7 @@ let configChain_CHAIN_ID = {
3671
3672
  USE: {
3672
3673
  TS: 'ts',
3673
3674
  CSS: 'css',
3675
+ CSS_URL: 'css-url',
3674
3676
  SASS: 'sass',
3675
3677
  LESS: 'less',
3676
3678
  STYLUS: 'stylus',
@@ -4316,21 +4318,39 @@ let addTrailingSep = (dir)=>dir.endsWith(sep) ? dir : dir + sep, isStrictSubdir
4316
4318
  ...defaultOptions,
4317
4319
  ...userOptions
4318
4320
  };
4319
- };
4321
+ }, getConsolePureFuncs = (methods)=>methods.map((method)=>`console.${method}`), ALL_CONSOLE_PURE_FUNCS = getConsolePureFuncs([
4322
+ 'assert',
4323
+ 'clear',
4324
+ 'count',
4325
+ 'countReset',
4326
+ 'debug',
4327
+ 'dir',
4328
+ 'dirxml',
4329
+ 'error',
4330
+ 'group',
4331
+ 'groupCollapsed',
4332
+ 'groupEnd',
4333
+ 'info',
4334
+ 'log',
4335
+ 'profile',
4336
+ 'profileEnd',
4337
+ 'table',
4338
+ 'time',
4339
+ 'timeEnd',
4340
+ 'timeLog',
4341
+ 'timeStamp',
4342
+ 'trace',
4343
+ 'warn'
4344
+ ]);
4320
4345
  function getSwcMinimizerOptions(config, jsOptions) {
4321
4346
  let options = {};
4322
4347
  options.minimizerOptions ||= {}, options.minimizerOptions.format ||= {};
4323
4348
  let { removeConsole } = config.performance;
4324
- if (!0 === removeConsole) options.minimizerOptions.compress = {
4325
- drop_console: !0
4326
- };
4327
- else if (Array.isArray(removeConsole)) {
4328
- let pureFuncs = removeConsole.map((method)=>`console.${method}`);
4329
- options.minimizerOptions.compress = {
4330
- pure_funcs: pureFuncs
4331
- };
4332
- }
4333
- if (config.output.legalComments) switch(config.output.legalComments){
4349
+ if (!0 === removeConsole ? options.minimizerOptions.compress = {
4350
+ pure_funcs: ALL_CONSOLE_PURE_FUNCS
4351
+ } : Array.isArray(removeConsole) && (options.minimizerOptions.compress = {
4352
+ pure_funcs: getConsolePureFuncs(removeConsole)
4353
+ }), config.output.legalComments) switch(config.output.legalComments){
4334
4354
  case 'inline':
4335
4355
  options.minimizerOptions.format.comments = 'some', options.extractComments = !1;
4336
4356
  break;
@@ -4358,7 +4378,7 @@ function parseMinifyOptions(config) {
4358
4378
  cssOptions: minify.cssOptions
4359
4379
  };
4360
4380
  }
4361
- let postcss_load_config_src = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.10_yaml@2.8.2/node_modules/postcss-load-config/src/index.js");
4381
+ let postcss_load_config_src = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.12_yaml@2.8.2/node_modules/postcss-load-config/src/index.js");
4362
4382
  var postcss_load_config_src_default = __webpack_require__.n(postcss_load_config_src);
4363
4383
  function getLightningCSSLoaderOptions(config, targets, minify) {
4364
4384
  let userOptions = 'object' == typeof config.tools.lightningcssLoader ? config.tools.lightningcssLoader : {}, initialOptions = {
@@ -8205,6 +8225,8 @@ try {
8205
8225
  cssRule.test(CSS_REGEX).dependency({
8206
8226
  not: 'url'
8207
8227
  });
8228
+ let urlRule = cssRule.oneOf(CHAIN_ID.ONE_OF.CSS_URL).resourceQuery(/^\?url$/);
8229
+ urlRule.use(CHAIN_ID.USE.CSS_URL).loader(node_path.join(dirname, 'cssUrlLoader.mjs'));
8208
8230
  let inlineRule = cssRule.oneOf(CHAIN_ID.ONE_OF.CSS_INLINE).resourceQuery(INLINE_QUERY_REGEX);
8209
8231
  cssRule.oneOf(CHAIN_ID.ONE_OF.CSS_RAW).type('asset/source').resourceQuery(RAW_QUERY_REGEX);
8210
8232
  let mainRule = cssRule.oneOf(CHAIN_ID.ONE_OF.CSS_MAIN), emitCss = config.output.emitCss ?? 'web' === target;
@@ -8220,7 +8242,7 @@ try {
8220
8242
  normal: 0,
8221
8243
  inline: 0
8222
8244
  }, updateRules = (callback, options = {})=>{
8223
- options.skipMain || callback(mainRule, 'main'), callback(inlineRule, 'inline');
8245
+ options.skipMain || callback(mainRule, 'main'), callback(inlineRule, 'inline'), callback(urlRule, 'url');
8224
8246
  }, cssLoaderPath = join(COMPILED_PATH, 'css-loader', 'index.js');
8225
8247
  if (updateRules((rule)=>{
8226
8248
  rule.use(CHAIN_ID.USE.CSS).loader(cssLoaderPath);
@@ -8232,7 +8254,7 @@ try {
8232
8254
  webEnvironment && (browserslist = webEnvironment.browserslist, minifyCss = parseMinifyOptions(webEnvironment.config).minifyCss);
8233
8255
  }
8234
8256
  updateRules((rule, type)=>{
8235
- let minify = ('inline' === type || config.output.injectStyles) && minifyCss, lightningcssOptions = getLightningCSSLoaderOptions(config, browserslist, minify);
8257
+ let minify = ('inline' === type || 'url' === type || config.output.injectStyles) && minifyCss, lightningcssOptions = getLightningCSSLoaderOptions(config, browserslist, minify);
8236
8258
  rule.use(CHAIN_ID.USE.LIGHTNINGCSS).loader('builtin:lightningcss-loader').options(lightningcssOptions);
8237
8259
  }, {
8238
8260
  skipMain: !emitCss
@@ -8289,7 +8311,7 @@ try {
8289
8311
  });
8290
8312
  updateRules((rule, type)=>{
8291
8313
  let finalOptions = cssLoaderOptions;
8292
- finalOptions = 'inline' === type ? {
8314
+ finalOptions = 'inline' === type || 'url' === type ? {
8293
8315
  ...cssLoaderOptions,
8294
8316
  exportType: 'string',
8295
8317
  modules: !1,
@@ -8297,7 +8319,12 @@ try {
8297
8319
  } : {
8298
8320
  ...cssLoaderOptions,
8299
8321
  importLoaders: importLoaders.normal
8300
- }, rule.use(CHAIN_ID.USE.CSS).options(finalOptions), rule.sideEffects(!0), rule.resolve.preferRelative(!0);
8322
+ }, rule.use(CHAIN_ID.USE.CSS).options(finalOptions), 'url' !== type && rule.sideEffects(!0), rule.resolve.preferRelative(!0);
8323
+ });
8324
+ let cssUrlFilename = getFilename(config, 'css', isProd), cssUrlPath = config.output.distPath.css;
8325
+ urlRule.use(CHAIN_ID.USE.CSS_URL).options({
8326
+ filename: 'function' == typeof cssUrlFilename ? (pathData, assetInfo)=>posix.join(cssUrlPath, cssUrlFilename(pathData, assetInfo)) : posix.join(cssUrlPath, cssUrlFilename),
8327
+ modules: cssLoaderOptions.modules
8301
8328
  });
8302
8329
  let isStringExport = 'string' === cssLoaderOptions.exportType;
8303
8330
  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) {
@@ -9194,7 +9221,7 @@ let applyServerOptions = (command)=>{
9194
9221
  };
9195
9222
  function setupCommands() {
9196
9223
  let cli = ((name = "")=>new CAC(name))('rsbuild');
9197
- cli.version("2.0.1"), 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)', {
9224
+ cli.version("2.0.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)', {
9198
9225
  default: 'auto'
9199
9226
  }).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', {
9200
9227
  type: [
@@ -9271,7 +9298,7 @@ function initNodeEnv() {
9271
9298
  }
9272
9299
  function showGreeting() {
9273
9300
  let { npm_execpath, npm_lifecycle_event, NODE_RUN_SCRIPT_NAME } = process.env, isBun = npm_execpath?.includes('.bun');
9274
- src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.0.1\n`);
9301
+ src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.0.2\n`);
9275
9302
  }
9276
9303
  function setupLogLevel() {
9277
9304
  let logLevelIndex = process.argv.findIndex((item)=>'--log-level' === item || '--logLevel' === item);
@@ -9292,5 +9319,5 @@ function runCLI() {
9292
9319
  src_logger.error('Failed to start Rsbuild CLI.'), src_logger.error(err), process.exit(1);
9293
9320
  }
9294
9321
  }
9295
- let src_version = "2.0.1";
9322
+ let src_version = "2.0.2";
9296
9323
  export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, core_rspack as rspack, createRsbuild, defaultAllowedOrigins, defineConfig, ensureAssetPrefix, loadConfig_loadConfig as loadConfig, loadEnv, logger_createLogger as createLogger, mergeRsbuildConfig, runCLI, src_logger as logger, src_version as version };
@@ -0,0 +1,38 @@
1
+ import node_path from "node:path";
2
+ let CSS_MODULE_REGEX = /\.module\.\w+$/i, HASH_PLACEHOLDER_REGEX = /\[(?:[^:\]]+:)?(?:chunkhash|contenthash|hash|fullhash)(?::[^\]]+)?]/i, getRelativePath = (root, resourcePath)=>{
3
+ let relativePath = node_path.relative(root, resourcePath);
4
+ if (relativePath && !('..' === relativePath || relativePath.startsWith(`..${node_path.sep}`)) && !node_path.isAbsolute(relativePath)) return relativePath.replace(/\\/g, '/');
5
+ }, pitch = async function(remainingRequest) {
6
+ let root, resourcePath, nameSource, hash, options = this.getOptions();
7
+ if (((modules, resourcePath, resourceQuery, resourceFragment)=>{
8
+ if (!modules) return !1;
9
+ if (!0 === modules || 'string' == typeof modules) return !0;
10
+ let { auto } = modules;
11
+ return !1 !== auto && (auto instanceof RegExp ? auto.test(resourcePath) : 'function' == typeof auto ? auto(resourcePath, resourceQuery, resourceFragment) : CSS_MODULE_REGEX.test(resourcePath));
12
+ })(options.modules, this.resourcePath, this.resourceQuery, this.resourceFragment)) throw Error('[rsbuild:css] CSS Modules do not support the ?url query. Use ?inline to import the compiled CSS content as a string.');
13
+ let content = ((moduleExports)=>{
14
+ let content = moduleExports && 'object' == typeof moduleExports && 'default' in moduleExports ? moduleExports.default : moduleExports;
15
+ if ('string' != typeof content) throw Error('[rsbuild:css] Expected CSS ?url imports to export a string.');
16
+ return content;
17
+ })(await this.importModule(`!!${remainingRequest}`)), ext = node_path.extname(this.resourcePath), sourceFilename = node_path.relative(this.rootContext, this.resourcePath).replace(/\\/g, '/'), name = (root = this.rootContext, resourcePath = this.resourcePath, nameSource = getRelativePath(node_path.join(root, 'src'), resourcePath) ?? getRelativePath(root, resourcePath) ?? node_path.basename(resourcePath), ext ? nameSource.slice(0, -ext.length) : nameSource), contentHash = ((hash = this.utils.createHash(this._compilation.outputOptions.hashFunction)).update(Buffer.from(content)), hash.digest(this._compilation.outputOptions.hashDigest || 'hex')), pathData = {
18
+ contentHash,
19
+ chunk: {
20
+ name,
21
+ hash: contentHash,
22
+ contentHash: {
23
+ css: contentHash
24
+ }
25
+ }
26
+ }, assetInfo = {
27
+ sourceFilename
28
+ }, filenameTemplate = 'function' == typeof options.filename ? options.filename(pathData, assetInfo) : options.filename, { path: filename, info } = this._compilation.getAssetPathWithInfo(filenameTemplate, pathData);
29
+ return this.emitFile(filename, content, void 0, {
30
+ ...info,
31
+ ...assetInfo,
32
+ immutable: info.immutable || HASH_PLACEHOLDER_REGEX.test(filenameTemplate)
33
+ }), `export default __webpack_public_path__ + ${JSON.stringify(filename)};`;
34
+ };
35
+ export default function(source) {
36
+ return source;
37
+ };
38
+ export { pitch };
@@ -6,6 +6,7 @@ import { EventEmitter } from "node:events";
6
6
  import "node:net";
7
7
  import "node:stream";
8
8
  import { URL as external_node_url_URL } from "node:url";
9
+ import { URL as external_url_URL } from "url";
9
10
  import "node:zlib";
10
11
  import "node:querystring";
11
12
  import { __webpack_require__ } from "./1~rslib-runtime.js";
@@ -2657,6 +2658,10 @@ let errorResponsePlugin = (proxyServer, options)=>{
2657
2658
  warn: ()=>{},
2658
2659
  error: ()=>{}
2659
2660
  };
2661
+ function createUrl({ protocol, host, port, path }) {
2662
+ let ipv6Host = host?.includes(':') ? `[${host}]` : host, url = new external_url_URL(`${protocol || 'undefined:'}//${ipv6Host || '[::]'}`);
2663
+ return port && (url.port = port), path && (url.pathname = path), url;
2664
+ }
2660
2665
  function logger_plugin_getPort(sockets) {
2661
2666
  return Object.keys(sockets || {})?.[0]?.split(':')[1];
2662
2667
  }
@@ -2668,14 +2673,15 @@ let loggerPlugin = (proxyServer, options)=>{
2668
2673
  }), proxyServer.on('proxyRes', (proxyRes, req, res)=>{
2669
2674
  let target, originalUrl = req.originalUrl ?? `${req.baseUrl || ''}${req.url}`;
2670
2675
  try {
2671
- let port = logger_plugin_getPort(proxyRes.req?.agent?.sockets), obj = {
2672
- protocol: proxyRes.req.protocol,
2673
- host: proxyRes.req.host,
2674
- pathname: proxyRes.req.path
2675
- };
2676
- target = new external_node_url_URL(`${obj.protocol}//${obj.host}${obj.pathname}`), port && (target.port = port);
2676
+ let port = logger_plugin_getPort(proxyRes.req?.agent?.sockets), { protocol, host, path } = proxyRes.req;
2677
+ target = createUrl({
2678
+ protocol,
2679
+ host,
2680
+ port,
2681
+ path
2682
+ });
2677
2683
  } catch (err) {
2678
- (target = new external_node_url_URL(options.target)).pathname = proxyRes.req.path;
2684
+ console.error('[HPM] Unexpected error while creating target URL', err), (target = new external_node_url_URL(options.target)).pathname = proxyRes.req.path;
2679
2685
  }
2680
2686
  let targetUrl = target.toString(), exchange = `[HPM] ${req.method} ${originalUrl} -> ${targetUrl} [${proxyRes.statusCode}]`;
2681
2687
  logger.info(exchange);
@@ -2899,7 +2905,7 @@ class HttpProxyMiddleware {
2899
2905
  options.router && (newTarget = await getTarget(req, options)) && (Debug('router new target: "%s"', newTarget), options.target = newTarget);
2900
2906
  };
2901
2907
  applyPathRewrite = async (req, pathRewriter)=>{
2902
- if (pathRewriter) {
2908
+ if (req.url && pathRewriter) {
2903
2909
  let path = await pathRewriter(req.url, req);
2904
2910
  'string' == typeof path ? (Debug('pathRewrite new path: %s', path), req.url = path) : Debug('pathRewrite: no rewritten path found: %s', req.url);
2905
2911
  }
@@ -45,6 +45,7 @@ export declare const CHAIN_ID: {
45
45
  /** CSS oneOf rules */
46
46
  readonly CSS_MAIN: 'css';
47
47
  readonly CSS_RAW: 'css-raw';
48
+ readonly CSS_URL: 'css-url';
48
49
  readonly CSS_INLINE: 'css-inline';
49
50
  /** SVG oneOf rules */
50
51
  readonly SVG: 'svg';
@@ -60,6 +61,8 @@ export declare const CHAIN_ID: {
60
61
  readonly TS: 'ts';
61
62
  /** css-loader */
62
63
  readonly CSS: 'css';
64
+ /** CSS URL loader */
65
+ readonly CSS_URL: 'css-url';
63
66
  /** sass-loader */
64
67
  readonly SASS: 'sass';
65
68
  /** less-loader */
@@ -0,0 +1,9 @@
1
+ import type { AssetInfo, LoaderDefinitionFunction, PathData, PitchLoaderDefinitionFunction } from '@rspack/core';
2
+ import type { CSSLoaderOptions } from '../types';
3
+ type CSSUrlLoaderOptions = {
4
+ filename: string | ((pathData: PathData, assetInfo?: AssetInfo) => string);
5
+ modules: CSSLoaderOptions['modules'];
6
+ };
7
+ declare const cssUrlLoader: LoaderDefinitionFunction<CSSUrlLoaderOptions>;
8
+ export declare const pitch: PitchLoaderDefinitionFunction<CSSUrlLoaderOptions>;
9
+ export default cssUrlLoader;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/core",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "The Rspack-based build tool.",
5
5
  "homepage": "https://rsbuild.rs",
6
6
  "bugs": {
@@ -36,7 +36,7 @@
36
36
  "types.d.ts"
37
37
  ],
38
38
  "dependencies": {
39
- "@rspack/core": "^2.0.0",
39
+ "@rspack/core": "~2.0.0",
40
40
  "@swc/helpers": "^0.5.21"
41
41
  },
42
42
  "peerDependencies": {
@@ -65,7 +65,7 @@
65
65
  "deepmerge": "^4.3.1",
66
66
  "dotenv-expand": "13.0.0",
67
67
  "html-rspack-plugin": "6.1.8",
68
- "http-proxy-middleware": "4.0.0-beta.4",
68
+ "http-proxy-middleware": "4.0.0-beta.5",
69
69
  "jiti": "^2.6.1",
70
70
  "launch-editor-middleware": "^2.13.2",
71
71
  "memfs": "^4.57.2",
package/types.d.ts CHANGED
@@ -239,10 +239,13 @@ declare module '*.toml' {
239
239
 
240
240
  /**
241
241
  * Imports the file as a URL string.
242
- * @note Only works for static assets by default.
242
+ * @note Only works for static assets and CSS files by default.
243
243
  * @example
244
244
  * import logoUrl from './logo.png?url'
245
245
  * console.log(logoUrl) // 'http://example.com/logo.123456.png'
246
+ *
247
+ * import cssUrl from './style.css?url'
248
+ * console.log(cssUrl) // 'http://example.com/style.123456.css'
246
249
  */
247
250
  declare module '*?url' {
248
251
  const content: string;