@rsbuild/core 1.1.10 → 1.1.12

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.
@@ -0,0 +1 @@
1
+ export = any;
@@ -0,0 +1,371 @@
1
+ (() => {
2
+ var __webpack_modules__ = {
3
+ 46: (module, __unused_webpack_exports, __nccwpck_require__) => {
4
+ (function () {
5
+ "use strict";
6
+ var assign = __nccwpck_require__(715);
7
+ var vary = __nccwpck_require__(443);
8
+ var defaults = {
9
+ origin: "*",
10
+ methods: "GET,HEAD,PUT,PATCH,POST,DELETE",
11
+ preflightContinue: false,
12
+ optionsSuccessStatus: 204,
13
+ };
14
+ function isString(s) {
15
+ return typeof s === "string" || s instanceof String;
16
+ }
17
+ function isOriginAllowed(origin, allowedOrigin) {
18
+ if (Array.isArray(allowedOrigin)) {
19
+ for (var i = 0; i < allowedOrigin.length; ++i) {
20
+ if (isOriginAllowed(origin, allowedOrigin[i])) {
21
+ return true;
22
+ }
23
+ }
24
+ return false;
25
+ } else if (isString(allowedOrigin)) {
26
+ return origin === allowedOrigin;
27
+ } else if (allowedOrigin instanceof RegExp) {
28
+ return allowedOrigin.test(origin);
29
+ } else {
30
+ return !!allowedOrigin;
31
+ }
32
+ }
33
+ function configureOrigin(options, req) {
34
+ var requestOrigin = req.headers.origin,
35
+ headers = [],
36
+ isAllowed;
37
+ if (!options.origin || options.origin === "*") {
38
+ headers.push([{ key: "Access-Control-Allow-Origin", value: "*" }]);
39
+ } else if (isString(options.origin)) {
40
+ headers.push([
41
+ { key: "Access-Control-Allow-Origin", value: options.origin },
42
+ ]);
43
+ headers.push([{ key: "Vary", value: "Origin" }]);
44
+ } else {
45
+ isAllowed = isOriginAllowed(requestOrigin, options.origin);
46
+ headers.push([
47
+ {
48
+ key: "Access-Control-Allow-Origin",
49
+ value: isAllowed ? requestOrigin : false,
50
+ },
51
+ ]);
52
+ headers.push([{ key: "Vary", value: "Origin" }]);
53
+ }
54
+ return headers;
55
+ }
56
+ function configureMethods(options) {
57
+ var methods = options.methods;
58
+ if (methods.join) {
59
+ methods = options.methods.join(",");
60
+ }
61
+ return { key: "Access-Control-Allow-Methods", value: methods };
62
+ }
63
+ function configureCredentials(options) {
64
+ if (options.credentials === true) {
65
+ return { key: "Access-Control-Allow-Credentials", value: "true" };
66
+ }
67
+ return null;
68
+ }
69
+ function configureAllowedHeaders(options, req) {
70
+ var allowedHeaders = options.allowedHeaders || options.headers;
71
+ var headers = [];
72
+ if (!allowedHeaders) {
73
+ allowedHeaders = req.headers["access-control-request-headers"];
74
+ headers.push([
75
+ { key: "Vary", value: "Access-Control-Request-Headers" },
76
+ ]);
77
+ } else if (allowedHeaders.join) {
78
+ allowedHeaders = allowedHeaders.join(",");
79
+ }
80
+ if (allowedHeaders && allowedHeaders.length) {
81
+ headers.push([
82
+ { key: "Access-Control-Allow-Headers", value: allowedHeaders },
83
+ ]);
84
+ }
85
+ return headers;
86
+ }
87
+ function configureExposedHeaders(options) {
88
+ var headers = options.exposedHeaders;
89
+ if (!headers) {
90
+ return null;
91
+ } else if (headers.join) {
92
+ headers = headers.join(",");
93
+ }
94
+ if (headers && headers.length) {
95
+ return { key: "Access-Control-Expose-Headers", value: headers };
96
+ }
97
+ return null;
98
+ }
99
+ function configureMaxAge(options) {
100
+ var maxAge =
101
+ (typeof options.maxAge === "number" || options.maxAge) &&
102
+ options.maxAge.toString();
103
+ if (maxAge && maxAge.length) {
104
+ return { key: "Access-Control-Max-Age", value: maxAge };
105
+ }
106
+ return null;
107
+ }
108
+ function applyHeaders(headers, res) {
109
+ for (var i = 0, n = headers.length; i < n; i++) {
110
+ var header = headers[i];
111
+ if (header) {
112
+ if (Array.isArray(header)) {
113
+ applyHeaders(header, res);
114
+ } else if (header.key === "Vary" && header.value) {
115
+ vary(res, header.value);
116
+ } else if (header.value) {
117
+ res.setHeader(header.key, header.value);
118
+ }
119
+ }
120
+ }
121
+ }
122
+ function cors(options, req, res, next) {
123
+ var headers = [],
124
+ method =
125
+ req.method && req.method.toUpperCase && req.method.toUpperCase();
126
+ if (method === "OPTIONS") {
127
+ headers.push(configureOrigin(options, req));
128
+ headers.push(configureCredentials(options, req));
129
+ headers.push(configureMethods(options, req));
130
+ headers.push(configureAllowedHeaders(options, req));
131
+ headers.push(configureMaxAge(options, req));
132
+ headers.push(configureExposedHeaders(options, req));
133
+ applyHeaders(headers, res);
134
+ if (options.preflightContinue) {
135
+ next();
136
+ } else {
137
+ res.statusCode = options.optionsSuccessStatus;
138
+ res.setHeader("Content-Length", "0");
139
+ res.end();
140
+ }
141
+ } else {
142
+ headers.push(configureOrigin(options, req));
143
+ headers.push(configureCredentials(options, req));
144
+ headers.push(configureExposedHeaders(options, req));
145
+ applyHeaders(headers, res);
146
+ next();
147
+ }
148
+ }
149
+ function middlewareWrapper(o) {
150
+ var optionsCallback = null;
151
+ if (typeof o === "function") {
152
+ optionsCallback = o;
153
+ } else {
154
+ optionsCallback = function (req, cb) {
155
+ cb(null, o);
156
+ };
157
+ }
158
+ return function corsMiddleware(req, res, next) {
159
+ optionsCallback(req, function (err, options) {
160
+ if (err) {
161
+ next(err);
162
+ } else {
163
+ var corsOptions = assign({}, defaults, options);
164
+ var originCallback = null;
165
+ if (
166
+ corsOptions.origin &&
167
+ typeof corsOptions.origin === "function"
168
+ ) {
169
+ originCallback = corsOptions.origin;
170
+ } else if (corsOptions.origin) {
171
+ originCallback = function (origin, cb) {
172
+ cb(null, corsOptions.origin);
173
+ };
174
+ }
175
+ if (originCallback) {
176
+ originCallback(req.headers.origin, function (err2, origin) {
177
+ if (err2 || !origin) {
178
+ next(err2);
179
+ } else {
180
+ corsOptions.origin = origin;
181
+ cors(corsOptions, req, res, next);
182
+ }
183
+ });
184
+ } else {
185
+ next();
186
+ }
187
+ }
188
+ });
189
+ };
190
+ }
191
+ module.exports = middlewareWrapper;
192
+ })();
193
+ },
194
+ 715: (module) => {
195
+ "use strict";
196
+ /*
197
+ object-assign
198
+ (c) Sindre Sorhus
199
+ @license MIT
200
+ */ var getOwnPropertySymbols = Object.getOwnPropertySymbols;
201
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
202
+ var propIsEnumerable = Object.prototype.propertyIsEnumerable;
203
+ function toObject(val) {
204
+ if (val === null || val === undefined) {
205
+ throw new TypeError(
206
+ "Object.assign cannot be called with null or undefined",
207
+ );
208
+ }
209
+ return Object(val);
210
+ }
211
+ function shouldUseNative() {
212
+ try {
213
+ if (!Object.assign) {
214
+ return false;
215
+ }
216
+ var test1 = new String("abc");
217
+ test1[5] = "de";
218
+ if (Object.getOwnPropertyNames(test1)[0] === "5") {
219
+ return false;
220
+ }
221
+ var test2 = {};
222
+ for (var i = 0; i < 10; i++) {
223
+ test2["_" + String.fromCharCode(i)] = i;
224
+ }
225
+ var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
226
+ return test2[n];
227
+ });
228
+ if (order2.join("") !== "0123456789") {
229
+ return false;
230
+ }
231
+ var test3 = {};
232
+ "abcdefghijklmnopqrst".split("").forEach(function (letter) {
233
+ test3[letter] = letter;
234
+ });
235
+ if (
236
+ Object.keys(Object.assign({}, test3)).join("") !==
237
+ "abcdefghijklmnopqrst"
238
+ ) {
239
+ return false;
240
+ }
241
+ return true;
242
+ } catch (err) {
243
+ return false;
244
+ }
245
+ }
246
+ module.exports = shouldUseNative()
247
+ ? Object.assign
248
+ : function (target, source) {
249
+ var from;
250
+ var to = toObject(target);
251
+ var symbols;
252
+ for (var s = 1; s < arguments.length; s++) {
253
+ from = Object(arguments[s]);
254
+ for (var key in from) {
255
+ if (hasOwnProperty.call(from, key)) {
256
+ to[key] = from[key];
257
+ }
258
+ }
259
+ if (getOwnPropertySymbols) {
260
+ symbols = getOwnPropertySymbols(from);
261
+ for (var i = 0; i < symbols.length; i++) {
262
+ if (propIsEnumerable.call(from, symbols[i])) {
263
+ to[symbols[i]] = from[symbols[i]];
264
+ }
265
+ }
266
+ }
267
+ }
268
+ return to;
269
+ };
270
+ },
271
+ 443: (module) => {
272
+ "use strict";
273
+ /*!
274
+ * vary
275
+ * Copyright(c) 2014-2017 Douglas Christopher Wilson
276
+ * MIT Licensed
277
+ */ module.exports = vary;
278
+ module.exports.append = append;
279
+ var FIELD_NAME_REGEXP = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
280
+ function append(header, field) {
281
+ if (typeof header !== "string") {
282
+ throw new TypeError("header argument is required");
283
+ }
284
+ if (!field) {
285
+ throw new TypeError("field argument is required");
286
+ }
287
+ var fields = !Array.isArray(field) ? parse(String(field)) : field;
288
+ for (var j = 0; j < fields.length; j++) {
289
+ if (!FIELD_NAME_REGEXP.test(fields[j])) {
290
+ throw new TypeError(
291
+ "field argument contains an invalid header name",
292
+ );
293
+ }
294
+ }
295
+ if (header === "*") {
296
+ return header;
297
+ }
298
+ var val = header;
299
+ var vals = parse(header.toLowerCase());
300
+ if (fields.indexOf("*") !== -1 || vals.indexOf("*") !== -1) {
301
+ return "*";
302
+ }
303
+ for (var i = 0; i < fields.length; i++) {
304
+ var fld = fields[i].toLowerCase();
305
+ if (vals.indexOf(fld) === -1) {
306
+ vals.push(fld);
307
+ val = val ? val + ", " + fields[i] : fields[i];
308
+ }
309
+ }
310
+ return val;
311
+ }
312
+ function parse(header) {
313
+ var end = 0;
314
+ var list = [];
315
+ var start = 0;
316
+ for (var i = 0, len = header.length; i < len; i++) {
317
+ switch (header.charCodeAt(i)) {
318
+ case 32:
319
+ if (start === end) {
320
+ start = end = i + 1;
321
+ }
322
+ break;
323
+ case 44:
324
+ list.push(header.substring(start, end));
325
+ start = end = i + 1;
326
+ break;
327
+ default:
328
+ end = i + 1;
329
+ break;
330
+ }
331
+ }
332
+ list.push(header.substring(start, end));
333
+ return list;
334
+ }
335
+ function vary(res, field) {
336
+ if (!res || !res.getHeader || !res.setHeader) {
337
+ throw new TypeError("res argument is required");
338
+ }
339
+ var val = res.getHeader("Vary") || "";
340
+ var header = Array.isArray(val) ? val.join(", ") : String(val);
341
+ if ((val = append(header, field))) {
342
+ res.setHeader("Vary", val);
343
+ }
344
+ }
345
+ },
346
+ };
347
+ var __webpack_module_cache__ = {};
348
+ function __nccwpck_require__(moduleId) {
349
+ var cachedModule = __webpack_module_cache__[moduleId];
350
+ if (cachedModule !== undefined) {
351
+ return cachedModule.exports;
352
+ }
353
+ var module = (__webpack_module_cache__[moduleId] = { exports: {} });
354
+ var threw = true;
355
+ try {
356
+ __webpack_modules__[moduleId](
357
+ module,
358
+ module.exports,
359
+ __nccwpck_require__,
360
+ );
361
+ threw = false;
362
+ } finally {
363
+ if (threw) delete __webpack_module_cache__[moduleId];
364
+ }
365
+ return module.exports;
366
+ }
367
+ if (typeof __nccwpck_require__ !== "undefined")
368
+ __nccwpck_require__.ab = __dirname + "/";
369
+ var __webpack_exports__ = __nccwpck_require__(46);
370
+ module.exports = __webpack_exports__;
371
+ })();
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2013 Troy Goode <troygoode@gmail.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ 'Software'), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1 @@
1
+ {"name":"cors","author":"Troy Goode <troygoode@gmail.com> (https://github.com/troygoode/)","version":"2.8.5","license":"MIT","types":"index.d.ts","type":"commonjs"}
@@ -1,22 +1,22 @@
1
1
  (() => {
2
2
  var __webpack_modules__ = {
3
- 3293: (module, __unused_webpack_exports, __nccwpck_require__) => {
3
+ 2174: (module, __unused_webpack_exports, __nccwpck_require__) => {
4
4
  "use strict";
5
- const loader = __nccwpck_require__(7956);
5
+ const loader = __nccwpck_require__(7268);
6
6
  module.exports = loader.default;
7
7
  module.exports.defaultGetLocalIdent =
8
- __nccwpck_require__(6563).defaultGetLocalIdent;
8
+ __nccwpck_require__(8547).defaultGetLocalIdent;
9
9
  },
10
- 7956: (__unused_webpack_module, exports, __nccwpck_require__) => {
10
+ 7268: (__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__(7337));
16
16
  var _semver = { satisfies: () => true };
17
- var _options = _interopRequireDefault(__nccwpck_require__(3818));
18
- var _plugins = __nccwpck_require__(2241);
19
- var _utils = __nccwpck_require__(6563);
17
+ var _options = _interopRequireDefault(__nccwpck_require__(1538));
18
+ var _plugins = __nccwpck_require__(5640);
19
+ var _utils = __nccwpck_require__(8547);
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
- 2241: (__unused_webpack_module, exports, __nccwpck_require__) => {
246
+ 5640: (__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__(2760),
268
+ __nccwpck_require__(4017),
269
269
  );
270
270
  var _postcssIcssParser = _interopRequireDefault(
271
- __nccwpck_require__(4123),
271
+ __nccwpck_require__(7012),
272
272
  );
273
- var _postcssUrlParser = _interopRequireDefault(__nccwpck_require__(644));
273
+ var _postcssUrlParser = _interopRequireDefault(__nccwpck_require__(2339));
274
274
  function _interopRequireDefault(obj) {
275
275
  return obj && obj.__esModule ? obj : { default: obj };
276
276
  }
277
277
  },
278
- 4123: (__unused_webpack_module, exports, __nccwpck_require__) => {
278
+ 7012: (__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__(4508);
283
- var _utils = __nccwpck_require__(6563);
283
+ var _utils = __nccwpck_require__(8547);
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
- 2760: (__unused_webpack_module, exports, __nccwpck_require__) => {
382
+ 4017: (__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__(6563);
389
+ var _utils = __nccwpck_require__(8547);
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
- 644: (__unused_webpack_module, exports, __nccwpck_require__) => {
694
+ 2339: (__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__(6563);
701
+ var _utils = __nccwpck_require__(8547);
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
- 6563: (__unused_webpack_module, exports, __nccwpck_require__) => {
1044
+ 8547: (__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;
@@ -7968,7 +7968,7 @@
7968
7968
  "use strict";
7969
7969
  module.exports = require("util");
7970
7970
  },
7971
- 3818: (module) => {
7971
+ 1538: (module) => {
7972
7972
  "use strict";
7973
7973
  module.exports = JSON.parse(
7974
7974
  '{"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"}',
@@ -8003,6 +8003,6 @@
8003
8003
  }
8004
8004
  if (typeof __nccwpck_require__ !== "undefined")
8005
8005
  __nccwpck_require__.ab = __dirname + "/";
8006
- var __webpack_exports__ = __nccwpck_require__(3293);
8006
+ var __webpack_exports__ = __nccwpck_require__(2174);
8007
8007
  module.exports = __webpack_exports__;
8008
8008
  })();
@@ -1,8 +1,8 @@
1
1
  (() => {
2
2
  var __webpack_modules__ = {
3
- 326: (module, __unused_webpack_exports, __nccwpck_require__) => {
3
+ 815: (module, __unused_webpack_exports, __nccwpck_require__) => {
4
4
  "use strict";
5
- const { HtmlWebpackChildCompiler } = __nccwpck_require__(401);
5
+ const { HtmlWebpackChildCompiler } = __nccwpck_require__(573);
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
- 401: (module) => {
307
+ 573: (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
- 809: (module) => {
476
+ 987: (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
- 781: (module) => {
495
+ 866: (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
- 992: (module, __unused_webpack_exports, __nccwpck_require__) => {
516
+ 58: (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
- 620: (module) => {
542
+ 961: (module) => {
543
543
  const voidTags = [
544
544
  "area",
545
545
  "base",
@@ -607,19 +607,19 @@
607
607
  htmlTagObjectToString,
608
608
  };
609
609
  },
610
- 522: (module, __unused_webpack_exports, __nccwpck_require__) => {
610
+ 918: (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__(326);
616
+ const { CachedChildCompilation } = __nccwpck_require__(815);
617
617
  const { createHtmlTagObject, htmlTagObjectToString, HtmlTagArray } =
618
- __nccwpck_require__(620);
619
- const prettyError = __nccwpck_require__(781);
620
- const chunkSorter = __nccwpck_require__(809);
618
+ __nccwpck_require__(961);
619
+ const prettyError = __nccwpck_require__(866);
620
+ const chunkSorter = __nccwpck_require__(987);
621
621
  const getHtmlRspackPluginHooks =
622
- __nccwpck_require__(992).getHtmlRspackPluginHooks;
622
+ __nccwpck_require__(58).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__(522);
1581
+ var __webpack_exports__ = __nccwpck_require__(918);
1582
1582
  module.exports = __webpack_exports__;
1583
1583
  })();
@@ -1,17 +1,17 @@
1
1
  (() => {
2
2
  "use strict";
3
3
  var __webpack_modules__ = {
4
- 57: (module, __unused_webpack_exports, __nccwpck_require__) => {
5
- module.exports = __nccwpck_require__(505)["default"];
4
+ 184: (module, __unused_webpack_exports, __nccwpck_require__) => {
5
+ module.exports = __nccwpck_require__(526)["default"];
6
6
  },
7
- 505: (__unused_webpack_module, exports, __nccwpck_require__) => {
7
+ 526: (__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__(337));
13
- var _options = _interopRequireDefault(__nccwpck_require__(268));
14
- var _utils = __nccwpck_require__(321);
13
+ var _options = _interopRequireDefault(__nccwpck_require__(612));
14
+ var _utils = __nccwpck_require__(922);
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
- 321: (module, exports, __nccwpck_require__) => {
192
+ 922: (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
- 268: (module) => {
694
+ 612: (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__(57);
739
+ var __webpack_exports__ = __nccwpck_require__(184);
740
740
  module.exports = __webpack_exports__;
741
741
  })();
@@ -1,7 +1,7 @@
1
1
  (() => {
2
2
  "use strict";
3
3
  var __webpack_modules__ = {
4
- 500: (__unused_webpack_module, exports, __nccwpck_require__) => {
4
+ 44: (__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
- 407: (__unused_webpack_module, exports, __nccwpck_require__) => {
123
+ 469: (__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__(500);
133
+ const helpers_1 = __nccwpck_require__(44);
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__(407);
315
+ const hooks_1 = __nccwpck_require__(469);
316
316
  Object.defineProperty(exports, "getCompilerHooks", {
317
317
  enumerable: true,
318
318
  get: function () {
@@ -1,24 +1,19 @@
1
1
  function resolveFileName(stats) {
2
- // Get the real source file path with stats.moduleIdentifier.
3
- // e.g. moduleIdentifier is "builtin:react-refresh-loader!/Users/x/src/App.jsx"
4
2
  if (stats.moduleIdentifier) {
5
3
  const regex = /(?:\!|^)([^!]+)$/;
6
4
  const matched = stats.moduleIdentifier.match(regex);
7
5
  if (matched) {
8
6
  const fileName = matched.pop();
9
- if (fileName) // add default column add lines for linking
10
- return `File: ${fileName}:1:1\n`;
7
+ if (fileName) return `File: ${fileName}:1:1\n`;
11
8
  }
12
9
  }
13
- // fallback to file or moduleName if moduleIdentifier parse failed
14
10
  const file = stats.file || stats.moduleName;
15
11
  return file ? `File: ${file}\n` : '';
16
12
  }
17
13
  function resolveModuleTrace(stats) {
18
14
  let traceStr = '';
19
15
  if (stats.moduleTrace) {
20
- for (const trace of stats.moduleTrace)if (trace.originName) // TODO: missing moduleTrace.dependencies[].loc in rspack
21
- traceStr += `\n @ ${trace.originName}`;
16
+ for (const trace of stats.moduleTrace)if (trace.originName) traceStr += `\n @ ${trace.originName}`;
22
17
  }
23
18
  return traceStr;
24
19
  }
@@ -30,11 +25,9 @@ function hintUnknownFiles(message) {
30
25
  if (/File: .+\.styl(us)?/.test(message)) return message.replace(hint, 'To enable support for Stylus, use "@rsbuild/plugin-stylus".');
31
26
  return message;
32
27
  }
33
- // Cleans up Rspack error messages.
34
28
  function formatMessage(stats, verbose) {
35
29
  let lines = [];
36
30
  let message;
37
- // Stats error object
38
31
  if ('object' == typeof stats) {
39
32
  const fileName = resolveFileName(stats);
40
33
  const mainMessage = stats.message;
@@ -45,9 +38,7 @@ function formatMessage(stats, verbose) {
45
38
  } else message = stats;
46
39
  message = hintUnknownFiles(message);
47
40
  lines = message.split('\n');
48
- // Remove duplicated newlines
49
41
  lines = lines.filter((line, index, arr)=>0 === index || '' !== line.trim() || line.trim() !== arr[index - 1].trim());
50
- // Reassemble the message
51
42
  message = lines.join('\n');
52
43
  const innerError = '-- inner error --';
53
44
  if (!verbose && message.includes(innerError)) message = message.split(innerError)[0];
@@ -75,16 +66,13 @@ function formatURL(param) {
75
66
  url.searchParams.append('compilationId', compilationId);
76
67
  return url.toString();
77
68
  }
78
- // compatible with IE11
79
69
  const colon = -1 === protocol.indexOf(':') ? ':' : '';
80
70
  return `${protocol}${colon}//${hostname}:${port}${pathname}`;
81
71
  }
82
- // Remember some state related to hot module replacement.
83
72
  let isFirstCompilation = true;
84
73
  let lastCompilationHash = null;
85
74
  let hasCompileErrors = false;
86
75
  function clearOutdatedErrors() {
87
- // Clean up outdated compile errors, if any.
88
76
  if (console.clear && hasCompileErrors) console.clear();
89
77
  }
90
78
  let createOverlay;
@@ -93,16 +81,13 @@ const registerOverlay = (createFn, clearFn)=>{
93
81
  createOverlay = createFn;
94
82
  clearOverlay = clearFn;
95
83
  };
96
- // Successful compilation.
97
84
  function handleSuccess() {
98
85
  clearOutdatedErrors();
99
86
  const isHotUpdate = !isFirstCompilation;
100
87
  isFirstCompilation = false;
101
88
  hasCompileErrors = false;
102
- // Attempt to apply hot updates or reload.
103
89
  if (isHotUpdate) tryApplyUpdates();
104
90
  }
105
- // Compilation with warnings (e.g. ESLint).
106
91
  function handleWarnings(warnings) {
107
92
  clearOutdatedErrors();
108
93
  const isHotUpdate = !isFirstCompilation;
@@ -119,10 +104,8 @@ function handleWarnings(warnings) {
119
104
  }
120
105
  console.warn(formatted.warnings[i]);
121
106
  }
122
- // Attempt to apply hot updates or reload.
123
107
  if (isHotUpdate) tryApplyUpdates();
124
108
  }
125
- // Compilation with errors (e.g. syntax error or missing modules).
126
109
  function handleErrors(errors) {
127
110
  clearOutdatedErrors();
128
111
  isFirstCompilation = false;
@@ -131,23 +114,16 @@ function handleErrors(errors) {
131
114
  errors,
132
115
  warnings: []
133
116
  });
134
- // Also log them to the console.
135
117
  for (const error of formatted.errors)console.error(error);
136
118
  if (createOverlay) createOverlay(formatted.errors);
137
119
  }
138
- // __webpack_hash__ is the hash of the current compilation.
139
- // It's a global variable injected by Rspack.
140
120
  const isUpdateAvailable = ()=>lastCompilationHash !== __webpack_hash__;
141
- // Attempt to update code on the fly, fall back to a hard reload.
142
121
  function tryApplyUpdates() {
143
- // detect is there a newer version of this code available
144
122
  if (!isUpdateAvailable()) return;
145
123
  if (!import.meta.webpackHot) {
146
- // HotModuleReplacementPlugin is not in Rspack configuration.
147
124
  reloadPage();
148
125
  return;
149
126
  }
150
- // Rspack disallows updates in other states.
151
127
  if ('idle' !== import.meta.webpackHot.status()) return;
152
128
  const handleApplyUpdates = (err, updatedModules)=>{
153
129
  const forcedReload = err || !updatedModules;
@@ -156,16 +132,13 @@ function tryApplyUpdates() {
156
132
  reloadPage();
157
133
  return;
158
134
  }
159
- if (isUpdateAvailable()) // While we were updating, there was a new update! Do it again.
160
- tryApplyUpdates();
135
+ if (isUpdateAvailable()) tryApplyUpdates();
161
136
  };
162
- // https://rspack.dev/api/runtime-api/module-variables#importmetawebpackhot
163
137
  import.meta.webpackHot.check(true).then((updatedModules)=>handleApplyUpdates(null, updatedModules), (err)=>handleApplyUpdates(err, null));
164
138
  }
165
139
  let connection = null;
166
140
  let reconnectCount = 0;
167
141
  function onOpen() {
168
- // Notify users that the HMR has successfully connected.
169
142
  console.info('[HMR] connected.');
170
143
  }
171
144
  function onMessage(e) {
@@ -173,7 +146,6 @@ function onMessage(e) {
173
146
  if (message.compilationId && message.compilationId !== compilationId) return;
174
147
  switch(message.type){
175
148
  case 'hash':
176
- // Update the last compilation hash
177
149
  lastCompilationHash = message.data;
178
150
  if (clearOverlay && isUpdateAvailable()) clearOverlay();
179
151
  break;
@@ -181,7 +153,6 @@ function onMessage(e) {
181
153
  case 'ok':
182
154
  handleSuccess();
183
155
  break;
184
- // Triggered when static files changed
185
156
  case 'static-changed':
186
157
  case 'content-changed':
187
158
  reloadPage();
@@ -205,7 +176,6 @@ function onClose() {
205
176
  reconnectCount++;
206
177
  setTimeout(connect, 1000 * 1.5 ** reconnectCount);
207
178
  }
208
- // Establishing a WebSocket connection with the server.
209
179
  function connect() {
210
180
  const { location } = self;
211
181
  const { host, port, path, protocol } = config;
@@ -217,9 +187,7 @@ function connect() {
217
187
  });
218
188
  connection = new WebSocket(socketUrl);
219
189
  connection.addEventListener('open', onOpen);
220
- // Attempt to reconnect after disconnection
221
190
  connection.addEventListener('close', onClose);
222
- // Handle messages from the server.
223
191
  connection.addEventListener('message', onMessage);
224
192
  }
225
193
  function removeListeners() {
@@ -191,7 +191,6 @@ class ErrorOverlay extends HTMLElement {
191
191
  root.innerHTML = overlayTemplate;
192
192
  linkedText(root, '.content', stripAnsi(message.join('\n')).trim());
193
193
  null === (_root_querySelector = root.querySelector('.close')) || void 0 === _root_querySelector || _root_querySelector.addEventListener('click', this.close);
194
- // close overlay when click outside
195
194
  this.addEventListener('click', this.close);
196
195
  root.querySelector('.container').addEventListener('click', (e)=>{
197
196
  e.stopPropagation();
@@ -210,8 +209,6 @@ function createOverlay(err) {
210
209
  document.body.appendChild(new ErrorOverlay(err));
211
210
  }
212
211
  function clearOverlay() {
213
- // use NodeList's forEach api instead of dom.iterable
214
- // biome-ignore lint/complexity/noForEach: <explanation>
215
212
  document.querySelectorAll(overlayId).forEach((n)=>n.close());
216
213
  }
217
214
  if ('undefined' != typeof document) (0, __WEBPACK_EXTERNAL_MODULE__hmr__.registerOverlay)(createOverlay, clearOverlay);
package/dist/index.cjs CHANGED
@@ -280,6 +280,10 @@ var __webpack_modules__ = {
280
280
  "use strict";
281
281
  module.exports = import("../compiled/connect/index.js");
282
282
  },
283
+ "../../compiled/cors/index.js": function(module) {
284
+ "use strict";
285
+ module.exports = import("../compiled/cors/index.js");
286
+ },
283
287
  "../../compiled/http-proxy-middleware/index.js": function(module) {
284
288
  "use strict";
285
289
  module.exports = import("../compiled/http-proxy-middleware/index.js");
@@ -2101,7 +2105,8 @@ var __webpack_exports__ = {};
2101
2105
  htmlFallback: 'index',
2102
2106
  compress: !0,
2103
2107
  printUrls: !0,
2104
- strictPort: !1
2108
+ strictPort: !1,
2109
+ cors: !0
2105
2110
  }), getDefaultSourceConfig = ()=>({
2106
2111
  alias: {},
2107
2112
  define: {},
@@ -2736,7 +2741,7 @@ var __webpack_exports__ = {};
2736
2741
  async function createContext(options, userConfig, bundlerType) {
2737
2742
  let { cwd } = options, rootPath = userConfig.root ? getAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = (0, external_node_path_.join)(rootPath, 'node_modules', '.cache');
2738
2743
  return {
2739
- version: "1.1.10",
2744
+ version: "1.1.12",
2740
2745
  rootPath,
2741
2746
  distPath: '',
2742
2747
  cachePath,
@@ -2938,7 +2943,10 @@ var __webpack_exports__ = {};
2938
2943
  javascript: {
2939
2944
  exportsPresence: 'error'
2940
2945
  }
2941
- }), isDev && config.dev.hmr && 'web' === target && chain.plugin(CHAIN_ID.PLUGIN.HMR).use(bundler.HotModuleReplacementPlugin), 'development' === env && chain.output.devtoolModuleFilenameTemplate((info)=>external_node_path_default().resolve(info.absoluteResourcePath).replace(/\\/g, '/')), process.env.RSPACK_CONFIG_VALIDATE ||= 'loose-unrecognized-keys', process.env.WATCHPACK_WATCHER_LIMIT ||= '20';
2946
+ }), isDev && config.dev.hmr && 'web' === target && chain.plugin(CHAIN_ID.PLUGIN.HMR).use(bundler.HotModuleReplacementPlugin), 'development' === env && chain.output.devtoolModuleFilenameTemplate((info)=>external_node_path_default().resolve(info.absoluteResourcePath).replace(/\\/g, '/')), process.env.RSPACK_CONFIG_VALIDATE ||= 'loose-unrecognized-keys', process.env.WATCHPACK_WATCHER_LIMIT ||= '20', process.env.EXPERIMENTAL_RSPACK_INCREMENTAL && chain.experiments({
2947
+ ...chain.get('experiments'),
2948
+ incremental: isDev
2949
+ });
2942
2950
  });
2943
2951
  }
2944
2952
  }), isUseAnalyzer = (config)=>{
@@ -5433,7 +5441,11 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
5433
5441
  }, setupServerHooks = (compiler, hookCallbacks)=>{
5434
5442
  if (isNodeCompiler(compiler)) return;
5435
5443
  let { compile, invalid, done } = compiler.hooks;
5436
- compile.tap('rsbuild-dev-server', ()=>hookCallbacks.onInvalid(getCompilationId(compiler))), invalid.tap('rsbuild-dev-server', ()=>hookCallbacks.onInvalid(getCompilationId(compiler))), done.tap('rsbuild-dev-server', hookCallbacks.onDone);
5444
+ compile.tap('rsbuild-dev-server', ()=>{
5445
+ hookCallbacks.onInvalid(getCompilationId(compiler));
5446
+ }), invalid.tap('rsbuild-dev-server', (fileName)=>{
5447
+ hookCallbacks.onInvalid(getCompilationId(compiler), fileName);
5448
+ }), done.tap('rsbuild-dev-server', hookCallbacks.onDone);
5437
5449
  }, getDevMiddleware = async (multiCompiler)=>{
5438
5450
  let { default: rsbuildDevMiddleware } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "../../compiled/rsbuild-dev-middleware/index.js"));
5439
5451
  return (options)=>{
@@ -5633,7 +5645,14 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
5633
5645
  publicPath: '/',
5634
5646
  stats: !1,
5635
5647
  callbacks: {
5636
- onInvalid: (compilationId)=>{
5648
+ onInvalid: (compilationId, fileName)=>{
5649
+ if ('string' == typeof fileName && HTML_REGEX.test(fileName)) {
5650
+ this.socketServer.sockWrite({
5651
+ type: 'content-changed',
5652
+ compilationId
5653
+ });
5654
+ return;
5655
+ }
5637
5656
  this.socketServer.sockWrite({
5638
5657
  type: 'invalid',
5639
5658
  compilationId
@@ -6113,7 +6132,11 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6113
6132
  let confHeaders = server.headers;
6114
6133
  if (confHeaders) for (let [key, value] of Object.entries(confHeaders))res.setHeader(key, value);
6115
6134
  next();
6116
- }), server.proxy) {
6135
+ }), server.cors) {
6136
+ let { default: corsMiddleware } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "../../compiled/cors/index.js"));
6137
+ middlewares.push(corsMiddleware('boolean' == typeof server.cors ? {} : server.cors));
6138
+ }
6139
+ if (server.proxy) {
6117
6140
  let { middlewares: proxyMiddlewares, upgrade } = await createProxyMiddleware(server.proxy);
6118
6141
  for (let middleware of (upgradeEvents.push(upgrade), proxyMiddlewares))middlewares.push(middleware);
6119
6142
  }
@@ -6497,13 +6520,17 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6497
6520
  this.app = app, await this.applyDefaultMiddlewares();
6498
6521
  }
6499
6522
  async applyDefaultMiddlewares() {
6500
- let { headers, proxy, historyApiFallback, compress, base } = this.options.serverConfig;
6523
+ let { headers, proxy, historyApiFallback, compress, base, cors } = this.options.serverConfig;
6501
6524
  if ('verbose' === rslog_index_js_namespaceObject.logger.level && this.middlewares.use(await getRequestLoggerMiddleware()), compress && this.middlewares.use(gzipMiddleware({
6502
6525
  level: 6
6503
6526
  })), headers && this.middlewares.use((_req, res, next)=>{
6504
6527
  for (let [key, value] of Object.entries(headers))res.setHeader(key, value);
6505
6528
  next();
6506
- }), proxy) {
6529
+ }), cors) {
6530
+ let { default: corsMiddleware } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "../../compiled/cors/index.js"));
6531
+ this.middlewares.use(corsMiddleware('boolean' == typeof cors ? {} : cors));
6532
+ }
6533
+ if (proxy) {
6507
6534
  let { middlewares, upgrade } = await createProxyMiddleware(proxy);
6508
6535
  for (let middleware of middlewares)this.middlewares.use(middleware);
6509
6536
  this.app.on('upgrade', upgrade);
@@ -7045,11 +7072,11 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
7045
7072
  }
7046
7073
  }(), process.title = 'rsbuild-node';
7047
7074
  let { npm_execpath } = process.env;
7048
- (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), rslog_index_js_namespaceObject.logger.greet(` Rsbuild v1.1.10\n`);
7075
+ (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), rslog_index_js_namespaceObject.logger.greet(` Rsbuild v1.1.12\n`);
7049
7076
  }();
7050
7077
  try {
7051
7078
  !function() {
7052
- program.name('rsbuild').usage('<command> [options]').version("1.1.10");
7079
+ program.name('rsbuild').usage('<command> [options]').version("1.1.12");
7053
7080
  let devCommand = program.command('dev'), buildCommand = program.command('build'), previewCommand = program.command('preview'), inspectCommand = program.command('inspect');
7054
7081
  [
7055
7082
  devCommand,
@@ -7108,7 +7135,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
7108
7135
  rslog_index_js_namespaceObject.logger.error('Failed to start Rsbuild CLI.'), rslog_index_js_namespaceObject.logger.error(err);
7109
7136
  }
7110
7137
  }
7111
- let src_rslib_entry_version = "1.1.10";
7138
+ let src_rslib_entry_version = "1.1.12";
7112
7139
  })();
7113
7140
  var __webpack_export_target__ = exports;
7114
7141
  for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
package/dist/index.js CHANGED
@@ -2011,7 +2011,8 @@ let config_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module__.createRequire)(
2011
2011
  htmlFallback: 'index',
2012
2012
  compress: !0,
2013
2013
  printUrls: !0,
2014
- strictPort: !1
2014
+ strictPort: !1,
2015
+ cors: !0
2015
2016
  }), getDefaultSourceConfig = ()=>({
2016
2017
  alias: {},
2017
2018
  define: {},
@@ -2646,7 +2647,7 @@ async function updateEnvironmentContext(context, configs) {
2646
2647
  async function createContext(options, userConfig, bundlerType) {
2647
2648
  let { cwd } = options, rootPath = userConfig.root ? getAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = (0, external_node_path_.join)(rootPath, 'node_modules', '.cache');
2648
2649
  return {
2649
- version: "1.1.10",
2650
+ version: "1.1.12",
2650
2651
  rootPath,
2651
2652
  distPath: '',
2652
2653
  cachePath,
@@ -2848,7 +2849,10 @@ let pluginAppIcon = ()=>({
2848
2849
  javascript: {
2849
2850
  exportsPresence: 'error'
2850
2851
  }
2851
- }), isDev && config.dev.hmr && 'web' === target && chain.plugin(CHAIN_ID.PLUGIN.HMR).use(bundler.HotModuleReplacementPlugin), 'development' === env && chain.output.devtoolModuleFilenameTemplate((info)=>external_node_path_.default.resolve(info.absoluteResourcePath).replace(/\\/g, '/')), process.env.RSPACK_CONFIG_VALIDATE ||= 'loose-unrecognized-keys', process.env.WATCHPACK_WATCHER_LIMIT ||= '20';
2852
+ }), isDev && config.dev.hmr && 'web' === target && chain.plugin(CHAIN_ID.PLUGIN.HMR).use(bundler.HotModuleReplacementPlugin), 'development' === env && chain.output.devtoolModuleFilenameTemplate((info)=>external_node_path_.default.resolve(info.absoluteResourcePath).replace(/\\/g, '/')), process.env.RSPACK_CONFIG_VALIDATE ||= 'loose-unrecognized-keys', process.env.WATCHPACK_WATCHER_LIMIT ||= '20', process.env.EXPERIMENTAL_RSPACK_INCREMENTAL && chain.experiments({
2853
+ ...chain.get('experiments'),
2854
+ incremental: isDev
2855
+ });
2852
2856
  });
2853
2857
  }
2854
2858
  }), isUseAnalyzer = (config)=>{
@@ -5329,7 +5333,11 @@ let isClientCompiler = (compiler)=>{
5329
5333
  }, setupServerHooks = (compiler, hookCallbacks)=>{
5330
5334
  if (isNodeCompiler(compiler)) return;
5331
5335
  let { compile, invalid, done } = compiler.hooks;
5332
- compile.tap('rsbuild-dev-server', ()=>hookCallbacks.onInvalid(getCompilationId(compiler))), invalid.tap('rsbuild-dev-server', ()=>hookCallbacks.onInvalid(getCompilationId(compiler))), done.tap('rsbuild-dev-server', hookCallbacks.onDone);
5336
+ compile.tap('rsbuild-dev-server', ()=>{
5337
+ hookCallbacks.onInvalid(getCompilationId(compiler));
5338
+ }), invalid.tap('rsbuild-dev-server', (fileName)=>{
5339
+ hookCallbacks.onInvalid(getCompilationId(compiler), fileName);
5340
+ }), done.tap('rsbuild-dev-server', hookCallbacks.onDone);
5333
5341
  }, getDevMiddleware = async (multiCompiler)=>{
5334
5342
  let { default: rsbuildDevMiddleware } = await import("../compiled/rsbuild-dev-middleware/index.js");
5335
5343
  return (options)=>{
@@ -5529,7 +5537,14 @@ class CompilerDevMiddleware {
5529
5537
  publicPath: '/',
5530
5538
  stats: !1,
5531
5539
  callbacks: {
5532
- onInvalid: (compilationId)=>{
5540
+ onInvalid: (compilationId, fileName)=>{
5541
+ if ('string' == typeof fileName && HTML_REGEX.test(fileName)) {
5542
+ this.socketServer.sockWrite({
5543
+ type: 'content-changed',
5544
+ compilationId
5545
+ });
5546
+ return;
5547
+ }
5533
5548
  this.socketServer.sockWrite({
5534
5549
  type: 'invalid',
5535
5550
  compilationId
@@ -6004,7 +6019,11 @@ let run = async (bundlePath, outputPath, compilerOptions, readFileSync)=>new Bas
6004
6019
  let confHeaders = server.headers;
6005
6020
  if (confHeaders) for (let [key, value] of Object.entries(confHeaders))res.setHeader(key, value);
6006
6021
  next();
6007
- }), server.proxy) {
6022
+ }), server.cors) {
6023
+ let { default: corsMiddleware } = await import("../compiled/cors/index.js");
6024
+ middlewares.push(corsMiddleware('boolean' == typeof server.cors ? {} : server.cors));
6025
+ }
6026
+ if (server.proxy) {
6008
6027
  let { middlewares: proxyMiddlewares, upgrade } = await createProxyMiddleware(server.proxy);
6009
6028
  for (let middleware of (upgradeEvents.push(upgrade), proxyMiddlewares))middlewares.push(middleware);
6010
6029
  }
@@ -6388,13 +6407,17 @@ class RsbuildProdServer {
6388
6407
  this.app = app, await this.applyDefaultMiddlewares();
6389
6408
  }
6390
6409
  async applyDefaultMiddlewares() {
6391
- let { headers, proxy, historyApiFallback, compress, base } = this.options.serverConfig;
6410
+ let { headers, proxy, historyApiFallback, compress, base, cors } = this.options.serverConfig;
6392
6411
  if ('verbose' === __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.level && this.middlewares.use(await getRequestLoggerMiddleware()), compress && this.middlewares.use(gzipMiddleware({
6393
6412
  level: 6
6394
6413
  })), headers && this.middlewares.use((_req, res, next)=>{
6395
6414
  for (let [key, value] of Object.entries(headers))res.setHeader(key, value);
6396
6415
  next();
6397
- }), proxy) {
6416
+ }), cors) {
6417
+ let { default: corsMiddleware } = await import("../compiled/cors/index.js");
6418
+ this.middlewares.use(corsMiddleware('boolean' == typeof cors ? {} : cors));
6419
+ }
6420
+ if (proxy) {
6398
6421
  let { middlewares, upgrade } = await createProxyMiddleware(proxy);
6399
6422
  for (let middleware of middlewares)this.middlewares.use(middleware);
6400
6423
  this.app.on('upgrade', upgrade);
@@ -6936,11 +6959,11 @@ async function runCLI() {
6936
6959
  }
6937
6960
  }(), process.title = 'rsbuild-node';
6938
6961
  let { npm_execpath } = process.env;
6939
- (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.greet(` Rsbuild v1.1.10\n`);
6962
+ (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.greet(` Rsbuild v1.1.12\n`);
6940
6963
  }();
6941
6964
  try {
6942
6965
  !function() {
6943
- program.name('rsbuild').usage('<command> [options]').version("1.1.10");
6966
+ program.name('rsbuild').usage('<command> [options]').version("1.1.12");
6944
6967
  let devCommand = program.command('dev'), buildCommand = program.command('build'), previewCommand = program.command('preview'), inspectCommand = program.command('inspect');
6945
6968
  [
6946
6969
  devCommand,
@@ -6999,6 +7022,6 @@ async function runCLI() {
6999
7022
  __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error('Failed to start Rsbuild CLI.'), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error(err);
7000
7023
  }
7001
7024
  }
7002
- let src_version = "1.1.10";
7025
+ let src_version = "1.1.12";
7003
7026
  var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger, __webpack_exports__rspack = __WEBPACK_EXTERNAL_MODULE__rspack_core__.rspack;
7004
7027
  export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, internal_namespaceObject as __internalHelper, createRsbuild, defineConfig, ensureAssetPrefix, config_loadConfig as loadConfig, loadEnv, mergeRsbuildConfig, runCLI, src_version as version, __webpack_exports__logger as logger, __webpack_exports__rspack as rspack };
@@ -10,8 +10,9 @@ async function transformLoader_rslib_entry_transform(source, map) {
10
10
  resourcePath: this.resourcePath,
11
11
  resourceQuery: this.resourceQuery,
12
12
  environment: getEnvironment(),
13
- addDependency: this.addDependency,
14
- emitFile: this.emitFile
13
+ addDependency: this.addDependency.bind(this),
14
+ emitFile: this.emitFile.bind(this),
15
+ importModule: this.importModule.bind(this)
15
16
  });
16
17
  if (null == result) return bypass();
17
18
  if ('string' == typeof result) return callback(null, result, map);
@@ -10,8 +10,9 @@ let transformRawLoader_rslib_entry_ = async function transformLoader_transform(s
10
10
  resourcePath: this.resourcePath,
11
11
  resourceQuery: this.resourceQuery,
12
12
  environment: getEnvironment(),
13
- addDependency: this.addDependency,
14
- emitFile: this.emitFile
13
+ addDependency: this.addDependency.bind(this),
14
+ emitFile: this.emitFile.bind(this),
15
+ importModule: this.importModule.bind(this)
15
16
  });
16
17
  if (null == result) return bypass();
17
18
  if ('string' == typeof result) return callback(null, result, map);
@@ -3,7 +3,7 @@ import type { Compiler, MultiCompiler } from '@rspack/core';
3
3
  import type { DevMiddlewareOptions } from '../provider/createCompiler';
4
4
  import type { NextFunction } from '../types';
5
5
  type ServerCallbacks = {
6
- onInvalid: (compilationId?: string) => void;
6
+ onInvalid: (compilationId?: string, fileName?: string | null) => void;
7
7
  onDone: (stats: any) => void;
8
8
  };
9
9
  export declare const isClientCompiler: (compiler: {
@@ -3,6 +3,7 @@ import type { SecureServerSessionOptions } from 'node:http2';
3
3
  import type { ServerOptions as HttpsServerOptions } from 'node:https';
4
4
  import type { Configuration, CopyRspackPluginOptions, Externals, LightningCssMinimizerRspackPluginOptions, ModuleFederationPluginOptions, RuleSetCondition, SwcJsMinimizerRspackPluginOptions, SwcLoaderOptions, rspack } from '@rspack/core';
5
5
  import type { ChokidarOptions } from '../../compiled/chokidar/index.js';
6
+ import type cors from '../../compiled/cors/index.js';
6
7
  import type { Options as HttpProxyOptions, Filter as ProxyFilter } from '../../compiled/http-proxy-middleware/index.js';
7
8
  import type RspackChain from '../../compiled/rspack-chain/index.js';
8
9
  import type { BundleAnalyzerPlugin } from '../../compiled/webpack-bundle-analyzer/index.js';
@@ -275,6 +276,15 @@ export interface ServerConfig {
275
276
  target?: string | string[];
276
277
  before?: () => Promise<void> | void;
277
278
  };
279
+ /**
280
+ * Configure CORS for the dev server or preview server.
281
+ * - true: enable CORS with default options.
282
+ * - false: disable CORS.
283
+ * - object: enable CORS with the specified options.
284
+ * @default true
285
+ * @link https://github.com/expressjs/cors
286
+ */
287
+ cors?: boolean | cors.CorsOptions;
278
288
  /**
279
289
  * Configure proxy rules for the dev server or preview server to proxy requests to the specified service.
280
290
  */
@@ -288,7 +298,7 @@ export interface ServerConfig {
288
298
  */
289
299
  printUrls?: PrintUrls;
290
300
  }
291
- export type NormalizedServerConfig = ServerConfig & Required<Pick<ServerConfig, 'htmlFallback' | 'port' | 'host' | 'compress' | 'strictPort' | 'printUrls' | 'open' | 'base'>>;
301
+ export type NormalizedServerConfig = ServerConfig & Required<Pick<ServerConfig, 'htmlFallback' | 'port' | 'host' | 'compress' | 'strictPort' | 'printUrls' | 'open' | 'base' | 'cors'>>;
292
302
  export type SriAlgorithm = 'sha256' | 'sha384' | 'sha512';
293
303
  export type SriOptions = {
294
304
  algorithm?: SriAlgorithm;
@@ -180,7 +180,11 @@ export type TransformContext = {
180
180
  * @param sourceMap source map of the asset
181
181
  * @param assetInfo additional asset information
182
182
  */
183
- emitFile: (name: string, content: string | Buffer, sourceMap?: string, assetInfo?: Record<string, any>) => void;
183
+ emitFile: Rspack.LoaderContext['emitFile'];
184
+ /**
185
+ * Compile and execute a module at the build time.
186
+ */
187
+ importModule: Rspack.LoaderContext['importModule'];
184
188
  };
185
189
  export type TransformHandler = (context: TransformContext) => MaybePromise<TransformResult>;
186
190
  export type TransformDescriptor = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/core",
3
- "version": "1.1.10",
3
+ "version": "1.1.12",
4
4
  "description": "The Rspack-based build tool.",
5
5
  "homepage": "https://rsbuild.dev",
6
6
  "bugs": {
@@ -46,15 +46,15 @@
46
46
  "types.d.ts"
47
47
  ],
48
48
  "dependencies": {
49
- "@rspack/core": "~1.1.6",
49
+ "@rspack/core": "1.1.8",
50
50
  "@rspack/lite-tapable": "~1.0.1",
51
51
  "@swc/helpers": "^0.5.15",
52
52
  "core-js": "~3.39.0"
53
53
  },
54
54
  "devDependencies": {
55
- "@rslib/core": "0.1.3",
55
+ "@rslib/core": "0.1.4",
56
56
  "@types/connect": "3.4.38",
57
- "@types/node": "^22.10.1",
57
+ "@types/node": "^22.10.2",
58
58
  "@types/on-finished": "2.3.4",
59
59
  "@types/webpack-bundle-analyzer": "4.7.0",
60
60
  "@types/ws": "^8.5.13",
@@ -63,6 +63,7 @@
63
63
  "commander": "^12.1.0",
64
64
  "connect": "3.7.0",
65
65
  "connect-history-api-fallback": "^2.0.0",
66
+ "cors": "^2.8.5",
66
67
  "css-loader": "7.1.2",
67
68
  "deepmerge": "^4.3.1",
68
69
  "dotenv": "16.4.7",