@rsbuild/core 1.0.18 → 1.1.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,22 +1,22 @@
1
1
  (() => {
2
2
  var __webpack_modules__ = {
3
- 6754: (module, __unused_webpack_exports, __nccwpck_require__) => {
3
+ 9365: (module, __unused_webpack_exports, __nccwpck_require__) => {
4
4
  "use strict";
5
- const loader = __nccwpck_require__(7386);
5
+ const loader = __nccwpck_require__(8102);
6
6
  module.exports = loader.default;
7
7
  module.exports.defaultGetLocalIdent =
8
- __nccwpck_require__(3004).defaultGetLocalIdent;
8
+ __nccwpck_require__(4705).defaultGetLocalIdent;
9
9
  },
10
- 7386: (__unused_webpack_module, exports, __nccwpck_require__) => {
10
+ 8102: (__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__(9961));
15
15
  var _package = _interopRequireDefault(__nccwpck_require__(3360));
16
16
  var _semver = { satisfies: () => true };
17
- var _options = _interopRequireDefault(__nccwpck_require__(3087));
18
- var _plugins = __nccwpck_require__(4077);
19
- var _utils = __nccwpck_require__(3004);
17
+ var _options = _interopRequireDefault(__nccwpck_require__(3258));
18
+ var _plugins = __nccwpck_require__(2750);
19
+ var _utils = __nccwpck_require__(4705);
20
20
  function _interopRequireDefault(obj) {
21
21
  return obj && obj.__esModule ? obj : { default: obj };
22
22
  }
@@ -243,7 +243,7 @@
243
243
  callback(null, `${importCode}${moduleCode}${exportCode}`);
244
244
  }
245
245
  },
246
- 4077: (__unused_webpack_module, exports, __nccwpck_require__) => {
246
+ 2750: (__unused_webpack_module, exports, __nccwpck_require__) => {
247
247
  "use strict";
248
248
  Object.defineProperty(exports, "__esModule", { value: true });
249
249
  Object.defineProperty(exports, "icssParser", {
@@ -265,22 +265,22 @@
265
265
  },
266
266
  });
267
267
  var _postcssImportParser = _interopRequireDefault(
268
- __nccwpck_require__(1252),
268
+ __nccwpck_require__(7331),
269
269
  );
270
270
  var _postcssIcssParser = _interopRequireDefault(
271
- __nccwpck_require__(3170),
271
+ __nccwpck_require__(3922),
272
272
  );
273
- var _postcssUrlParser = _interopRequireDefault(__nccwpck_require__(4706));
273
+ var _postcssUrlParser = _interopRequireDefault(__nccwpck_require__(2767));
274
274
  function _interopRequireDefault(obj) {
275
275
  return obj && obj.__esModule ? obj : { default: obj };
276
276
  }
277
277
  },
278
- 3170: (__unused_webpack_module, exports, __nccwpck_require__) => {
278
+ 3922: (__unused_webpack_module, exports, __nccwpck_require__) => {
279
279
  "use strict";
280
280
  Object.defineProperty(exports, "__esModule", { value: true });
281
281
  exports["default"] = void 0;
282
282
  var _icssUtils = __nccwpck_require__(8406);
283
- var _utils = __nccwpck_require__(3004);
283
+ var _utils = __nccwpck_require__(4705);
284
284
  const plugin = (options = {}) => ({
285
285
  postcssPlugin: "postcss-icss-parser",
286
286
  async OnceExit(root) {
@@ -379,14 +379,14 @@
379
379
  plugin.postcss = true;
380
380
  var _default = (exports["default"] = plugin);
381
381
  },
382
- 1252: (__unused_webpack_module, exports, __nccwpck_require__) => {
382
+ 7331: (__unused_webpack_module, exports, __nccwpck_require__) => {
383
383
  "use strict";
384
384
  Object.defineProperty(exports, "__esModule", { value: true });
385
385
  exports["default"] = void 0;
386
386
  var _postcssValueParser = _interopRequireDefault(
387
387
  __nccwpck_require__(7555),
388
388
  );
389
- var _utils = __nccwpck_require__(3004);
389
+ var _utils = __nccwpck_require__(4705);
390
390
  function _interopRequireDefault(obj) {
391
391
  return obj && obj.__esModule ? obj : { default: obj };
392
392
  }
@@ -691,14 +691,14 @@
691
691
  plugin.postcss = true;
692
692
  var _default = (exports["default"] = plugin);
693
693
  },
694
- 4706: (__unused_webpack_module, exports, __nccwpck_require__) => {
694
+ 2767: (__unused_webpack_module, exports, __nccwpck_require__) => {
695
695
  "use strict";
696
696
  Object.defineProperty(exports, "__esModule", { value: true });
697
697
  exports["default"] = void 0;
698
698
  var _postcssValueParser = _interopRequireDefault(
699
699
  __nccwpck_require__(7555),
700
700
  );
701
- var _utils = __nccwpck_require__(3004);
701
+ var _utils = __nccwpck_require__(4705);
702
702
  function _interopRequireDefault(obj) {
703
703
  return obj && obj.__esModule ? obj : { default: obj };
704
704
  }
@@ -1041,7 +1041,7 @@
1041
1041
  plugin.postcss = true;
1042
1042
  var _default = (exports["default"] = plugin);
1043
1043
  },
1044
- 3004: (__unused_webpack_module, exports, __nccwpck_require__) => {
1044
+ 4705: (__unused_webpack_module, exports, __nccwpck_require__) => {
1045
1045
  "use strict";
1046
1046
  Object.defineProperty(exports, "__esModule", { value: true });
1047
1047
  exports.WEBPACK_IGNORE_COMMENT_REGEXP = void 0;
@@ -7960,7 +7960,7 @@
7960
7960
  "use strict";
7961
7961
  module.exports = require("util");
7962
7962
  },
7963
- 3087: (module) => {
7963
+ 3258: (module) => {
7964
7964
  "use strict";
7965
7965
  module.exports = JSON.parse(
7966
7966
  '{"title":"CSS Loader options","additionalProperties":false,"properties":{"url":{"description":"Allows to enables/disables `url()`/`image-set()` functions handling.","link":"https://github.com/webpack-contrib/css-loader#url","anyOf":[{"type":"boolean"},{"type":"object","properties":{"filter":{"instanceof":"Function"}},"additionalProperties":false}]},"import":{"description":"Allows to enables/disables `@import` at-rules handling.","link":"https://github.com/webpack-contrib/css-loader#import","anyOf":[{"type":"boolean"},{"type":"object","properties":{"filter":{"instanceof":"Function"}},"additionalProperties":false}]},"modules":{"description":"Allows to enable/disable CSS Modules or ICSS and setup configuration.","link":"https://github.com/webpack-contrib/css-loader#modules","anyOf":[{"type":"boolean"},{"enum":["local","global","pure","icss"]},{"type":"object","additionalProperties":false,"properties":{"auto":{"description":"Allows auto enable CSS modules based on filename.","link":"https://github.com/webpack-contrib/css-loader#auto","anyOf":[{"instanceof":"RegExp"},{"instanceof":"Function"},{"type":"boolean"}]},"mode":{"description":"Setup `mode` option.","link":"https://github.com/webpack-contrib/css-loader#mode","anyOf":[{"enum":["local","global","pure","icss"]},{"instanceof":"Function"}]},"localIdentName":{"description":"Allows to configure the generated local ident name.","link":"https://github.com/webpack-contrib/css-loader#localidentname","type":"string","minLength":1},"localIdentContext":{"description":"Allows to redefine basic loader context for local ident name.","link":"https://github.com/webpack-contrib/css-loader#localidentcontext","type":"string","minLength":1},"localIdentHashSalt":{"description":"Allows to add custom hash to generate more unique classes.","link":"https://github.com/webpack-contrib/css-loader#localidenthashsalt","type":"string","minLength":1},"localIdentHashFunction":{"description":"Allows to specify hash function to generate classes.","link":"https://github.com/webpack-contrib/css-loader#localidenthashfunction","type":"string","minLength":1},"localIdentHashDigest":{"description":"Allows to specify hash digest to generate classes.","link":"https://github.com/webpack-contrib/css-loader#localidenthashdigest","type":"string","minLength":1},"localIdentHashDigestLength":{"description":"Allows to specify hash digest length to generate classes.","link":"https://github.com/webpack-contrib/css-loader#localidenthashdigestlength","type":"number"},"hashStrategy":{"description":"Allows to specify should localName be used when computing the hash.","link":"https://github.com/webpack-contrib/css-loader#hashstrategy","enum":["resource-path-and-local-name","minimal-subset"]},"localIdentRegExp":{"description":"Allows to specify custom RegExp for local ident name.","link":"https://github.com/webpack-contrib/css-loader#localidentregexp","anyOf":[{"type":"string","minLength":1},{"instanceof":"RegExp"}]},"getLocalIdent":{"description":"Allows to specify a function to generate the classname.","link":"https://github.com/webpack-contrib/css-loader#getlocalident","instanceof":"Function"},"namedExport":{"description":"Enables/disables ES modules named export for locals.","link":"https://github.com/webpack-contrib/css-loader#namedexport","type":"boolean"},"exportGlobals":{"description":"Allows to export names from global class or id, so you can use that as local name.","link":"https://github.com/webpack-contrib/css-loader#exportglobals","type":"boolean"},"exportLocalsConvention":{"description":"Style of exported classnames.","link":"https://github.com/webpack-contrib/css-loader#localsconvention","anyOf":[{"enum":["asIs","as-is","camelCase","camel-case","camelCaseOnly","camel-case-only","dashes","dashesOnly","dashes-only"]},{"instanceof":"Function"}]},"exportOnlyLocals":{"description":"Export only locals.","link":"https://github.com/webpack-contrib/css-loader#exportonlylocals","type":"boolean"},"getJSON":{"description":"Allows outputting of CSS modules mapping through a callback.","link":"https://github.com/webpack-contrib/css-loader#getJSON","instanceof":"Function"}}}]},"sourceMap":{"description":"Allows to enable/disable source maps.","link":"https://github.com/webpack-contrib/css-loader#sourcemap","type":"boolean"},"importLoaders":{"description":"Allows enables/disables or setups number of loaders applied before CSS loader for `@import`/CSS Modules and ICSS imports.","link":"https://github.com/webpack-contrib/css-loader#importloaders","anyOf":[{"type":"boolean"},{"type":"string"},{"type":"integer"}]},"esModule":{"description":"Use the ES modules syntax.","link":"https://github.com/webpack-contrib/css-loader#esmodule","type":"boolean"},"exportType":{"description":"Allows exporting styles as array with modules, string or constructable stylesheet (i.e. `CSSStyleSheet`).","link":"https://github.com/webpack-contrib/css-loader#exporttype","enum":["array","string","css-style-sheet"]}},"type":"object"}',
@@ -7995,6 +7995,6 @@
7995
7995
  }
7996
7996
  if (typeof __nccwpck_require__ !== "undefined")
7997
7997
  __nccwpck_require__.ab = __dirname + "/";
7998
- var __webpack_exports__ = __nccwpck_require__(6754);
7998
+ var __webpack_exports__ = __nccwpck_require__(9365);
7999
7999
  module.exports = __webpack_exports__;
8000
8000
  })();
@@ -1,8 +1,8 @@
1
1
  (() => {
2
2
  var __webpack_modules__ = {
3
- 909: (module, __unused_webpack_exports, __nccwpck_require__) => {
3
+ 261: (module, __unused_webpack_exports, __nccwpck_require__) => {
4
4
  "use strict";
5
- const { HtmlWebpackChildCompiler } = __nccwpck_require__(903);
5
+ const { HtmlWebpackChildCompiler } = __nccwpck_require__(117);
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
- 903: (module) => {
307
+ 117: (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
- 78: (module) => {
476
+ 673: (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
- 422: (module) => {
495
+ 740: (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
- 9: (module, __unused_webpack_exports, __nccwpck_require__) => {
516
+ 865: (module, __unused_webpack_exports, __nccwpck_require__) => {
517
517
  "use strict";
518
518
  const { AsyncSeriesWaterfallHook } = __nccwpck_require__(348);
519
519
  const htmlWebpackPluginHooksMap = new WeakMap();
@@ -539,7 +539,7 @@
539
539
  }
540
540
  module.exports = { getHtmlRspackPluginHooks };
541
541
  },
542
- 301: (module) => {
542
+ 154: (module) => {
543
543
  const voidTags = [
544
544
  "area",
545
545
  "base",
@@ -607,19 +607,19 @@
607
607
  htmlTagObjectToString,
608
608
  };
609
609
  },
610
- 541: (module, __unused_webpack_exports, __nccwpck_require__) => {
610
+ 761: (module, __unused_webpack_exports, __nccwpck_require__) => {
611
611
  "use strict";
612
612
  const promisify = __nccwpck_require__(837).promisify;
613
613
  const vm = __nccwpck_require__(144);
614
614
  const fs = __nccwpck_require__(147);
615
615
  const path = __nccwpck_require__(17);
616
- const { CachedChildCompilation } = __nccwpck_require__(909);
616
+ const { CachedChildCompilation } = __nccwpck_require__(261);
617
617
  const { createHtmlTagObject, htmlTagObjectToString, HtmlTagArray } =
618
- __nccwpck_require__(301);
619
- const prettyError = __nccwpck_require__(422);
620
- const chunkSorter = __nccwpck_require__(78);
618
+ __nccwpck_require__(154);
619
+ const prettyError = __nccwpck_require__(740);
620
+ const chunkSorter = __nccwpck_require__(673);
621
621
  const getHtmlRspackPluginHooks =
622
- __nccwpck_require__(9).getHtmlRspackPluginHooks;
622
+ __nccwpck_require__(865).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__(541);
1581
+ var __webpack_exports__ = __nccwpck_require__(761);
1582
1582
  module.exports = __webpack_exports__;
1583
1583
  })();
@@ -1,17 +1,17 @@
1
1
  (() => {
2
2
  "use strict";
3
3
  var __webpack_modules__ = {
4
- 777: (module, __unused_webpack_exports, __nccwpck_require__) => {
5
- module.exports = __nccwpck_require__(779)["default"];
4
+ 254: (module, __unused_webpack_exports, __nccwpck_require__) => {
5
+ module.exports = __nccwpck_require__(44)["default"];
6
6
  },
7
- 779: (__unused_webpack_module, exports, __nccwpck_require__) => {
7
+ 44: (__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__(17));
12
12
  var _package = _interopRequireDefault(__nccwpck_require__(360));
13
- var _options = _interopRequireDefault(__nccwpck_require__(723));
14
- var _utils = __nccwpck_require__(974);
13
+ var _options = _interopRequireDefault(__nccwpck_require__(573));
14
+ var _utils = __nccwpck_require__(226);
15
15
  function _interopRequireDefault(obj) {
16
16
  return obj && obj.__esModule ? obj : { default: obj };
17
17
  }
@@ -189,7 +189,7 @@
189
189
  callback(null, result.css, map, { ast });
190
190
  }
191
191
  },
192
- 974: (module, exports, __nccwpck_require__) => {
192
+ 226: (module, exports, __nccwpck_require__) => {
193
193
  module = __nccwpck_require__.nmd(module);
194
194
  Object.defineProperty(exports, "__esModule", { value: true });
195
195
  exports.exec = exec;
@@ -691,7 +691,7 @@
691
691
  310: (module) => {
692
692
  module.exports = require("url");
693
693
  },
694
- 723: (module) => {
694
+ 573: (module) => {
695
695
  module.exports = JSON.parse(
696
696
  '{"title":"PostCSS Loader options","type":"object","properties":{"postcssOptions":{"description":"Options to pass through to `Postcss`.","link":"https://github.com/webpack-contrib/postcss-loader#postcssOptions","anyOf":[{"type":"object","additionalProperties":true,"properties":{"config":{"description":"Allows to specify PostCSS config path.","link":"https://github.com/webpack-contrib/postcss-loader#config","anyOf":[{"description":"Allows to specify the path to the configuration file","type":"string"},{"description":"Enables/Disables autoloading config","type":"boolean"}]}}},{"instanceof":"Function"}]},"execute":{"description":"Enables/Disables PostCSS parser support in \'CSS-in-JS\'.","link":"https://github.com/webpack-contrib/postcss-loader#execute","type":"boolean"},"sourceMap":{"description":"Enables/Disables generation of source maps.","link":"https://github.com/webpack-contrib/postcss-loader#sourcemap","type":"boolean"},"implementation":{"description":"The implementation of postcss to use, instead of the locally installed version","link":"https://github.com/webpack-contrib/postcss-loader#implementation","anyOf":[{"type":"string"},{"instanceof":"Function"}]}},"additionalProperties":false}',
697
697
  );
@@ -736,6 +736,6 @@
736
736
  })();
737
737
  if (typeof __nccwpck_require__ !== "undefined")
738
738
  __nccwpck_require__.ab = __dirname + "/";
739
- var __webpack_exports__ = __nccwpck_require__(777);
739
+ var __webpack_exports__ = __nccwpck_require__(254);
740
740
  module.exports = __webpack_exports__;
741
741
  })();
@@ -1,7 +1,7 @@
1
1
  (() => {
2
2
  "use strict";
3
3
  var __webpack_modules__ = {
4
- 248: (__unused_webpack_module, exports, __nccwpck_require__) => {
4
+ 19: (__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
- 458: (__unused_webpack_module, exports, __nccwpck_require__) => {
123
+ 843: (__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__(147);
131
131
  const path_1 = __nccwpck_require__(17);
132
132
  const lite_tapable_1 = __nccwpck_require__(348);
133
- const helpers_1 = __nccwpck_require__(248);
133
+ const helpers_1 = __nccwpck_require__(19);
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__(17);
315
- const hooks_1 = __nccwpck_require__(458);
315
+ const hooks_1 = __nccwpck_require__(843);
316
316
  Object.defineProperty(exports, "getCompilerHooks", {
317
317
  enumerable: true,
318
318
  get: function () {
package/dist/index.cjs CHANGED
@@ -6029,7 +6029,7 @@ async function createContext(options, userConfig, bundlerType) {
6029
6029
  const rsbuildConfig = await withDefaultConfig(rootPath, userConfig);
6030
6030
  const cachePath = (0, import_node_path10.join)(rootPath, "node_modules", ".cache");
6031
6031
  return {
6032
- version: "1.0.18",
6032
+ version: "1.1.0-beta.0",
6033
6033
  rootPath,
6034
6034
  distPath: "",
6035
6035
  cachePath,
@@ -7161,7 +7161,8 @@ var init_cjs = __esm({
7161
7161
  timeout.unref();
7162
7162
  return timeout;
7163
7163
  },
7164
- clearTimeout
7164
+ clearTimeout,
7165
+ queueMicrotask
7165
7166
  };
7166
7167
  }
7167
7168
  createBaseModuleScope() {
@@ -7174,7 +7175,8 @@ var init_cjs = __esm({
7174
7175
  value: "Module"
7175
7176
  });
7176
7177
  return m;
7177
- }
7178
+ },
7179
+ queueMicrotask
7178
7180
  };
7179
7181
  return baseModuleScope;
7180
7182
  }
@@ -9636,7 +9638,7 @@ async function applyCSSRule({
9636
9638
  config,
9637
9639
  root: context.rootPath
9638
9640
  });
9639
- if (postcssLoaderOptions.postcssOptions?.plugins?.length) {
9641
+ if (typeof postcssLoaderOptions.postcssOptions === "function" || postcssLoaderOptions.postcssOptions?.plugins?.length) {
9640
9642
  importLoaders++;
9641
9643
  rule.use(CHAIN_ID2.USE.POSTCSS).loader(getCompiledPath("postcss-loader")).options(postcssLoaderOptions);
9642
9644
  }
@@ -9660,6 +9662,7 @@ var init_css = __esm({
9660
9662
  import_deepmerge2 = __toESM(require_cjs());
9661
9663
  init_dist2();
9662
9664
  init_constants();
9665
+ init_helpers();
9663
9666
  init_path();
9664
9667
  init_pluginHelper();
9665
9668
  isUseCssExtract = (config, target) => !config.output.injectStyles && target !== "node" && target !== "web-worker";
@@ -9701,35 +9704,57 @@ var init_css = __esm({
9701
9704
  const extraPlugins = [];
9702
9705
  const utils = {
9703
9706
  addPlugins(plugins) {
9704
- if (Array.isArray(plugins)) {
9705
- extraPlugins.push(...plugins);
9706
- } else {
9707
- extraPlugins.push(plugins);
9708
- }
9707
+ extraPlugins.push(...castArray(plugins));
9709
9708
  }
9710
9709
  };
9711
- const userPostcssConfig = await loadUserPostcssrc(root);
9712
- userPostcssConfig.plugins ||= [];
9713
- const defaultPostcssConfig = {
9710
+ const userOptions = await loadUserPostcssrc(root);
9711
+ userOptions.plugins ||= [];
9712
+ const defaultOptions2 = {
9714
9713
  implementation: getCompiledPath("postcss"),
9715
- postcssOptions: userPostcssConfig,
9714
+ postcssOptions: userOptions,
9716
9715
  sourceMap: config.output.sourceMap.css
9717
9716
  };
9718
- const merged = reduceConfigsWithContext({
9719
- initial: defaultPostcssConfig,
9717
+ const finalOptions = reduceConfigsWithContext({
9718
+ initial: defaultOptions2,
9720
9719
  config: config.tools.postcss,
9721
9720
  ctx: utils
9722
9721
  });
9723
- merged.postcssOptions ||= {};
9724
- merged.postcssOptions.plugins ||= [];
9725
- if (extraPlugins.length) {
9726
- merged.postcssOptions.plugins.push(...extraPlugins);
9722
+ finalOptions.postcssOptions ||= {};
9723
+ const updatePostcssOptions = (options) => {
9724
+ options.plugins ||= [];
9725
+ if (extraPlugins.length) {
9726
+ options.plugins.push(...extraPlugins);
9727
+ }
9728
+ options.plugins = options.plugins.map(
9729
+ (plugin) => isPostcssPluginCreator(plugin) ? plugin() : plugin
9730
+ );
9731
+ options.config = false;
9732
+ return options;
9733
+ };
9734
+ const { postcssOptions } = finalOptions;
9735
+ if (typeof postcssOptions === "function") {
9736
+ const postcssOptionsWrapper = (loaderContext) => {
9737
+ const options = postcssOptions(loaderContext);
9738
+ if (typeof options !== "object" || options === null) {
9739
+ throw new Error(
9740
+ `\`postcssOptions\` function must return a PostCSSOptions object, got "${typeof options}".`
9741
+ );
9742
+ }
9743
+ const mergedOptions = {
9744
+ ...userOptions,
9745
+ ...options,
9746
+ plugins: [...userOptions.plugins || [], ...options.plugins || []]
9747
+ };
9748
+ return updatePostcssOptions(mergedOptions);
9749
+ };
9750
+ postcssOptionsWrapper.config = false;
9751
+ return {
9752
+ ...finalOptions,
9753
+ postcssOptions: postcssOptionsWrapper
9754
+ };
9727
9755
  }
9728
- merged.postcssOptions.plugins = merged.postcssOptions.plugins.map(
9729
- (plugin) => isPostcssPluginCreator(plugin) ? plugin() : plugin
9730
- );
9731
- merged.postcssOptions.config = false;
9732
- return merged;
9756
+ finalOptions.postcssOptions = updatePostcssOptions(postcssOptions);
9757
+ return finalOptions;
9733
9758
  };
9734
9759
  getCSSLoaderOptions = ({
9735
9760
  config,
@@ -11371,7 +11396,11 @@ function getDefaultSwcConfig(browserslist, cacheRoot) {
11371
11396
  decorators: true
11372
11397
  },
11373
11398
  experimental: {
11374
- cacheRoot
11399
+ cacheRoot,
11400
+ /**
11401
+ * Preserve `with` in imports and exports.
11402
+ */
11403
+ keepImportAttributes: true
11375
11404
  }
11376
11405
  },
11377
11406
  isModule: "unknown",
@@ -12892,7 +12921,7 @@ var sri_exports = {};
12892
12921
  __export(sri_exports, {
12893
12922
  pluginSri: () => pluginSri
12894
12923
  });
12895
- var import_node_crypto2, getAssetName, pluginSri;
12924
+ var import_node_crypto2, getAssetName, isSriLinkRel, pluginSri;
12896
12925
  var init_sri = __esm({
12897
12926
  "src/plugins/sri.ts"() {
12898
12927
  "use strict";
@@ -12906,6 +12935,9 @@ var init_sri = __esm({
12906
12935
  }
12907
12936
  return removeLeadingSlash(url2);
12908
12937
  };
12938
+ isSriLinkRel = (rel) => {
12939
+ return typeof rel === "string" && ["stylesheet", "preload", "modulepreload"].includes(rel);
12940
+ };
12909
12941
  pluginSri = () => ({
12910
12942
  name: "rsbuild:sri",
12911
12943
  setup(api) {
@@ -12936,7 +12968,7 @@ var init_sri = __esm({
12936
12968
  }
12937
12969
  if (tag.tag === "script" && typeof tag.attrs.src === "string") {
12938
12970
  url2 = tag.attrs.src;
12939
- } else if (tag.tag === "link" && tag.attrs.rel === "stylesheet" && typeof tag.attrs.href === "string") {
12971
+ } else if (tag.tag === "link" && isSriLinkRel(tag.attrs.rel) && typeof tag.attrs.href === "string") {
12940
12972
  url2 = tag.attrs.href;
12941
12973
  }
12942
12974
  if (!url2) {
@@ -13610,7 +13642,7 @@ var init_init = __esm({
13610
13642
 
13611
13643
  // src/cli/commands.ts
13612
13644
  function runCli() {
13613
- program.name("rsbuild").usage("<command> [options]").version("1.0.18");
13645
+ program.name("rsbuild").usage("<command> [options]").version("1.1.0-beta.0");
13614
13646
  const devCommand = program.command("dev");
13615
13647
  const buildCommand = program.command("build");
13616
13648
  const previewCommand = program.command("preview");
@@ -13719,7 +13751,7 @@ function prepareCli() {
13719
13751
  if (!npm_execpath || npm_execpath.includes("npx-cli.js") || npm_execpath.includes(".bun")) {
13720
13752
  console.log();
13721
13753
  }
13722
- import_rslog.logger.greet(` ${`Rsbuild v${"1.0.18"}`}
13754
+ import_rslog.logger.greet(` ${`Rsbuild v${"1.1.0-beta.0"}`}
13723
13755
  `);
13724
13756
  }
13725
13757
  var import_node_module;
@@ -13806,7 +13838,7 @@ init_logger();
13806
13838
  init_mergeConfig();
13807
13839
  init_helpers();
13808
13840
  init_constants();
13809
- var version = "1.0.18";
13841
+ var version = "1.1.0-beta.0";
13810
13842
  // Annotate the CommonJS export names for ESM import in node:
13811
13843
  0 && (module.exports = {
13812
13844
  PLUGIN_CSS_NAME,
package/dist/index.js CHANGED
@@ -46,12 +46,12 @@ var __publicField = (obj, key, value) => {
46
46
  return value;
47
47
  };
48
48
 
49
- // ../../node_modules/.pnpm/@modern-js+module-tools@2.60.4_typescript@5.6.3/node_modules/@modern-js/module-tools/shims/esm.js
49
+ // ../../node_modules/.pnpm/@modern-js+module-tools@2.60.5_typescript@5.6.3/node_modules/@modern-js/module-tools/shims/esm.js
50
50
  import path from "path";
51
51
  import { fileURLToPath } from "url";
52
52
  var getFilename, getDirname, __dirname, __filename;
53
53
  var init_esm = __esm({
54
- "../../node_modules/.pnpm/@modern-js+module-tools@2.60.4_typescript@5.6.3/node_modules/@modern-js/module-tools/shims/esm.js"() {
54
+ "../../node_modules/.pnpm/@modern-js+module-tools@2.60.5_typescript@5.6.3/node_modules/@modern-js/module-tools/shims/esm.js"() {
55
55
  "use strict";
56
56
  getFilename = () => fileURLToPath(import.meta.url);
57
57
  getDirname = () => path.dirname(getFilename());
@@ -6078,7 +6078,7 @@ async function createContext(options, userConfig, bundlerType) {
6078
6078
  const rsbuildConfig = await withDefaultConfig(rootPath, userConfig);
6079
6079
  const cachePath = join6(rootPath, "node_modules", ".cache");
6080
6080
  return {
6081
- version: "1.0.18",
6081
+ version: "1.1.0-beta.0",
6082
6082
  rootPath,
6083
6083
  distPath: "",
6084
6084
  cachePath,
@@ -7219,7 +7219,8 @@ var init_cjs = __esm({
7219
7219
  timeout.unref();
7220
7220
  return timeout;
7221
7221
  },
7222
- clearTimeout
7222
+ clearTimeout,
7223
+ queueMicrotask
7223
7224
  };
7224
7225
  }
7225
7226
  createBaseModuleScope() {
@@ -7232,7 +7233,8 @@ var init_cjs = __esm({
7232
7233
  value: "Module"
7233
7234
  });
7234
7235
  return m;
7235
- }
7236
+ },
7237
+ queueMicrotask
7236
7238
  };
7237
7239
  return baseModuleScope;
7238
7240
  }
@@ -9717,7 +9719,7 @@ async function applyCSSRule({
9717
9719
  config,
9718
9720
  root: context.rootPath
9719
9721
  });
9720
- if (postcssLoaderOptions.postcssOptions?.plugins?.length) {
9722
+ if (typeof postcssLoaderOptions.postcssOptions === "function" || postcssLoaderOptions.postcssOptions?.plugins?.length) {
9721
9723
  importLoaders++;
9722
9724
  rule.use(CHAIN_ID2.USE.POSTCSS).loader(getCompiledPath("postcss-loader")).options(postcssLoaderOptions);
9723
9725
  }
@@ -9741,6 +9743,7 @@ var init_css = __esm({
9741
9743
  import_deepmerge2 = __toESM(require_cjs());
9742
9744
  init_dist2();
9743
9745
  init_constants();
9746
+ init_helpers();
9744
9747
  init_path();
9745
9748
  init_pluginHelper();
9746
9749
  isUseCssExtract = (config, target) => !config.output.injectStyles && target !== "node" && target !== "web-worker";
@@ -9782,35 +9785,57 @@ var init_css = __esm({
9782
9785
  const extraPlugins = [];
9783
9786
  const utils = {
9784
9787
  addPlugins(plugins) {
9785
- if (Array.isArray(plugins)) {
9786
- extraPlugins.push(...plugins);
9787
- } else {
9788
- extraPlugins.push(plugins);
9789
- }
9788
+ extraPlugins.push(...castArray(plugins));
9790
9789
  }
9791
9790
  };
9792
- const userPostcssConfig = await loadUserPostcssrc(root);
9793
- userPostcssConfig.plugins ||= [];
9794
- const defaultPostcssConfig = {
9791
+ const userOptions = await loadUserPostcssrc(root);
9792
+ userOptions.plugins ||= [];
9793
+ const defaultOptions2 = {
9795
9794
  implementation: getCompiledPath("postcss"),
9796
- postcssOptions: userPostcssConfig,
9795
+ postcssOptions: userOptions,
9797
9796
  sourceMap: config.output.sourceMap.css
9798
9797
  };
9799
- const merged = reduceConfigsWithContext({
9800
- initial: defaultPostcssConfig,
9798
+ const finalOptions = reduceConfigsWithContext({
9799
+ initial: defaultOptions2,
9801
9800
  config: config.tools.postcss,
9802
9801
  ctx: utils
9803
9802
  });
9804
- merged.postcssOptions ||= {};
9805
- merged.postcssOptions.plugins ||= [];
9806
- if (extraPlugins.length) {
9807
- merged.postcssOptions.plugins.push(...extraPlugins);
9803
+ finalOptions.postcssOptions ||= {};
9804
+ const updatePostcssOptions = (options) => {
9805
+ options.plugins ||= [];
9806
+ if (extraPlugins.length) {
9807
+ options.plugins.push(...extraPlugins);
9808
+ }
9809
+ options.plugins = options.plugins.map(
9810
+ (plugin) => isPostcssPluginCreator(plugin) ? plugin() : plugin
9811
+ );
9812
+ options.config = false;
9813
+ return options;
9814
+ };
9815
+ const { postcssOptions } = finalOptions;
9816
+ if (typeof postcssOptions === "function") {
9817
+ const postcssOptionsWrapper = (loaderContext) => {
9818
+ const options = postcssOptions(loaderContext);
9819
+ if (typeof options !== "object" || options === null) {
9820
+ throw new Error(
9821
+ `\`postcssOptions\` function must return a PostCSSOptions object, got "${typeof options}".`
9822
+ );
9823
+ }
9824
+ const mergedOptions = {
9825
+ ...userOptions,
9826
+ ...options,
9827
+ plugins: [...userOptions.plugins || [], ...options.plugins || []]
9828
+ };
9829
+ return updatePostcssOptions(mergedOptions);
9830
+ };
9831
+ postcssOptionsWrapper.config = false;
9832
+ return {
9833
+ ...finalOptions,
9834
+ postcssOptions: postcssOptionsWrapper
9835
+ };
9808
9836
  }
9809
- merged.postcssOptions.plugins = merged.postcssOptions.plugins.map(
9810
- (plugin) => isPostcssPluginCreator(plugin) ? plugin() : plugin
9811
- );
9812
- merged.postcssOptions.config = false;
9813
- return merged;
9837
+ finalOptions.postcssOptions = updatePostcssOptions(postcssOptions);
9838
+ return finalOptions;
9814
9839
  };
9815
9840
  getCSSLoaderOptions = ({
9816
9841
  config,
@@ -11468,7 +11493,11 @@ function getDefaultSwcConfig(browserslist, cacheRoot) {
11468
11493
  decorators: true
11469
11494
  },
11470
11495
  experimental: {
11471
- cacheRoot
11496
+ cacheRoot,
11497
+ /**
11498
+ * Preserve `with` in imports and exports.
11499
+ */
11500
+ keepImportAttributes: true
11472
11501
  }
11473
11502
  },
11474
11503
  isModule: "unknown",
@@ -13006,7 +13035,7 @@ __export(sri_exports, {
13006
13035
  pluginSri: () => pluginSri
13007
13036
  });
13008
13037
  import crypto2 from "crypto";
13009
- var getAssetName, pluginSri;
13038
+ var getAssetName, isSriLinkRel, pluginSri;
13010
13039
  var init_sri = __esm({
13011
13040
  "src/plugins/sri.ts"() {
13012
13041
  "use strict";
@@ -13020,6 +13049,9 @@ var init_sri = __esm({
13020
13049
  }
13021
13050
  return removeLeadingSlash(url2);
13022
13051
  };
13052
+ isSriLinkRel = (rel) => {
13053
+ return typeof rel === "string" && ["stylesheet", "preload", "modulepreload"].includes(rel);
13054
+ };
13023
13055
  pluginSri = () => ({
13024
13056
  name: "rsbuild:sri",
13025
13057
  setup(api) {
@@ -13050,7 +13082,7 @@ var init_sri = __esm({
13050
13082
  }
13051
13083
  if (tag.tag === "script" && typeof tag.attrs.src === "string") {
13052
13084
  url2 = tag.attrs.src;
13053
- } else if (tag.tag === "link" && tag.attrs.rel === "stylesheet" && typeof tag.attrs.href === "string") {
13085
+ } else if (tag.tag === "link" && isSriLinkRel(tag.attrs.rel) && typeof tag.attrs.href === "string") {
13054
13086
  url2 = tag.attrs.href;
13055
13087
  }
13056
13088
  if (!url2) {
@@ -13728,7 +13760,7 @@ var init_init = __esm({
13728
13760
 
13729
13761
  // src/cli/commands.ts
13730
13762
  function runCli() {
13731
- program.name("rsbuild").usage("<command> [options]").version("1.0.18");
13763
+ program.name("rsbuild").usage("<command> [options]").version("1.1.0-beta.0");
13732
13764
  const devCommand = program.command("dev");
13733
13765
  const buildCommand = program.command("build");
13734
13766
  const previewCommand = program.command("preview");
@@ -13839,7 +13871,7 @@ function prepareCli() {
13839
13871
  if (!npm_execpath || npm_execpath.includes("npx-cli.js") || npm_execpath.includes(".bun")) {
13840
13872
  console.log();
13841
13873
  }
13842
- logger.greet(` ${`Rsbuild v${"1.0.18"}`}
13874
+ logger.greet(` ${`Rsbuild v${"1.1.0-beta.0"}`}
13843
13875
  `);
13844
13876
  }
13845
13877
  var init_prepare = __esm({
@@ -13911,7 +13943,7 @@ init_mergeConfig();
13911
13943
  init_helpers();
13912
13944
  init_constants();
13913
13945
  import { rspack as rspack10 } from "@rspack/core";
13914
- var version = "1.0.18";
13946
+ var version = "1.1.0-beta.0";
13915
13947
  export {
13916
13948
  PLUGIN_CSS_NAME,
13917
13949
  PLUGIN_SWC_NAME,
@@ -16,20 +16,24 @@ export type PostCSSOptions = ProcessOptions & {
16
16
  export type PostCSSLoaderOptions = {
17
17
  /**
18
18
  * Enable PostCSS Parser support in CSS-in-JS. If you use JS styles the postcss-js parser, add the execute option.
19
+ * @default undefined
19
20
  */
20
21
  execute?: boolean;
21
22
  /**
22
- * By default generation of source maps depends on the devtool option. All values enable source map generation except eval and false value.
23
+ * Whether to generate source maps.
24
+ * @default `rsbuildConfig.output.sourceMap.css`
23
25
  */
24
26
  sourceMap?: boolean;
25
27
  /**
26
28
  * The special implementation option determines which implementation of PostCSS to use.
29
+ * @default `@rsbuild/core/compiled/postcss`
27
30
  */
28
31
  implementation?: unknown;
29
32
  /**
30
33
  * Allows to set PostCSS options and plugins.
34
+ * @default undefined
31
35
  */
32
- postcssOptions?: PostCSSOptions;
36
+ postcssOptions?: PostCSSOptions | ((loaderContext: Rspack.LoaderContext) => PostCSSOptions);
33
37
  };
34
38
  export type { AcceptedPlugin as PostCSSPlugin } from 'postcss';
35
39
  export type CSSLoaderModulesMode = 'local' | 'global' | 'pure' | 'icss' | ((resourcePath: string) => 'local' | 'global' | 'pure' | 'icss');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/core",
3
- "version": "1.0.18",
3
+ "version": "1.1.0-beta.0",
4
4
  "description": "The Rspack-based build tool.",
5
5
  "homepage": "https://rsbuild.dev",
6
6
  "bugs": {
@@ -46,7 +46,7 @@
46
46
  "types.d.ts"
47
47
  ],
48
48
  "dependencies": {
49
- "@rspack/core": "~1.0.14",
49
+ "@rspack/core": "~1.1.0-beta.0",
50
50
  "@rspack/lite-tapable": "~1.0.1",
51
51
  "@swc/helpers": "^0.5.13",
52
52
  "core-js": "~3.38.1"