@rsbuild/core 0.7.1 → 0.7.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,19 +1,19 @@
1
1
  /******/ (() => { // webpackBootstrap
2
2
  /******/ var __webpack_modules__ = ({
3
3
 
4
- /***/ 9106:
4
+ /***/ 6329:
5
5
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
6
6
 
7
7
  "use strict";
8
8
 
9
9
 
10
- const loader = __nccwpck_require__(1922);
10
+ const loader = __nccwpck_require__(98);
11
11
  module.exports = loader.default;
12
- module.exports.defaultGetLocalIdent = __nccwpck_require__(3012).defaultGetLocalIdent;
12
+ module.exports.defaultGetLocalIdent = __nccwpck_require__(6894).defaultGetLocalIdent;
13
13
 
14
14
  /***/ }),
15
15
 
16
- /***/ 1922:
16
+ /***/ 98:
17
17
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
18
18
 
19
19
  "use strict";
@@ -26,9 +26,9 @@ exports["default"] = loader;
26
26
  var _postcss = _interopRequireDefault(__nccwpck_require__(977));
27
27
  var _package = _interopRequireDefault(__nccwpck_require__(5446));
28
28
  var _semver = __nccwpck_require__(1280);
29
- var _options = _interopRequireDefault(__nccwpck_require__(6527));
30
- var _plugins = __nccwpck_require__(2320);
31
- var _utils = __nccwpck_require__(3012);
29
+ var _options = _interopRequireDefault(__nccwpck_require__(5021));
30
+ var _plugins = __nccwpck_require__(5796);
31
+ var _utils = __nccwpck_require__(6894);
32
32
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
33
33
  /*
34
34
  MIT License http://www.opensource.org/licenses/mit-license.php
@@ -167,20 +167,7 @@ async function loader(content, map, meta) {
167
167
  });
168
168
  }
169
169
  }
170
- let isTemplateLiteralSupported = false;
171
- if (
172
- // eslint-disable-next-line no-underscore-dangle
173
- this._compilation &&
174
- // eslint-disable-next-line no-underscore-dangle
175
- this._compilation.options &&
176
- // eslint-disable-next-line no-underscore-dangle
177
- this._compilation.options.output &&
178
- // eslint-disable-next-line no-underscore-dangle
179
- this._compilation.options.output.environment &&
180
- // eslint-disable-next-line no-underscore-dangle
181
- this._compilation.options.output.environment.templateLiteral) {
182
- isTemplateLiteralSupported = true;
183
- }
170
+ const isTemplateLiteralSupported = (0, _utils.supportTemplateLiteral)(this);
184
171
  const importCode = (0, _utils.getImportCode)(imports, options);
185
172
  let moduleCode;
186
173
  try {
@@ -211,7 +198,7 @@ async function loader(content, map, meta) {
211
198
 
212
199
  /***/ }),
213
200
 
214
- /***/ 2320:
201
+ /***/ 5796:
215
202
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
216
203
 
217
204
  "use strict";
@@ -238,14 +225,14 @@ Object.defineProperty(exports, "urlParser", ({
238
225
  return _postcssUrlParser.default;
239
226
  }
240
227
  }));
241
- var _postcssImportParser = _interopRequireDefault(__nccwpck_require__(2019));
242
- var _postcssIcssParser = _interopRequireDefault(__nccwpck_require__(7123));
243
- var _postcssUrlParser = _interopRequireDefault(__nccwpck_require__(7562));
228
+ var _postcssImportParser = _interopRequireDefault(__nccwpck_require__(9124));
229
+ var _postcssIcssParser = _interopRequireDefault(__nccwpck_require__(3410));
230
+ var _postcssUrlParser = _interopRequireDefault(__nccwpck_require__(1170));
244
231
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
245
232
 
246
233
  /***/ }),
247
234
 
248
- /***/ 7123:
235
+ /***/ 3410:
249
236
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
250
237
 
251
238
  "use strict";
@@ -256,7 +243,7 @@ Object.defineProperty(exports, "__esModule", ({
256
243
  }));
257
244
  exports["default"] = void 0;
258
245
  var _icssUtils = __nccwpck_require__(3275);
259
- var _utils = __nccwpck_require__(3012);
246
+ var _utils = __nccwpck_require__(6894);
260
247
  const plugin = (options = {}) => {
261
248
  return {
262
249
  postcssPlugin: "postcss-icss-parser",
@@ -365,7 +352,7 @@ var _default = exports["default"] = plugin;
365
352
 
366
353
  /***/ }),
367
354
 
368
- /***/ 2019:
355
+ /***/ 9124:
369
356
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
370
357
 
371
358
  "use strict";
@@ -376,27 +363,34 @@ Object.defineProperty(exports, "__esModule", ({
376
363
  }));
377
364
  exports["default"] = void 0;
378
365
  var _postcssValueParser = _interopRequireDefault(__nccwpck_require__(1036));
379
- var _utils = __nccwpck_require__(3012);
366
+ var _utils = __nccwpck_require__(6894);
380
367
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
381
- function parseNode(atRule, key, options) {
382
- // Convert only top-level @import
383
- if (atRule.parent.type !== "root") {
384
- return;
385
- }
368
+ function isIgnoredAfterName(atRule) {
386
369
  if (atRule.raws && atRule.raws.afterName && atRule.raws.afterName.trim().length > 0) {
387
370
  const lastCommentIndex = atRule.raws.afterName.lastIndexOf("/*");
388
371
  const matched = atRule.raws.afterName.slice(lastCommentIndex).match(_utils.WEBPACK_IGNORE_COMMENT_REGEXP);
389
372
  if (matched && matched[2] === "true") {
390
- return;
373
+ return true;
391
374
  }
392
375
  }
376
+ return false;
377
+ }
378
+ function isIgnoredPrevNode(atRule) {
393
379
  const prevNode = atRule.prev();
394
380
  if (prevNode && prevNode.type === "comment") {
395
381
  const matched = prevNode.text.match(_utils.WEBPACK_IGNORE_COMMENT_REGEXP);
396
382
  if (matched && matched[2] === "true") {
397
- return;
383
+ return true;
398
384
  }
399
385
  }
386
+ return false;
387
+ }
388
+ function parseNode(atRule, key, options) {
389
+ // Convert only top-level @import
390
+ if (atRule.parent.type !== "root") {
391
+ return;
392
+ }
393
+ const isIgnored = isIgnoredAfterName(atRule) || isIgnoredPrevNode(atRule);
400
394
 
401
395
  // Nodes do not exists - `@import url('http://') :root {}`
402
396
  if (atRule.nodes) {
@@ -432,10 +426,14 @@ function parseNode(atRule, key, options) {
432
426
  url = isStringValue ? paramsNodes[0].nodes[0].value : _postcssValueParser.default.stringify(paramsNodes[0].nodes);
433
427
  }
434
428
  url = (0, _utils.normalizeUrl)(url, isStringValue);
435
- const {
436
- requestable,
437
- needResolve
438
- } = (0, _utils.isURLRequestable)(url, options);
429
+ let requestable = false;
430
+ let needResolve = false;
431
+ if (!isIgnored) {
432
+ ({
433
+ requestable,
434
+ needResolve
435
+ } = (0, _utils.isURLRequestable)(url, options));
436
+ }
439
437
  let prefix;
440
438
  if (requestable && needResolve) {
441
439
  const queryParts = url.split("!");
@@ -654,7 +652,7 @@ var _default = exports["default"] = plugin;
654
652
 
655
653
  /***/ }),
656
654
 
657
- /***/ 7562:
655
+ /***/ 1170:
658
656
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
659
657
 
660
658
  "use strict";
@@ -665,7 +663,7 @@ Object.defineProperty(exports, "__esModule", ({
665
663
  }));
666
664
  exports["default"] = void 0;
667
665
  var _postcssValueParser = _interopRequireDefault(__nccwpck_require__(1036));
668
- var _utils = __nccwpck_require__(3012);
666
+ var _utils = __nccwpck_require__(6894);
669
667
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
670
668
  const isUrlFunc = /url/i;
671
669
  const isImageSetFunc = /^(?:-webkit-)?image-set$/i;
@@ -1017,7 +1015,7 @@ var _default = exports["default"] = plugin;
1017
1015
 
1018
1016
  /***/ }),
1019
1017
 
1020
- /***/ 3012:
1018
+ /***/ 6894:
1021
1019
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
1022
1020
 
1023
1021
  "use strict";
@@ -1050,6 +1048,7 @@ exports.shouldUseModulesPlugins = shouldUseModulesPlugins;
1050
1048
  exports.shouldUseURLPlugin = shouldUseURLPlugin;
1051
1049
  exports.sort = sort;
1052
1050
  exports.stringifyRequest = stringifyRequest;
1051
+ exports.supportTemplateLiteral = supportTemplateLiteral;
1053
1052
  exports.syntaxErrorFactory = syntaxErrorFactory;
1054
1053
  exports.warningFactory = warningFactory;
1055
1054
  var _url = __nccwpck_require__(7310);
@@ -2057,6 +2056,27 @@ function syntaxErrorFactory(error) {
2057
2056
  obj.stack = null;
2058
2057
  return obj;
2059
2058
  }
2059
+ function supportTemplateLiteral(loaderContext) {
2060
+ if (loaderContext.environment && loaderContext.environment.templateLiteral) {
2061
+ return true;
2062
+ }
2063
+
2064
+ // TODO remove in the next major release
2065
+ if (
2066
+ // eslint-disable-next-line no-underscore-dangle
2067
+ loaderContext._compilation &&
2068
+ // eslint-disable-next-line no-underscore-dangle
2069
+ loaderContext._compilation.options &&
2070
+ // eslint-disable-next-line no-underscore-dangle
2071
+ loaderContext._compilation.options.output &&
2072
+ // eslint-disable-next-line no-underscore-dangle
2073
+ loaderContext._compilation.options.output.environment &&
2074
+ // eslint-disable-next-line no-underscore-dangle
2075
+ loaderContext._compilation.options.output.environment.templateLiteral) {
2076
+ return true;
2077
+ }
2078
+ return false;
2079
+ }
2060
2080
 
2061
2081
  /***/ }),
2062
2082
 
@@ -7298,7 +7318,7 @@ module.exports = require("util");
7298
7318
 
7299
7319
  /***/ }),
7300
7320
 
7301
- /***/ 6527:
7321
+ /***/ 5021:
7302
7322
  /***/ ((module) => {
7303
7323
 
7304
7324
  "use strict";
@@ -7356,7 +7376,7 @@ module.exports = JSON.parse('{"name":"postcss","version":"8.4.38","description":
7356
7376
  /******/ // startup
7357
7377
  /******/ // Load entry module and return exports
7358
7378
  /******/ // This entry module is referenced by other modules so it can't be inlined
7359
- /******/ var __webpack_exports__ = __nccwpck_require__(9106);
7379
+ /******/ var __webpack_exports__ = __nccwpck_require__(6329);
7360
7380
  /******/ module.exports = __webpack_exports__;
7361
7381
  /******/
7362
7382
  /******/ })()
@@ -1 +1 @@
1
- {"name":"css-loader","author":"Tobias Koppers @sokra","version":"7.1.1","funding":{"type":"opencollective","url":"https://opencollective.com/webpack"},"license":"MIT","types":"index.d.ts","type":"commonjs"}
1
+ {"name":"css-loader","author":"Tobias Koppers @sokra","version":"7.1.2","funding":{"type":"opencollective","url":"https://opencollective.com/webpack"},"license":"MIT","types":"index.d.ts","type":"commonjs"}
@@ -7637,18 +7637,18 @@ module.exports = parseJson;
7637
7637
 
7638
7638
  /***/ }),
7639
7639
 
7640
- /***/ 6399:
7640
+ /***/ 701:
7641
7641
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
7642
7642
 
7643
- let tty = __nccwpck_require__(6224)
7644
-
7643
+ let argv = process.argv || [],
7644
+ env = process.env
7645
7645
  let isColorSupported =
7646
- !("NO_COLOR" in process.env || process.argv.includes("--no-color")) &&
7647
- ("FORCE_COLOR" in process.env ||
7648
- process.argv.includes("--color") ||
7646
+ !("NO_COLOR" in env || argv.includes("--no-color")) &&
7647
+ ("FORCE_COLOR" in env ||
7648
+ argv.includes("--color") ||
7649
7649
  process.platform === "win32" ||
7650
- (tty.isatty(1) && process.env.TERM !== "dumb") ||
7651
- "CI" in process.env)
7650
+ (require != null && (__nccwpck_require__(6224).isatty)(1) && env.TERM !== "dumb") ||
7651
+ "CI" in env)
7652
7652
 
7653
7653
  let formatter =
7654
7654
  (open, close, replace = open) =>
@@ -7661,40 +7661,47 @@ let formatter =
7661
7661
  }
7662
7662
 
7663
7663
  let replaceClose = (string, close, replace, index) => {
7664
- let start = string.substring(0, index) + replace
7665
- let end = string.substring(index + close.length)
7666
- let nextIndex = end.indexOf(close)
7667
- return ~nextIndex ? start + replaceClose(end, close, replace, nextIndex) : start + end
7668
- }
7669
-
7670
- let createColors = (enabled = isColorSupported) => ({
7671
- isColorSupported: enabled,
7672
- reset: enabled ? s => `\x1b[0m${s}\x1b[0m` : String,
7673
- bold: enabled ? formatter("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m") : String,
7674
- dim: enabled ? formatter("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m") : String,
7675
- italic: enabled ? formatter("\x1b[3m", "\x1b[23m") : String,
7676
- underline: enabled ? formatter("\x1b[4m", "\x1b[24m") : String,
7677
- inverse: enabled ? formatter("\x1b[7m", "\x1b[27m") : String,
7678
- hidden: enabled ? formatter("\x1b[8m", "\x1b[28m") : String,
7679
- strikethrough: enabled ? formatter("\x1b[9m", "\x1b[29m") : String,
7680
- black: enabled ? formatter("\x1b[30m", "\x1b[39m") : String,
7681
- red: enabled ? formatter("\x1b[31m", "\x1b[39m") : String,
7682
- green: enabled ? formatter("\x1b[32m", "\x1b[39m") : String,
7683
- yellow: enabled ? formatter("\x1b[33m", "\x1b[39m") : String,
7684
- blue: enabled ? formatter("\x1b[34m", "\x1b[39m") : String,
7685
- magenta: enabled ? formatter("\x1b[35m", "\x1b[39m") : String,
7686
- cyan: enabled ? formatter("\x1b[36m", "\x1b[39m") : String,
7687
- white: enabled ? formatter("\x1b[37m", "\x1b[39m") : String,
7688
- gray: enabled ? formatter("\x1b[90m", "\x1b[39m") : String,
7689
- bgBlack: enabled ? formatter("\x1b[40m", "\x1b[49m") : String,
7690
- bgRed: enabled ? formatter("\x1b[41m", "\x1b[49m") : String,
7691
- bgGreen: enabled ? formatter("\x1b[42m", "\x1b[49m") : String,
7692
- bgYellow: enabled ? formatter("\x1b[43m", "\x1b[49m") : String,
7693
- bgBlue: enabled ? formatter("\x1b[44m", "\x1b[49m") : String,
7694
- bgMagenta: enabled ? formatter("\x1b[45m", "\x1b[49m") : String,
7695
- bgCyan: enabled ? formatter("\x1b[46m", "\x1b[49m") : String,
7696
- bgWhite: enabled ? formatter("\x1b[47m", "\x1b[49m") : String,
7697
- })
7664
+ let result = ""
7665
+ let cursor = 0
7666
+ do {
7667
+ result += string.substring(cursor, index) + replace
7668
+ cursor = index + close.length
7669
+ index = string.indexOf(close, cursor)
7670
+ } while (~index)
7671
+ return result + string.substring(cursor)
7672
+ }
7673
+
7674
+ let createColors = (enabled = isColorSupported) => {
7675
+ let init = enabled ? formatter : () => String
7676
+ return {
7677
+ isColorSupported: enabled,
7678
+ reset: init("\x1b[0m", "\x1b[0m"),
7679
+ bold: init("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"),
7680
+ dim: init("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
7681
+ italic: init("\x1b[3m", "\x1b[23m"),
7682
+ underline: init("\x1b[4m", "\x1b[24m"),
7683
+ inverse: init("\x1b[7m", "\x1b[27m"),
7684
+ hidden: init("\x1b[8m", "\x1b[28m"),
7685
+ strikethrough: init("\x1b[9m", "\x1b[29m"),
7686
+ black: init("\x1b[30m", "\x1b[39m"),
7687
+ red: init("\x1b[31m", "\x1b[39m"),
7688
+ green: init("\x1b[32m", "\x1b[39m"),
7689
+ yellow: init("\x1b[33m", "\x1b[39m"),
7690
+ blue: init("\x1b[34m", "\x1b[39m"),
7691
+ magenta: init("\x1b[35m", "\x1b[39m"),
7692
+ cyan: init("\x1b[36m", "\x1b[39m"),
7693
+ white: init("\x1b[37m", "\x1b[39m"),
7694
+ gray: init("\x1b[90m", "\x1b[39m"),
7695
+ bgBlack: init("\x1b[40m", "\x1b[49m"),
7696
+ bgRed: init("\x1b[41m", "\x1b[49m"),
7697
+ bgGreen: init("\x1b[42m", "\x1b[49m"),
7698
+ bgYellow: init("\x1b[43m", "\x1b[49m"),
7699
+ bgBlue: init("\x1b[44m", "\x1b[49m"),
7700
+ bgMagenta: init("\x1b[45m", "\x1b[49m"),
7701
+ bgCyan: init("\x1b[46m", "\x1b[49m"),
7702
+ bgWhite: init("\x1b[47m", "\x1b[49m"),
7703
+ }
7704
+ }
7698
7705
 
7699
7706
  module.exports = createColors()
7700
7707
  module.exports.createColors = createColors
@@ -8678,7 +8685,7 @@ Object.defineProperty(exports, "__esModule", ({
8678
8685
  exports.codeFrameColumns = codeFrameColumns;
8679
8686
  exports["default"] = _default;
8680
8687
  var _highlight = __nccwpck_require__(8635);
8681
- var _picocolors = _interopRequireWildcard(__nccwpck_require__(6399), true);
8688
+ var _picocolors = _interopRequireWildcard(__nccwpck_require__(701), true);
8682
8689
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
8683
8690
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
8684
8691
  const colors = typeof process === "object" && (process.env.FORCE_COLOR === "0" || process.env.FORCE_COLOR === "false") ? (0, _picocolors.createColors)(false) : _picocolors.default;
@@ -8830,7 +8837,7 @@ function _default(rawLines, lineNumber, colNumber, opts = {}) {
8830
8837
 
8831
8838
  /***/ }),
8832
8839
 
8833
- /***/ 752:
8840
+ /***/ 7235:
8834
8841
  /***/ ((__unused_webpack_module, exports) => {
8835
8842
 
8836
8843
  "use strict";
@@ -8908,7 +8915,7 @@ function isIdentifierName(name) {
8908
8915
 
8909
8916
  /***/ }),
8910
8917
 
8911
- /***/ 3596:
8918
+ /***/ 9130:
8912
8919
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
8913
8920
 
8914
8921
  "use strict";
@@ -8965,15 +8972,15 @@ Object.defineProperty(exports, "isStrictReservedWord", ({
8965
8972
  return _keyword.isStrictReservedWord;
8966
8973
  }
8967
8974
  }));
8968
- var _identifier = __nccwpck_require__(752);
8969
- var _keyword = __nccwpck_require__(6);
8975
+ var _identifier = __nccwpck_require__(7235);
8976
+ var _keyword = __nccwpck_require__(8101);
8970
8977
 
8971
8978
  //# sourceMappingURL=index.js.map
8972
8979
 
8973
8980
 
8974
8981
  /***/ }),
8975
8982
 
8976
- /***/ 6:
8983
+ /***/ 8101:
8977
8984
  /***/ ((__unused_webpack_module, exports) => {
8978
8985
 
8979
8986
  "use strict";
@@ -9028,8 +9035,8 @@ Object.defineProperty(exports, "__esModule", ({
9028
9035
  exports["default"] = highlight;
9029
9036
  exports.shouldHighlight = shouldHighlight;
9030
9037
  var _jsTokens = __nccwpck_require__(1192);
9031
- var _helperValidatorIdentifier = __nccwpck_require__(3596);
9032
- var _picocolors = _interopRequireWildcard(__nccwpck_require__(6399), true);
9038
+ var _helperValidatorIdentifier = __nccwpck_require__(9130);
9039
+ var _picocolors = _interopRequireWildcard(__nccwpck_require__(701), true);
9033
9040
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
9034
9041
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
9035
9042
  const colors = typeof process === "object" && (process.env.FORCE_COLOR === "0" || process.env.FORCE_COLOR === "false") ? (0, _picocolors.createColors)(false) : _picocolors.default;
@@ -11,8 +11,8 @@ function resolveFileName(stats) {
11
11
  }
12
12
  }
13
13
  }
14
- return `File: ${stats.moduleName}
15
- `;
14
+ return stats.moduleName ? `File: ${stats.moduleName}
15
+ ` : "";
16
16
  }
17
17
  function hintUnknownFiles(message) {
18
18
  const hint = "You may need an appropriate loader to handle this file type.";
package/dist/index.cjs CHANGED
@@ -35,23 +35,6 @@ var __publicField = (obj, key, value) => {
35
35
  return value;
36
36
  };
37
37
 
38
- // src/constants.ts
39
- var import_node_path, PLUGIN_SWC_NAME, PLUGIN_CSS_NAME, LOADER_PATH, STATIC_PATH, COMPILED_PATH, TS_CONFIG_FILE, HTML_REGEX, CSS_REGEX;
40
- var init_constants = __esm({
41
- "src/constants.ts"() {
42
- "use strict";
43
- import_node_path = require("path");
44
- PLUGIN_SWC_NAME = "rsbuild:swc";
45
- PLUGIN_CSS_NAME = "rsbuild:css";
46
- LOADER_PATH = (0, import_node_path.join)(__dirname);
47
- STATIC_PATH = (0, import_node_path.join)(__dirname, "../static");
48
- COMPILED_PATH = (0, import_node_path.join)(__dirname, "../compiled");
49
- TS_CONFIG_FILE = "tsconfig.json";
50
- HTML_REGEX = /\.html$/;
51
- CSS_REGEX = /\.css$/;
52
- }
53
- });
54
-
55
38
  // src/client/format.ts
56
39
  function resolveFileName(stats) {
57
40
  if (stats.moduleIdentifier) {
@@ -65,8 +48,8 @@ function resolveFileName(stats) {
65
48
  }
66
49
  }
67
50
  }
68
- return `File: ${stats.moduleName}
69
- `;
51
+ return stats.moduleName ? `File: ${stats.moduleName}
52
+ ` : "";
70
53
  }
71
54
  function hintUnknownFiles(message) {
72
55
  const hint = "You may need an appropriate loader to handle this file type.";
@@ -130,6 +113,23 @@ var init_format = __esm({
130
113
  }
131
114
  });
132
115
 
116
+ // src/constants.ts
117
+ var import_node_path, PLUGIN_SWC_NAME, PLUGIN_CSS_NAME, LOADER_PATH, STATIC_PATH, COMPILED_PATH, TS_CONFIG_FILE, HTML_REGEX, CSS_REGEX;
118
+ var init_constants = __esm({
119
+ "src/constants.ts"() {
120
+ "use strict";
121
+ import_node_path = require("path");
122
+ PLUGIN_SWC_NAME = "rsbuild:swc";
123
+ PLUGIN_CSS_NAME = "rsbuild:css";
124
+ LOADER_PATH = (0, import_node_path.join)(__dirname);
125
+ STATIC_PATH = (0, import_node_path.join)(__dirname, "../static");
126
+ COMPILED_PATH = (0, import_node_path.join)(__dirname, "../compiled");
127
+ TS_CONFIG_FILE = "tsconfig.json";
128
+ HTML_REGEX = /\.html$/;
129
+ CSS_REGEX = /\.css$/;
130
+ }
131
+ });
132
+
133
133
  // src/helpers.ts
134
134
  function formatErrorMessage(errors) {
135
135
  const messages = errors.map((error) => hintNodePolyfill(error));
@@ -188,6 +188,10 @@ function formatStats(stats, options = {}) {
188
188
  }
189
189
  return {};
190
190
  }
191
+ function isEmptyDir(path13) {
192
+ const files = import_shared2.fse.readdirSync(path13);
193
+ return files.length === 0 || files.length === 1 && files[0] === ".git";
194
+ }
191
195
  async function isFileExists(file) {
192
196
  return import_shared2.fse.promises.access(file, import_shared2.fse.constants.F_OK).then(() => true).catch(() => false);
193
197
  }
@@ -650,6 +654,7 @@ var init_config = __esm({
650
654
  inlineStyles: false,
651
655
  cssModules: {
652
656
  auto: true,
657
+ namedExport: false,
653
658
  exportGlobals: false,
654
659
  exportLocalsConvention: "camelCase"
655
660
  },
@@ -667,7 +672,7 @@ var init_config = __esm({
667
672
  });
668
673
  withDefaultConfig = async (rootPath, config) => {
669
674
  const merged = mergeRsbuildConfig(createDefaultConfig(), config);
670
- merged.source || (merged.source = {});
675
+ merged.source ||= {};
671
676
  if (!merged.source.entry) {
672
677
  merged.source.entry = getDefaultEntry(rootPath);
673
678
  }
@@ -911,7 +916,7 @@ async function createContextByConfig(options, bundlerType, config = {}) {
911
916
  return {
912
917
  entry: getEntryObject(config, "web"),
913
918
  targets: config.output?.targets || [],
914
- version: "0.7.1",
919
+ version: "0.7.2",
915
920
  rootPath,
916
921
  distPath,
917
922
  cachePath,
@@ -1888,7 +1893,7 @@ function formatProxyOptions(proxyOptions) {
1888
1893
  }
1889
1894
  const handleError = (err) => import_shared18.logger.error(err);
1890
1895
  for (const opts of ret) {
1891
- opts.onError ?? (opts.onError = handleError);
1896
+ opts.onError ??= handleError;
1892
1897
  }
1893
1898
  return ret;
1894
1899
  }
@@ -3083,7 +3088,10 @@ var init_build = __esm({
3083
3088
  const buildError = err || new Error("Rspack build failed!");
3084
3089
  reject(buildError);
3085
3090
  } else {
3086
- compiler.close(() => {
3091
+ compiler.close((closeErr) => {
3092
+ if (closeErr) {
3093
+ import_shared24.logger.error(closeErr);
3094
+ }
3087
3095
  resolve({ stats });
3088
3096
  });
3089
3097
  }
@@ -3193,7 +3201,6 @@ var init_basic = __esm({
3193
3201
  setup(api) {
3194
3202
  api.modifyBundlerChain(
3195
3203
  (chain, { env, isProd: isProd4, target, bundler, CHAIN_ID: CHAIN_ID3 }) => {
3196
- var _a;
3197
3204
  const config = api.getNormalizedConfig();
3198
3205
  chain.name(import_shared25.TARGET_ID_MAP[target]);
3199
3206
  chain.devtool((0, import_shared25.getJsSourceMap)(config));
@@ -3223,7 +3230,7 @@ var init_basic = __esm({
3223
3230
  );
3224
3231
  }
3225
3232
  process.env.RSPACK_CONFIG_VALIDATE = "loose-silent";
3226
- (_a = process.env).WATCHPACK_WATCHER_LIMIT || (_a.WATCHPACK_WATCHER_LIMIT = "20");
3233
+ process.env.WATCHPACK_WATCHER_LIMIT ||= "20";
3227
3234
  }
3228
3235
  );
3229
3236
  }
@@ -3533,7 +3540,7 @@ var init_css = __esm({
3533
3540
  if (extraPlugins.length) {
3534
3541
  mergedConfig?.postcssOptions?.plugins.push(...extraPlugins);
3535
3542
  }
3536
- mergedConfig.postcssOptions || (mergedConfig.postcssOptions = {});
3543
+ mergedConfig.postcssOptions ||= {};
3537
3544
  mergedConfig.postcssOptions.config = false;
3538
3545
  return mergedConfig;
3539
3546
  };
@@ -3547,10 +3554,7 @@ var init_css = __esm({
3547
3554
  const defaultOptions2 = {
3548
3555
  importLoaders,
3549
3556
  modules: {
3550
- auto: cssModules.auto,
3551
- namedExport: false,
3552
- exportGlobals: cssModules.exportGlobals,
3553
- exportLocalsConvention: cssModules.exportLocalsConvention,
3557
+ ...cssModules,
3554
3558
  localIdentName
3555
3559
  },
3556
3560
  sourceMap: config.output.sourceMap.css
@@ -3584,7 +3588,7 @@ var init_css = __esm({
3584
3588
  }
3585
3589
  });
3586
3590
  api.modifyRspackConfig(async (rspackConfig) => {
3587
- rspackConfig.experiments || (rspackConfig.experiments = {});
3591
+ rspackConfig.experiments ||= {};
3588
3592
  rspackConfig.experiments.css = false;
3589
3593
  });
3590
3594
  }
@@ -3760,7 +3764,7 @@ var init_resolve = __esm({
3760
3764
  api.modifyRspackConfig(async (rspackConfig) => {
3761
3765
  const isTsProject = Boolean(api.context.tsconfigPath);
3762
3766
  const config = api.getNormalizedConfig();
3763
- rspackConfig.resolve || (rspackConfig.resolve = {});
3767
+ rspackConfig.resolve ||= {};
3764
3768
  if (isTsProject && config.source.aliasStrategy === "prefer-tsconfig") {
3765
3769
  rspackConfig.resolve.tsConfigPath = api.context.tsconfigPath;
3766
3770
  }
@@ -4100,7 +4104,7 @@ var init_minimize = __esm({
4100
4104
  pure_funcs: pureFuncs
4101
4105
  };
4102
4106
  }
4103
- options.format || (options.format = {});
4107
+ options.format ||= {};
4104
4108
  switch (config.output.legalComments) {
4105
4109
  case "inline":
4106
4110
  options.format.comments = "some";
@@ -4771,7 +4775,6 @@ var init_html = __esm({
4771
4775
  // ensure `crossorigin` and `nonce` can be applied to all tags
4772
4776
  order: "post",
4773
4777
  handler: ({ headTags, bodyTags }) => {
4774
- var _a;
4775
4778
  const config = api.getNormalizedConfig();
4776
4779
  const { crossorigin } = config.html;
4777
4780
  const { nonce } = config.security;
@@ -4780,15 +4783,15 @@ var init_html = __esm({
4780
4783
  const formattedCrossorigin = crossorigin === true ? "anonymous" : crossorigin;
4781
4784
  for (const tag of allTags) {
4782
4785
  if (tag.tag === "script" && tag.attrs?.src || tag.tag === "link" && tag.attrs?.rel === "stylesheet") {
4783
- tag.attrs || (tag.attrs = {});
4784
- (_a = tag.attrs).crossorigin ?? (_a.crossorigin = formattedCrossorigin);
4786
+ tag.attrs ||= {};
4787
+ tag.attrs.crossorigin ??= formattedCrossorigin;
4785
4788
  }
4786
4789
  }
4787
4790
  }
4788
4791
  if (nonce) {
4789
4792
  for (const tag of allTags) {
4790
4793
  if (tag.tag === "script" || tag.tag === "style") {
4791
- tag.attrs ?? (tag.attrs = {});
4794
+ tag.attrs ??= {};
4792
4795
  tag.attrs.nonce = nonce;
4793
4796
  }
4794
4797
  }
@@ -5020,17 +5023,15 @@ async function applyCoreJs(swcConfig, chain, polyfillMode) {
5020
5023
  });
5021
5024
  }
5022
5025
  function applyTransformImport(swcConfig, pluginImport) {
5023
- var _a;
5024
5026
  if (pluginImport !== false && pluginImport) {
5025
- swcConfig.rspackExperiments ?? (swcConfig.rspackExperiments = {});
5026
- (_a = swcConfig.rspackExperiments).import ?? (_a.import = []);
5027
+ swcConfig.rspackExperiments ??= {};
5028
+ swcConfig.rspackExperiments.import ??= [];
5027
5029
  swcConfig.rspackExperiments.import.push(...pluginImport);
5028
5030
  }
5029
5031
  }
5030
5032
  function applySwcDecoratorConfig(swcConfig, config) {
5031
- var _a;
5032
- swcConfig.jsc || (swcConfig.jsc = {});
5033
- (_a = swcConfig.jsc).transform || (_a.transform = {});
5033
+ swcConfig.jsc ||= {};
5034
+ swcConfig.jsc.transform ||= {};
5034
5035
  const { version: version2 } = config.source.decorators;
5035
5036
  switch (version2) {
5036
5037
  case "legacy":
@@ -5705,7 +5706,7 @@ function pluginBundleAnalyzer() {
5705
5706
  if ((0, import_shared47.isProd)() || !isUseAnalyzer(config)) {
5706
5707
  return;
5707
5708
  }
5708
- config.dev || (config.dev = {});
5709
+ config.dev ||= {};
5709
5710
  config.dev.writeToDisk = true;
5710
5711
  return config;
5711
5712
  });
@@ -5779,7 +5780,7 @@ var init_rsdoctor = __esm({
5779
5780
  if (registered) {
5780
5781
  return;
5781
5782
  }
5782
- config.plugins || (config.plugins = []);
5783
+ config.plugins ||= [];
5783
5784
  config.plugins.push(new module2[pluginName]());
5784
5785
  isAutoRegister = true;
5785
5786
  }
@@ -6146,7 +6147,7 @@ var init_performance = __esm({
6146
6147
  api.modifyRsbuildConfig((rsbuildConfig) => {
6147
6148
  if (rsbuildConfig.performance?.profile) {
6148
6149
  if (!rsbuildConfig.performance?.bundleAnalyze) {
6149
- rsbuildConfig.performance ?? (rsbuildConfig.performance = {});
6150
+ rsbuildConfig.performance ??= {};
6150
6151
  rsbuildConfig.performance.bundleAnalyze = {
6151
6152
  analyzerMode: "disabled",
6152
6153
  generateStatsFile: true
@@ -6804,21 +6805,21 @@ async function init({
6804
6805
  watchFiles(files);
6805
6806
  }
6806
6807
  const { createRsbuild: createRsbuild2 } = await Promise.resolve().then(() => (init_createRsbuild(), createRsbuild_exports));
6807
- config.source || (config.source = {});
6808
+ config.source ||= {};
6808
6809
  config.source.define = {
6809
6810
  ...envs.publicVars,
6810
6811
  ...config.source.define
6811
6812
  };
6812
6813
  if (commonOpts.open && !config.dev?.startUrl) {
6813
- config.dev || (config.dev = {});
6814
+ config.dev ||= {};
6814
6815
  config.dev.startUrl = commonOpts.open;
6815
6816
  }
6816
6817
  if (commonOpts.host) {
6817
- config.server || (config.server = {});
6818
+ config.server ||= {};
6818
6819
  config.server.host = commonOpts.host;
6819
6820
  }
6820
6821
  if (commonOpts.port) {
6821
- config.server || (config.server = {});
6822
+ config.server ||= {};
6822
6823
  config.server.port = commonOpts.port;
6823
6824
  }
6824
6825
  return createRsbuild2({
@@ -6889,6 +6890,7 @@ var import_node_fs5 = require("fs");
6889
6890
  var import_node_path28 = require("path");
6890
6891
  var import_shared59 = require("@rsbuild/shared");
6891
6892
  var import_commander = require("../compiled/commander/index.js");
6893
+ init_helpers();
6892
6894
  init_init();
6893
6895
  var applyCommonOptions = (command) => {
6894
6896
  command.option(
@@ -6903,7 +6905,7 @@ var applyServerOptions = (command) => {
6903
6905
  command.option("-o --open [url]", "open the page in browser on startup").option("--port <port>", "specify a port number for server to listen").option("--host <host>", "specify the host that the server listens to");
6904
6906
  };
6905
6907
  function runCli() {
6906
- import_commander.program.name("rsbuild").usage("<command> [options]").version("0.7.1");
6908
+ import_commander.program.name("rsbuild").usage("<command> [options]").version("0.7.2");
6907
6909
  const devCommand = import_commander.program.command("dev");
6908
6910
  const buildCommand = import_commander.program.command("build");
6909
6911
  const previewCommand = import_commander.program.command("preview");
@@ -6937,12 +6939,22 @@ function runCli() {
6937
6939
  previewCommand.description("preview the production build locally").action(async (options) => {
6938
6940
  try {
6939
6941
  const rsbuild = await init({ cliOptions: options });
6940
- if (rsbuild && !(0, import_node_fs5.existsSync)(rsbuild.context.distPath)) {
6941
- throw new Error(
6942
- `The output directory ${import_shared59.color.yellow(
6943
- rsbuild.context.distPath
6944
- )} does not exist, please build the project before previewing.`
6945
- );
6942
+ if (rsbuild) {
6943
+ const { distPath } = rsbuild.context;
6944
+ if (!(0, import_node_fs5.existsSync)(distPath)) {
6945
+ throw new Error(
6946
+ `The output directory ${import_shared59.color.yellow(
6947
+ distPath
6948
+ )} does not exist, please build the project before previewing.`
6949
+ );
6950
+ }
6951
+ if (isEmptyDir(distPath)) {
6952
+ throw new Error(
6953
+ `The output directory ${import_shared59.color.yellow(
6954
+ distPath
6955
+ )} is empty, please build the project before previewing.`
6956
+ );
6957
+ }
6946
6958
  }
6947
6959
  await rsbuild?.preview();
6948
6960
  } catch (err) {
@@ -6983,7 +6995,7 @@ function prepareCli() {
6983
6995
  if (!npm_execpath || npm_execpath.includes("npx-cli.js") || npm_execpath.includes(".bun")) {
6984
6996
  console.log();
6985
6997
  }
6986
- import_shared60.logger.greet(` ${`Rsbuild v${"0.7.1"}`}
6998
+ import_shared60.logger.greet(` ${`Rsbuild v${"0.7.2"}`}
6987
6999
  `);
6988
7000
  }
6989
7001
 
@@ -7009,7 +7021,7 @@ init_config();
7009
7021
  var import_shared61 = require("@rsbuild/shared");
7010
7022
  init_mergeConfig();
7011
7023
  init_constants();
7012
- var version = "0.7.1";
7024
+ var version = "0.7.2";
7013
7025
  // Annotate the CommonJS export names for ESM import in node:
7014
7026
  0 && (module.exports = {
7015
7027
  PLUGIN_CSS_NAME,
package/dist/index.js CHANGED
@@ -23,12 +23,12 @@ var __publicField = (obj, key, value) => {
23
23
  return value;
24
24
  };
25
25
 
26
- // ../../node_modules/.pnpm/@modern-js+module-tools@2.50.0_eslint@9.3.0_typescript@5.4.5/node_modules/@modern-js/module-tools/shims/esm.js
26
+ // ../../node_modules/.pnpm/@modern-js+module-tools@2.50.0_eslint@9.4.0_typescript@5.4.5/node_modules/@modern-js/module-tools/shims/esm.js
27
27
  import { fileURLToPath } from "url";
28
28
  import path from "path";
29
29
  var getFilename, getDirname, __dirname, __filename;
30
30
  var init_esm = __esm({
31
- "../../node_modules/.pnpm/@modern-js+module-tools@2.50.0_eslint@9.3.0_typescript@5.4.5/node_modules/@modern-js/module-tools/shims/esm.js"() {
31
+ "../../node_modules/.pnpm/@modern-js+module-tools@2.50.0_eslint@9.4.0_typescript@5.4.5/node_modules/@modern-js/module-tools/shims/esm.js"() {
32
32
  "use strict";
33
33
  getFilename = () => fileURLToPath(import.meta.url);
34
34
  getDirname = () => path.dirname(getFilename());
@@ -37,24 +37,6 @@ var init_esm = __esm({
37
37
  }
38
38
  });
39
39
 
40
- // src/constants.ts
41
- import { join } from "path";
42
- var PLUGIN_SWC_NAME, PLUGIN_CSS_NAME, LOADER_PATH, STATIC_PATH, COMPILED_PATH, TS_CONFIG_FILE, HTML_REGEX, CSS_REGEX;
43
- var init_constants = __esm({
44
- "src/constants.ts"() {
45
- "use strict";
46
- init_esm();
47
- PLUGIN_SWC_NAME = "rsbuild:swc";
48
- PLUGIN_CSS_NAME = "rsbuild:css";
49
- LOADER_PATH = join(__dirname);
50
- STATIC_PATH = join(__dirname, "../static");
51
- COMPILED_PATH = join(__dirname, "../compiled");
52
- TS_CONFIG_FILE = "tsconfig.json";
53
- HTML_REGEX = /\.html$/;
54
- CSS_REGEX = /\.css$/;
55
- }
56
- });
57
-
58
40
  // src/client/format.ts
59
41
  function resolveFileName(stats) {
60
42
  if (stats.moduleIdentifier) {
@@ -68,8 +50,8 @@ function resolveFileName(stats) {
68
50
  }
69
51
  }
70
52
  }
71
- return `File: ${stats.moduleName}
72
- `;
53
+ return stats.moduleName ? `File: ${stats.moduleName}
54
+ ` : "";
73
55
  }
74
56
  function hintUnknownFiles(message) {
75
57
  const hint = "You may need an appropriate loader to handle this file type.";
@@ -134,6 +116,24 @@ var init_format = __esm({
134
116
  }
135
117
  });
136
118
 
119
+ // src/constants.ts
120
+ import { join } from "path";
121
+ var PLUGIN_SWC_NAME, PLUGIN_CSS_NAME, LOADER_PATH, STATIC_PATH, COMPILED_PATH, TS_CONFIG_FILE, HTML_REGEX, CSS_REGEX;
122
+ var init_constants = __esm({
123
+ "src/constants.ts"() {
124
+ "use strict";
125
+ init_esm();
126
+ PLUGIN_SWC_NAME = "rsbuild:swc";
127
+ PLUGIN_CSS_NAME = "rsbuild:css";
128
+ LOADER_PATH = join(__dirname);
129
+ STATIC_PATH = join(__dirname, "../static");
130
+ COMPILED_PATH = join(__dirname, "../compiled");
131
+ TS_CONFIG_FILE = "tsconfig.json";
132
+ HTML_REGEX = /\.html$/;
133
+ CSS_REGEX = /\.css$/;
134
+ }
135
+ });
136
+
137
137
  // src/helpers.ts
138
138
  import path2 from "path";
139
139
  import {
@@ -201,6 +201,10 @@ function formatStats(stats, options = {}) {
201
201
  }
202
202
  return {};
203
203
  }
204
+ function isEmptyDir(path14) {
205
+ const files = fse.readdirSync(path14);
206
+ return files.length === 0 || files.length === 1 && files[0] === ".git";
207
+ }
204
208
  async function isFileExists(file) {
205
209
  return fse.promises.access(file, fse.constants.F_OK).then(() => true).catch(() => false);
206
210
  }
@@ -690,6 +694,7 @@ var init_config = __esm({
690
694
  inlineStyles: false,
691
695
  cssModules: {
692
696
  auto: true,
697
+ namedExport: false,
693
698
  exportGlobals: false,
694
699
  exportLocalsConvention: "camelCase"
695
700
  },
@@ -707,7 +712,7 @@ var init_config = __esm({
707
712
  });
708
713
  withDefaultConfig = async (rootPath, config) => {
709
714
  const merged = mergeRsbuildConfig(createDefaultConfig(), config);
710
- merged.source || (merged.source = {});
715
+ merged.source ||= {};
711
716
  if (!merged.source.entry) {
712
717
  merged.source.entry = getDefaultEntry(rootPath);
713
718
  }
@@ -962,7 +967,7 @@ async function createContextByConfig(options, bundlerType, config = {}) {
962
967
  return {
963
968
  entry: getEntryObject(config, "web"),
964
969
  targets: config.output?.targets || [],
965
- version: "0.7.1",
970
+ version: "0.7.2",
966
971
  rootPath,
967
972
  distPath,
968
973
  cachePath,
@@ -1984,7 +1989,7 @@ function formatProxyOptions(proxyOptions) {
1984
1989
  }
1985
1990
  const handleError = (err) => logger7.error(err);
1986
1991
  for (const opts of ret) {
1987
- opts.onError ?? (opts.onError = handleError);
1992
+ opts.onError ??= handleError;
1988
1993
  }
1989
1994
  return ret;
1990
1995
  }
@@ -3206,7 +3211,10 @@ var init_build = __esm({
3206
3211
  const buildError = err || new Error("Rspack build failed!");
3207
3212
  reject(buildError);
3208
3213
  } else {
3209
- compiler.close(() => {
3214
+ compiler.close((closeErr) => {
3215
+ if (closeErr) {
3216
+ logger10.error(closeErr);
3217
+ }
3210
3218
  resolve({ stats });
3211
3219
  });
3212
3220
  }
@@ -3318,7 +3326,6 @@ var init_basic = __esm({
3318
3326
  setup(api) {
3319
3327
  api.modifyBundlerChain(
3320
3328
  (chain, { env, isProd: isProd4, target, bundler, CHAIN_ID: CHAIN_ID3 }) => {
3321
- var _a;
3322
3329
  const config = api.getNormalizedConfig();
3323
3330
  chain.name(TARGET_ID_MAP2[target]);
3324
3331
  chain.devtool(getJsSourceMap(config));
@@ -3348,7 +3355,7 @@ var init_basic = __esm({
3348
3355
  );
3349
3356
  }
3350
3357
  process.env.RSPACK_CONFIG_VALIDATE = "loose-silent";
3351
- (_a = process.env).WATCHPACK_WATCHER_LIMIT || (_a.WATCHPACK_WATCHER_LIMIT = "20");
3358
+ process.env.WATCHPACK_WATCHER_LIMIT ||= "20";
3352
3359
  }
3353
3360
  );
3354
3361
  }
@@ -3670,7 +3677,7 @@ var init_css = __esm({
3670
3677
  if (extraPlugins.length) {
3671
3678
  mergedConfig?.postcssOptions?.plugins.push(...extraPlugins);
3672
3679
  }
3673
- mergedConfig.postcssOptions || (mergedConfig.postcssOptions = {});
3680
+ mergedConfig.postcssOptions ||= {};
3674
3681
  mergedConfig.postcssOptions.config = false;
3675
3682
  return mergedConfig;
3676
3683
  };
@@ -3684,10 +3691,7 @@ var init_css = __esm({
3684
3691
  const defaultOptions2 = {
3685
3692
  importLoaders,
3686
3693
  modules: {
3687
- auto: cssModules.auto,
3688
- namedExport: false,
3689
- exportGlobals: cssModules.exportGlobals,
3690
- exportLocalsConvention: cssModules.exportLocalsConvention,
3694
+ ...cssModules,
3691
3695
  localIdentName
3692
3696
  },
3693
3697
  sourceMap: config.output.sourceMap.css
@@ -3721,7 +3725,7 @@ var init_css = __esm({
3721
3725
  }
3722
3726
  });
3723
3727
  api.modifyRspackConfig(async (rspackConfig) => {
3724
- rspackConfig.experiments || (rspackConfig.experiments = {});
3728
+ rspackConfig.experiments ||= {};
3725
3729
  rspackConfig.experiments.css = false;
3726
3730
  });
3727
3731
  }
@@ -3908,7 +3912,7 @@ var init_resolve = __esm({
3908
3912
  api.modifyRspackConfig(async (rspackConfig) => {
3909
3913
  const isTsProject = Boolean(api.context.tsconfigPath);
3910
3914
  const config = api.getNormalizedConfig();
3911
- rspackConfig.resolve || (rspackConfig.resolve = {});
3915
+ rspackConfig.resolve ||= {};
3912
3916
  if (isTsProject && config.source.aliasStrategy === "prefer-tsconfig") {
3913
3917
  rspackConfig.resolve.tsConfigPath = api.context.tsconfigPath;
3914
3918
  }
@@ -4263,7 +4267,7 @@ var init_minimize = __esm({
4263
4267
  pure_funcs: pureFuncs
4264
4268
  };
4265
4269
  }
4266
- options.format || (options.format = {});
4270
+ options.format ||= {};
4267
4271
  switch (config.output.legalComments) {
4268
4272
  case "inline":
4269
4273
  options.format.comments = "some";
@@ -4954,7 +4958,6 @@ var init_html = __esm({
4954
4958
  // ensure `crossorigin` and `nonce` can be applied to all tags
4955
4959
  order: "post",
4956
4960
  handler: ({ headTags, bodyTags }) => {
4957
- var _a;
4958
4961
  const config = api.getNormalizedConfig();
4959
4962
  const { crossorigin } = config.html;
4960
4963
  const { nonce } = config.security;
@@ -4963,15 +4966,15 @@ var init_html = __esm({
4963
4966
  const formattedCrossorigin = crossorigin === true ? "anonymous" : crossorigin;
4964
4967
  for (const tag of allTags) {
4965
4968
  if (tag.tag === "script" && tag.attrs?.src || tag.tag === "link" && tag.attrs?.rel === "stylesheet") {
4966
- tag.attrs || (tag.attrs = {});
4967
- (_a = tag.attrs).crossorigin ?? (_a.crossorigin = formattedCrossorigin);
4969
+ tag.attrs ||= {};
4970
+ tag.attrs.crossorigin ??= formattedCrossorigin;
4968
4971
  }
4969
4972
  }
4970
4973
  }
4971
4974
  if (nonce) {
4972
4975
  for (const tag of allTags) {
4973
4976
  if (tag.tag === "script" || tag.tag === "style") {
4974
- tag.attrs ?? (tag.attrs = {});
4977
+ tag.attrs ??= {};
4975
4978
  tag.attrs.nonce = nonce;
4976
4979
  }
4977
4980
  }
@@ -5219,17 +5222,15 @@ async function applyCoreJs(swcConfig, chain, polyfillMode) {
5219
5222
  });
5220
5223
  }
5221
5224
  function applyTransformImport(swcConfig, pluginImport) {
5222
- var _a;
5223
5225
  if (pluginImport !== false && pluginImport) {
5224
- swcConfig.rspackExperiments ?? (swcConfig.rspackExperiments = {});
5225
- (_a = swcConfig.rspackExperiments).import ?? (_a.import = []);
5226
+ swcConfig.rspackExperiments ??= {};
5227
+ swcConfig.rspackExperiments.import ??= [];
5226
5228
  swcConfig.rspackExperiments.import.push(...pluginImport);
5227
5229
  }
5228
5230
  }
5229
5231
  function applySwcDecoratorConfig(swcConfig, config) {
5230
- var _a;
5231
- swcConfig.jsc || (swcConfig.jsc = {});
5232
- (_a = swcConfig.jsc).transform || (_a.transform = {});
5232
+ swcConfig.jsc ||= {};
5233
+ swcConfig.jsc.transform ||= {};
5233
5234
  const { version: version2 } = config.source.decorators;
5234
5235
  switch (version2) {
5235
5236
  case "legacy":
@@ -5920,7 +5921,7 @@ function pluginBundleAnalyzer() {
5920
5921
  if (isProd3() || !isUseAnalyzer(config)) {
5921
5922
  return;
5922
5923
  }
5923
- config.dev || (config.dev = {});
5924
+ config.dev ||= {};
5924
5925
  config.dev.writeToDisk = true;
5925
5926
  return config;
5926
5927
  });
@@ -5995,7 +5996,7 @@ var init_rsdoctor = __esm({
5995
5996
  if (registered) {
5996
5997
  return;
5997
5998
  }
5998
- config.plugins || (config.plugins = []);
5999
+ config.plugins ||= [];
5999
6000
  config.plugins.push(new module[pluginName]());
6000
6001
  isAutoRegister = true;
6001
6002
  }
@@ -6380,7 +6381,7 @@ var init_performance = __esm({
6380
6381
  api.modifyRsbuildConfig((rsbuildConfig) => {
6381
6382
  if (rsbuildConfig.performance?.profile) {
6382
6383
  if (!rsbuildConfig.performance?.bundleAnalyze) {
6383
- rsbuildConfig.performance ?? (rsbuildConfig.performance = {});
6384
+ rsbuildConfig.performance ??= {};
6384
6385
  rsbuildConfig.performance.bundleAnalyze = {
6385
6386
  analyzerMode: "disabled",
6386
6387
  generateStatsFile: true
@@ -7047,21 +7048,21 @@ async function init({
7047
7048
  watchFiles(files);
7048
7049
  }
7049
7050
  const { createRsbuild: createRsbuild2 } = await Promise.resolve().then(() => (init_createRsbuild(), createRsbuild_exports));
7050
- config.source || (config.source = {});
7051
+ config.source ||= {};
7051
7052
  config.source.define = {
7052
7053
  ...envs.publicVars,
7053
7054
  ...config.source.define
7054
7055
  };
7055
7056
  if (commonOpts.open && !config.dev?.startUrl) {
7056
- config.dev || (config.dev = {});
7057
+ config.dev ||= {};
7057
7058
  config.dev.startUrl = commonOpts.open;
7058
7059
  }
7059
7060
  if (commonOpts.host) {
7060
- config.server || (config.server = {});
7061
+ config.server ||= {};
7061
7062
  config.server.host = commonOpts.host;
7062
7063
  }
7063
7064
  if (commonOpts.port) {
7064
- config.server || (config.server = {});
7065
+ config.server ||= {};
7065
7066
  config.server.port = commonOpts.port;
7066
7067
  }
7067
7068
  return createRsbuild2({
@@ -7116,6 +7117,7 @@ init_esm();
7116
7117
 
7117
7118
  // src/cli/commands.ts
7118
7119
  init_esm();
7120
+ init_helpers();
7119
7121
  init_init();
7120
7122
  import { existsSync } from "fs";
7121
7123
  import { join as join12 } from "path";
@@ -7134,7 +7136,7 @@ var applyServerOptions = (command) => {
7134
7136
  command.option("-o --open [url]", "open the page in browser on startup").option("--port <port>", "specify a port number for server to listen").option("--host <host>", "specify the host that the server listens to");
7135
7137
  };
7136
7138
  function runCli() {
7137
- program.name("rsbuild").usage("<command> [options]").version("0.7.1");
7139
+ program.name("rsbuild").usage("<command> [options]").version("0.7.2");
7138
7140
  const devCommand = program.command("dev");
7139
7141
  const buildCommand = program.command("build");
7140
7142
  const previewCommand = program.command("preview");
@@ -7168,12 +7170,22 @@ function runCli() {
7168
7170
  previewCommand.description("preview the production build locally").action(async (options) => {
7169
7171
  try {
7170
7172
  const rsbuild = await init({ cliOptions: options });
7171
- if (rsbuild && !existsSync(rsbuild.context.distPath)) {
7172
- throw new Error(
7173
- `The output directory ${color13.yellow(
7174
- rsbuild.context.distPath
7175
- )} does not exist, please build the project before previewing.`
7176
- );
7173
+ if (rsbuild) {
7174
+ const { distPath } = rsbuild.context;
7175
+ if (!existsSync(distPath)) {
7176
+ throw new Error(
7177
+ `The output directory ${color13.yellow(
7178
+ distPath
7179
+ )} does not exist, please build the project before previewing.`
7180
+ );
7181
+ }
7182
+ if (isEmptyDir(distPath)) {
7183
+ throw new Error(
7184
+ `The output directory ${color13.yellow(
7185
+ distPath
7186
+ )} is empty, please build the project before previewing.`
7187
+ );
7188
+ }
7177
7189
  }
7178
7190
  await rsbuild?.preview();
7179
7191
  } catch (err) {
@@ -7215,7 +7227,7 @@ function prepareCli() {
7215
7227
  if (!npm_execpath || npm_execpath.includes("npx-cli.js") || npm_execpath.includes(".bun")) {
7216
7228
  console.log();
7217
7229
  }
7218
- logger18.greet(` ${`Rsbuild v${"0.7.1"}`}
7230
+ logger18.greet(` ${`Rsbuild v${"0.7.2"}`}
7219
7231
  `);
7220
7232
  }
7221
7233
 
@@ -7242,7 +7254,7 @@ init_config();
7242
7254
  init_mergeConfig();
7243
7255
  init_constants();
7244
7256
  import { logger as logger19 } from "@rsbuild/shared";
7245
- var version = "0.7.1";
7257
+ var version = "0.7.2";
7246
7258
  export {
7247
7259
  PLUGIN_CSS_NAME,
7248
7260
  PLUGIN_SWC_NAME,
@@ -23,6 +23,7 @@ export declare const getPublicPathFromChain: (chain: BundlerChain, withSlash?: b
23
23
  */
24
24
  export declare const ensureAbsolutePath: (base: string, filePath: string) => string;
25
25
  export declare const isFileSync: (filePath: string) => boolean | undefined;
26
+ export declare function isEmptyDir(path: string): boolean;
26
27
  /**
27
28
  * Find first already exists file.
28
29
  * @param files - Absolute file paths with extension.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/core",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "description": "The Rspack-based build tool.",
5
5
  "homepage": "https://rsbuild.dev",
6
6
  "bugs": {
@@ -51,7 +51,7 @@
51
51
  "core-js": "~3.36.0",
52
52
  "html-webpack-plugin": "npm:html-rspack-plugin@5.7.2",
53
53
  "postcss": "^8.4.38",
54
- "@rsbuild/shared": "0.7.1"
54
+ "@rsbuild/shared": "0.7.2"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@types/connect": "3.4.38",
@@ -62,7 +62,7 @@
62
62
  "commander": "^12.1.0",
63
63
  "connect": "3.7.0",
64
64
  "connect-history-api-fallback": "^2.0.0",
65
- "css-loader": "7.1.1",
65
+ "css-loader": "7.1.2",
66
66
  "dotenv": "16.4.5",
67
67
  "dotenv-expand": "11.0.6",
68
68
  "fs-extra": "^11.2.0",