@rsbuild/core 0.6.8 → 0.6.9

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.
Files changed (53) hide show
  1. package/compiled/commander/{typings/index.d.ts → index.d.ts} +26 -24
  2. package/compiled/commander/index.js +3528 -1
  3. package/compiled/commander/package.json +1 -1
  4. package/compiled/connect-history-api-fallback/index.js +186 -1
  5. package/compiled/dotenv/{lib/main.d.ts → index.d.ts} +16 -12
  6. package/compiled/dotenv/index.js +458 -1
  7. package/compiled/dotenv/package.json +1 -1
  8. package/compiled/dotenv-expand/{lib/main.d.ts → index.d.ts} +9 -7
  9. package/compiled/dotenv-expand/index.js +146 -1
  10. package/compiled/dotenv-expand/package.json +1 -1
  11. package/compiled/http-compression/index.js +185 -1
  12. package/compiled/launch-editor-middleware/index.js +843 -1
  13. package/compiled/on-finished/index.d.ts +2 -2
  14. package/compiled/on-finished/index.js +390 -3
  15. package/compiled/on-finished/package.json +1 -1
  16. package/compiled/open/index.d.ts +1 -153
  17. package/compiled/open/index.js +526 -1
  18. package/compiled/open/package.json +1 -1
  19. package/compiled/sirv/index.d.ts +1 -0
  20. package/compiled/sirv/index.js +798 -1
  21. package/compiled/sirv/package.json +1 -1
  22. package/compiled/webpack-dev-middleware/index.d.ts +1 -0
  23. package/compiled/webpack-dev-middleware/index.js +6696 -0
  24. package/compiled/webpack-dev-middleware/license +20 -0
  25. package/compiled/webpack-dev-middleware/package.json +1 -0
  26. package/compiled/webpack-dev-middleware/schema-utils.js +1 -0
  27. package/compiled/ws/index.d.ts +7 -15
  28. package/compiled/ws/index.js +4885 -1
  29. package/compiled/ws/package.json +1 -1
  30. package/dist/cli/commands.js +1 -1
  31. package/dist/cli/prepare.js +1 -1
  32. package/dist/client/format.d.ts +5 -0
  33. package/dist/client/{formatStats.js → format.js} +8 -43
  34. package/dist/client/{hmr/index.d.ts → hmr.d.ts} +4 -0
  35. package/dist/client/hmr.mjs +194 -431
  36. package/dist/client/overlay.mjs +205 -227
  37. package/dist/createContext.js +1 -1
  38. package/dist/index.js +1 -1
  39. package/dist/plugins/target.js +19 -16
  40. package/dist/provider/plugins/swc.js +1 -0
  41. package/dist/provider/shared.js +2 -2
  42. package/dist/server/devMiddleware.js +1 -1
  43. package/dist/server/devServer.js +6 -1
  44. package/dist/server/getDevMiddlewares.d.ts +3 -0
  45. package/dist/server/getDevMiddlewares.js +6 -8
  46. package/dist/server/helper.d.ts +4 -4
  47. package/dist/server/middlewares.d.ts +5 -2
  48. package/dist/server/middlewares.js +1 -7
  49. package/package.json +6 -5
  50. package/compiled/open/license +0 -9
  51. package/compiled/sirv/sirv.d.ts +0 -27
  52. package/dist/client/formatStats.d.ts +0 -12
  53. package/dist/client/hmr/url.d.ts +0 -6
@@ -1,243 +1,221 @@
1
1
  // src/client/overlay.ts
2
- function _assert_this_initialized(self) {
3
- if (self === void 0) {
4
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
5
- }
6
- return self;
7
- }
8
- function _class_call_check(instance, Constructor) {
9
- if (!(instance instanceof Constructor)) {
10
- throw new TypeError("Cannot call a class as a function");
11
- }
12
- }
13
- function _construct(Parent, args, Class) {
14
- if (_is_native_reflect_construct()) {
15
- _construct = Reflect.construct;
16
- } else {
17
- _construct = function construct(Parent, args, Class) {
18
- var a = [
19
- null
20
- ];
21
- a.push.apply(a, args);
22
- var Constructor = Function.bind.apply(Parent, a);
23
- var instance = new Constructor();
24
- if (Class) _set_prototype_of(instance, Class.prototype);
25
- return instance;
26
- };
27
- }
28
- return _construct.apply(null, arguments);
29
- }
30
- function _define_property(obj, key, value) {
31
- if (key in obj) {
32
- Object.defineProperty(obj, key, {
33
- value: value,
34
- enumerable: true,
35
- configurable: true,
36
- writable: true
37
- });
38
- } else {
39
- obj[key] = value;
40
- }
41
- return obj;
42
- }
43
- function _get_prototype_of(o) {
44
- _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
45
- return o.__proto__ || Object.getPrototypeOf(o);
46
- };
47
- return _get_prototype_of(o);
48
- }
49
- function _inherits(subClass, superClass) {
50
- if (typeof superClass !== "function" && superClass !== null) {
51
- throw new TypeError("Super expression must either be null or a function");
52
- }
53
- subClass.prototype = Object.create(superClass && superClass.prototype, {
54
- constructor: {
55
- value: subClass,
56
- writable: true,
57
- configurable: true
58
- }
59
- });
60
- if (superClass) _set_prototype_of(subClass, superClass);
61
- }
62
- function _is_native_function(fn) {
63
- return Function.toString.call(fn).indexOf("[native code]") !== -1;
64
- }
65
- function _possible_constructor_return(self, call) {
66
- if (call && (_type_of(call) === "object" || typeof call === "function")) {
67
- return call;
68
- }
69
- return _assert_this_initialized(self);
70
- }
71
- function _set_prototype_of(o, p) {
72
- _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
73
- o.__proto__ = p;
74
- return o;
75
- };
76
- return _set_prototype_of(o, p);
77
- }
78
- function _type_of(obj) {
79
- "@swc/helpers - typeof";
80
- return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
81
- }
82
- function _wrap_native_super(Class) {
83
- var _cache = typeof Map === "function" ? new Map() : undefined;
84
- _wrap_native_super = function wrapNativeSuper(Class) {
85
- if (Class === null || !_is_native_function(Class)) return Class;
86
- if (typeof Class !== "function") {
87
- throw new TypeError("Super expression must either be null or a function");
88
- }
89
- if (typeof _cache !== "undefined") {
90
- if (_cache.has(Class)) return _cache.get(Class);
91
- _cache.set(Class, Wrapper);
92
- }
93
- function Wrapper() {
94
- return _construct(Class, arguments, _get_prototype_of(this).constructor);
95
- }
96
- Wrapper.prototype = Object.create(Class.prototype, {
97
- constructor: {
98
- value: Wrapper,
99
- enumerable: false,
100
- writable: true,
101
- configurable: true
102
- }
103
- });
104
- return _set_prototype_of(Wrapper, Class);
105
- };
106
- return _wrap_native_super(Class);
107
- }
108
- function _is_native_reflect_construct() {
109
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
110
- if (Reflect.construct.sham) return false;
111
- if (typeof Proxy === "function") return true;
112
- try {
113
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
114
- return true;
115
- } catch (e) {
116
- return false;
117
- }
118
- }
119
- function _create_super(Derived) {
120
- var hasNativeReflectConstruct = _is_native_reflect_construct();
121
- return function _createSuperInternal() {
122
- var Super = _get_prototype_of(Derived), result;
123
- if (hasNativeReflectConstruct) {
124
- var NewTarget = _get_prototype_of(this).constructor;
125
- result = Reflect.construct(Super, arguments, NewTarget);
126
- } else {
127
- result = Super.apply(this, arguments);
128
- }
129
- return _possible_constructor_return(this, result);
130
- };
131
- }
2
+ import { _ as _define_property } from "@swc/helpers/_/_define_property";
132
3
  import { registerOverlay } from "./hmr";
133
4
  function stripAnsi(content) {
134
- var pattern = [
135
- "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
136
- "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"
137
- ].join("|");
138
- var regex = new RegExp(pattern, "g");
139
- return content.replace(regex, "");
5
+ const pattern = [
6
+ "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
7
+ "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"
8
+ ].join("|");
9
+ const regex = new RegExp(pattern, "g");
10
+ return content.replace(regex, "");
140
11
  }
141
12
  function linkedText(root, selector, text) {
142
- var _loop = function() {
143
- var file = match[0], index = match.index;
144
- if (index != null) {
145
- var frag2 = text.slice(curIndex, index);
146
- el.appendChild(document.createTextNode(frag2));
147
- var link = document.createElement("a");
148
- link.textContent = file;
149
- link.className = "file-link";
150
- link.onclick = function() {
151
- fetch("/__open-in-editor?file=".concat(encodeURIComponent(file)));
152
- };
153
- el.appendChild(link);
154
- curIndex += frag2.length + file.length;
155
- }
156
- match = fileRegex.exec(text);
157
- };
158
- var el = root.querySelector(selector);
159
- var fileRegex = /(?:[a-zA-Z]:\\|\/).*?:\d+:\d+/g;
160
- var curIndex = 0;
161
- var match = fileRegex.exec(text);
162
- while(match !== null)_loop();
163
- var frag = text.slice(curIndex);
164
- el.appendChild(document.createTextNode(frag));
165
- }
166
- var overlayTemplate = '\n<style>\n.root {\n position: fixed;\n z-index: 9999;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n overflow-y: scroll;\n margin: 0;\n background: rgba(0, 0, 0, 0.66);\n cursor: pointer;\n}\n.container {\n font-family: Menlo, Consolas, monospace;\n line-height: 1.6;\n width: 800px;\n max-width: 85%;\n color: #d8d8d8;\n margin: 32px auto;\n padding: 32px 40px;\n position: relative;\n background: #181818;\n border-radius: 24px;\n box-shadow: 0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22);\n overflow: hidden;\n direction: ltr;\n text-align: left;\n box-sizing: border-box;\n cursor: default;\n}\n.title {\n margin: 0 0 20px;\n padding-bottom: 12px;\n font-size: 17px;\n font-weight: 600;\n color: #fc5e5e;\n border-bottom: 2px solid rgba(252,94,94,.66);\n}\n.content {\n margin: 0;\n font-size: 14px;\n font-family: inherit;\n overflow-x: scroll;\n scrollbar-width: none;\n color: #b8b8b8;\n}\n.content::-webkit-scrollbar {\n display: none;\n}\n.file-link {\n cursor: pointer;\n color: #27caca;\n text-decoration: underline;\n &:hover {\n opacity: 0.8;\n }\n &:active {\n opacity: 0.6;\n }\n}\n.close {\n position: absolute;\n top: 27px;\n right: 32px;\n width: 32px;\n height: 32px;\n cursor: pointer;\n}\n.close:hover {\n opacity: 0.8;\n}\n.close:active {\n opacity: 0.6;\n}\n.close:before,\n.close:after {\n position: absolute;\n left: 16px;\n top: 8px;\n content: \' \';\n height: 18px;\n width: 2px;\n border-radius: 4px;\n background-color: #b8b8b8;\n}\n.close:before {\n transform: rotate(45deg);\n}\n.close:after {\n transform: rotate(-45deg);\n}\n.footer {\n font-size: 12px;\n color: #7e6a92;\n margin-top: 20px;\n padding-top: 12px;\n border-top: 2px solid rgba(126,106,146,.6);\n}\n.footer p {\n margin: 4px 0 0;\n}\n.footer span {\n color: #a88dc3;\n}\n</style>\n\n<div class="root">\n <div class="container">\n <div class="close"></div>\n <p class="title">Compilation failed</p>\n <pre class="content"></pre>\n <footer class="footer">\n <p><span>Fix error</span>, click outside, or press Esc to close the overlay.</p>\n <p>Disable overlay by setting Rsbuild\'s <span>dev.client.overlay</span> config to false.<p>\n </footer>\n </div>\n</div>\n';
167
- var _ref = typeof window !== "undefined" ? window : globalThis, _ref_HTMLElement = _ref.HTMLElement, HTMLElement = _ref_HTMLElement === void 0 ? function HTMLElement() {
168
- "use strict";
169
- _class_call_check(this, HTMLElement);
170
- } : _ref_HTMLElement, customElements = _ref.customElements;
171
- var ErrorOverlay = /*#__PURE__*/ function(HTMLElement) {
172
- "use strict";
173
- _inherits(ErrorOverlay, HTMLElement);
174
- var _super = _create_super(ErrorOverlay);
175
- function ErrorOverlay(message) {
176
- _class_call_check(this, ErrorOverlay);
177
- var _this;
178
- var _root_querySelector;
179
- _this = _super.call(this);
180
- _define_property(_assert_this_initialized(_this), "close", function() {
181
- var remove = function() {
182
- var _this_parentNode;
183
- return (_this_parentNode = _this.parentNode) === null || _this_parentNode === void 0 ? void 0 : _this_parentNode.removeChild(_assert_this_initialized(_this));
184
- };
185
- if (_this.animate) {
186
- _this.animate([
187
- {
188
- opacity: 1
189
- },
190
- {
191
- opacity: 0
192
- }
193
- ], {
194
- duration: 300,
195
- easing: "ease-out"
196
- }).addEventListener("finish", remove);
197
- } else {
198
- remove();
199
- }
200
- });
201
- if (!_this.attachShadow) {
202
- console.warn("[Rsbuild] Current browser version does not support displaying error overlay");
203
- return _possible_constructor_return(_this);
204
- }
205
- var root = _this.attachShadow({
206
- mode: "open"
207
- });
208
- root.innerHTML = overlayTemplate;
209
- linkedText(root, ".content", stripAnsi(message.join("/n")).trim());
210
- (_root_querySelector = root.querySelector(".close")) === null || _root_querySelector === void 0 ? void 0 : _root_querySelector.addEventListener("click", _this.close);
211
- _this.addEventListener("click", _this.close);
212
- root.querySelector(".container").addEventListener("click", function(e) {
213
- e.stopPropagation();
214
- });
215
- var onEscKeydown = function(e) {
216
- if (e.key === "Escape" || e.code === "Escape") {
217
- _this.close();
218
- }
219
- document.removeEventListener("keydown", onEscKeydown);
220
- };
221
- document.addEventListener("keydown", onEscKeydown);
222
- return _this;
13
+ const el = root.querySelector(selector);
14
+ const fileRegex = /(?:[a-zA-Z]:\\|\/).*?:\d+:\d+/g;
15
+ let curIndex = 0;
16
+ let match = fileRegex.exec(text);
17
+ while (match !== null) {
18
+ const { 0: file, index } = match;
19
+ if (index != null) {
20
+ const frag2 = text.slice(curIndex, index);
21
+ el.appendChild(document.createTextNode(frag2));
22
+ const link = document.createElement("a");
23
+ link.textContent = file;
24
+ link.className = "file-link";
25
+ link.onclick = () => {
26
+ fetch(`/__open-in-editor?file=${encodeURIComponent(file)}`);
27
+ };
28
+ el.appendChild(link);
29
+ curIndex += frag2.length + file.length;
30
+ }
31
+ match = fileRegex.exec(text);
32
+ }
33
+ const frag = text.slice(curIndex);
34
+ el.appendChild(document.createTextNode(frag));
35
+ }
36
+ var overlayTemplate = `
37
+ <style>
38
+ .root {
39
+ position: fixed;
40
+ z-index: 9999;
41
+ top: 0;
42
+ left: 0;
43
+ width: 100%;
44
+ height: 100%;
45
+ overflow-y: scroll;
46
+ margin: 0;
47
+ background: rgba(0, 0, 0, 0.66);
48
+ cursor: pointer;
49
+ }
50
+ .container {
51
+ font-family: Menlo, Consolas, monospace;
52
+ line-height: 1.6;
53
+ width: 800px;
54
+ max-width: 85%;
55
+ color: #d8d8d8;
56
+ margin: 32px auto;
57
+ padding: 32px 40px;
58
+ position: relative;
59
+ background: #181818;
60
+ border-radius: 24px;
61
+ box-shadow: 0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22);
62
+ overflow: hidden;
63
+ direction: ltr;
64
+ text-align: left;
65
+ box-sizing: border-box;
66
+ cursor: default;
67
+ }
68
+ .title {
69
+ margin: 0 0 20px;
70
+ padding-bottom: 12px;
71
+ font-size: 17px;
72
+ font-weight: 600;
73
+ color: #fc5e5e;
74
+ border-bottom: 2px solid rgba(252,94,94,.66);
75
+ }
76
+ .content {
77
+ margin: 0;
78
+ font-size: 14px;
79
+ font-family: inherit;
80
+ overflow-x: scroll;
81
+ scrollbar-width: none;
82
+ color: #b8b8b8;
83
+ }
84
+ .content::-webkit-scrollbar {
85
+ display: none;
86
+ }
87
+ .file-link {
88
+ cursor: pointer;
89
+ color: #27caca;
90
+ text-decoration: underline;
91
+ &:hover {
92
+ opacity: 0.8;
93
+ }
94
+ &:active {
95
+ opacity: 0.6;
96
+ }
97
+ }
98
+ .close {
99
+ position: absolute;
100
+ top: 27px;
101
+ right: 32px;
102
+ width: 32px;
103
+ height: 32px;
104
+ cursor: pointer;
105
+ }
106
+ .close:hover {
107
+ opacity: 0.8;
108
+ }
109
+ .close:active {
110
+ opacity: 0.6;
111
+ }
112
+ .close:before,
113
+ .close:after {
114
+ position: absolute;
115
+ left: 16px;
116
+ top: 8px;
117
+ content: ' ';
118
+ height: 18px;
119
+ width: 2px;
120
+ border-radius: 4px;
121
+ background-color: #b8b8b8;
122
+ }
123
+ .close:before {
124
+ transform: rotate(45deg);
125
+ }
126
+ .close:after {
127
+ transform: rotate(-45deg);
128
+ }
129
+ .footer {
130
+ font-size: 12px;
131
+ color: #7e6a92;
132
+ margin-top: 20px;
133
+ padding-top: 12px;
134
+ border-top: 2px solid rgba(126,106,146,.6);
135
+ }
136
+ .footer p {
137
+ margin: 4px 0 0;
138
+ }
139
+ .footer span {
140
+ color: #a88dc3;
141
+ }
142
+ </style>
143
+
144
+ <div class="root">
145
+ <div class="container">
146
+ <div class="close"></div>
147
+ <p class="title">Compilation failed</p>
148
+ <pre class="content"></pre>
149
+ <footer class="footer">
150
+ <p><span>Fix error</span>, click outside, or press Esc to close the overlay.</p>
151
+ <p>Disable overlay by setting Rsbuild's <span>dev.client.overlay</span> config to false.<p>
152
+ </footer>
153
+ </div>
154
+ </div>
155
+ `;
156
+ var { HTMLElement = class {
157
+ }, customElements } = typeof window !== "undefined" ? window : globalThis;
158
+ var ErrorOverlay = class extends HTMLElement {
159
+ constructor(message) {
160
+ var _root_querySelector;
161
+ super();
162
+ _define_property(this, "close", () => {
163
+ const remove = () => {
164
+ var _this_parentNode;
165
+ return (_this_parentNode = this.parentNode) === null || _this_parentNode === void 0 ? void 0 : _this_parentNode.removeChild(this);
166
+ };
167
+ if (this.animate) {
168
+ this.animate([
169
+ {
170
+ opacity: 1
171
+ },
172
+ {
173
+ opacity: 0
174
+ }
175
+ ], {
176
+ duration: 300,
177
+ easing: "ease-out"
178
+ }).addEventListener("finish", remove);
179
+ } else {
180
+ remove();
181
+ }
182
+ });
183
+ if (!this.attachShadow) {
184
+ console.warn("[Rsbuild] Current browser version does not support displaying error overlay");
185
+ return;
223
186
  }
224
- return ErrorOverlay;
225
- }(_wrap_native_super(HTMLElement));
187
+ const root = this.attachShadow({
188
+ mode: "open"
189
+ });
190
+ root.innerHTML = overlayTemplate;
191
+ linkedText(root, ".content", stripAnsi(message.join("/n")).trim());
192
+ (_root_querySelector = root.querySelector(".close")) === null || _root_querySelector === void 0 ? void 0 : _root_querySelector.addEventListener("click", this.close);
193
+ this.addEventListener("click", this.close);
194
+ root.querySelector(".container").addEventListener("click", (e) => {
195
+ e.stopPropagation();
196
+ });
197
+ const onEscKeydown = (e) => {
198
+ if (e.key === "Escape" || e.code === "Escape") {
199
+ this.close();
200
+ }
201
+ document.removeEventListener("keydown", onEscKeydown);
202
+ };
203
+ document.addEventListener("keydown", onEscKeydown);
204
+ }
205
+ };
226
206
  var overlayId = "rsbuild-error-overlay";
227
207
  if (customElements && !customElements.get(overlayId)) {
228
- customElements.define(overlayId, ErrorOverlay);
208
+ customElements.define(overlayId, ErrorOverlay);
229
209
  }
230
210
  function createOverlay(err) {
231
- clearOverlay();
232
- document.body.appendChild(new ErrorOverlay(err));
211
+ clearOverlay();
212
+ document.body.appendChild(new ErrorOverlay(err));
233
213
  }
234
214
  function clearOverlay() {
235
- document.querySelectorAll(overlayId).forEach(function(n) {
236
- return n.close();
237
- });
215
+ document.querySelectorAll(overlayId).forEach((n) => n.close());
238
216
  }
239
217
  if (typeof document !== "undefined") {
240
- registerOverlay(createOverlay, clearOverlay);
218
+ registerOverlay(createOverlay, clearOverlay);
241
219
  } else {
242
- console.info("[Rsbuild] Failed to display error overlay as document is not available, you can disable the `dev.client.overlay` option.");
220
+ console.info("[Rsbuild] Failed to display error overlay as document is not available, you can disable the `dev.client.overlay` option.");
243
221
  }
@@ -44,7 +44,7 @@ async function createContextByConfig(options, bundlerType, config = {}) {
44
44
  const context = {
45
45
  entry: (0, import_entry.getEntryObject)(config, "web"),
46
46
  targets: config.output?.targets || [],
47
- version: "0.6.8",
47
+ version: "0.6.9",
48
48
  rootPath,
49
49
  distPath,
50
50
  cachePath,
package/dist/index.js CHANGED
@@ -40,7 +40,7 @@ var import_config = require("./config");
40
40
  var import_shared = require("@rsbuild/shared");
41
41
  var import_mergeConfig = require("./mergeConfig");
42
42
  var import_constants = require("./constants");
43
- const version = "0.6.8";
43
+ const version = "0.6.9";
44
44
  // Annotate the CommonJS export names for ESM import in node:
45
45
  0 && (module.exports = {
46
46
  PLUGIN_CSS_NAME,
@@ -25,23 +25,26 @@ var import_shared = require("@rsbuild/shared");
25
25
  const pluginTarget = () => ({
26
26
  name: "rsbuild:target",
27
27
  setup(api) {
28
- api.modifyBundlerChain(async (chain, { target }) => {
29
- if (target === "node") {
30
- chain.target("node");
31
- return;
28
+ api.modifyBundlerChain({
29
+ order: "pre",
30
+ handler: async (chain, { target }) => {
31
+ if (target === "node") {
32
+ chain.target("node");
33
+ return;
34
+ }
35
+ const config = api.getNormalizedConfig();
36
+ const browserslist = await (0, import_shared.getBrowserslistWithDefault)(
37
+ api.context.rootPath,
38
+ config,
39
+ target
40
+ );
41
+ const esVersion = (0, import_shared.browserslistToESVersion)(browserslist);
42
+ if (target === "web-worker" || target === "service-worker") {
43
+ chain.target(["webworker", `es${esVersion}`]);
44
+ return;
45
+ }
46
+ chain.target(["web", `es${esVersion}`]);
32
47
  }
33
- const config = api.getNormalizedConfig();
34
- const browserslist = await (0, import_shared.getBrowserslistWithDefault)(
35
- api.context.rootPath,
36
- config,
37
- target
38
- );
39
- const esVersion = (0, import_shared.browserslistToESVersion)(browserslist);
40
- if (target === "web-worker" || target === "service-worker") {
41
- chain.target(["webworker", `es${esVersion}`]);
42
- return;
43
- }
44
- chain.target(["web", `es${esVersion}`]);
45
48
  });
46
49
  }
47
50
  });
@@ -66,6 +66,7 @@ const pluginSwc = () => ({
66
66
  const rule = chain.module.rule(CHAIN_ID.RULE.JS).test(import_shared.SCRIPT_REGEX).type("javascript/auto");
67
67
  (0, import_shared.applyScriptCondition)({
68
68
  rule,
69
+ chain,
69
70
  config,
70
71
  context: api.context,
71
72
  includes: [],
@@ -31,7 +31,7 @@ module.exports = __toCommonJS(shared_exports);
31
31
  var import_node_path = require("node:path");
32
32
  var import_shared = require("@rsbuild/shared");
33
33
  var import_shared2 = require("@rsbuild/shared");
34
- var import_formatStats = require("../client/formatStats");
34
+ var import_format = require("../client/format");
35
35
  const rspackMinVersion = "0.6.2";
36
36
  const compareSemver = (version1, version2) => {
37
37
  const parts1 = version1.split(".").map(Number);
@@ -182,7 +182,7 @@ function formatStats(stats, options = {}) {
182
182
  ...options
183
183
  } : options
184
184
  );
185
- const { errors, warnings } = (0, import_formatStats.formatStatsMessages)({
185
+ const { errors, warnings } = (0, import_format.formatStatsMessages)({
186
186
  errors: getAllStatsErrors(statsData),
187
187
  warnings: getAllStatsWarnings(statsData)
188
188
  });
@@ -32,7 +32,7 @@ __export(devMiddleware_exports, {
32
32
  });
33
33
  module.exports = __toCommonJS(devMiddleware_exports);
34
34
  var import_shared = require("@rsbuild/shared");
35
- var import_webpack_dev_middleware = __toESM(require("@rsbuild/shared/webpack-dev-middleware"));
35
+ var import_webpack_dev_middleware = __toESM(require("../../compiled/webpack-dev-middleware"));
36
36
  function applyHMREntry({
37
37
  compiler,
38
38
  clientPaths,
@@ -31,6 +31,7 @@ __export(devServer_exports, {
31
31
  createDevServer: () => createDevServer
32
32
  });
33
33
  module.exports = __toCommonJS(devServer_exports);
34
+ var import_node_fs = __toESM(require("node:fs"));
34
35
  var import_shared = require("@rsbuild/shared");
35
36
  var import_connect = __toESM(require("@rsbuild/shared/connect"));
36
37
  var import_getDevMiddlewares = require("./getDevMiddlewares");
@@ -63,6 +64,7 @@ async function createDevServer(options, createDevMiddleware, {
63
64
  port,
64
65
  https
65
66
  };
67
+ let outputFileSystem = import_node_fs.default;
66
68
  const startCompile = async () => {
67
69
  const { devMiddleware, compiler } = await createDevMiddleware(
68
70
  options,
@@ -77,6 +79,7 @@ async function createDevServer(options, createDevMiddleware, {
77
79
  devMiddleware
78
80
  });
79
81
  compilerDevMiddleware.init();
82
+ outputFileSystem = (0, import_shared.isMultiCompiler)(compiler) ? compiler.compilers[0].outputFileSystem : compiler.outputFileSystem;
80
83
  return {
81
84
  middleware: compilerDevMiddleware.middleware,
82
85
  sockWrite: (...args) => compilerDevMiddleware.sockWrite(...args),
@@ -119,7 +122,8 @@ async function createDevServer(options, createDevMiddleware, {
119
122
  server: serverConfig,
120
123
  output: {
121
124
  distPath: rsbuildConfig.output?.distPath?.root || import_shared.ROOT_DIST_DIR
122
- }
125
+ },
126
+ outputFileSystem
123
127
  });
124
128
  const middlewares = (0, import_connect.default)();
125
129
  for (const item of devMiddlewares.middlewares) {
@@ -132,6 +136,7 @@ async function createDevServer(options, createDevMiddleware, {
132
136
  const server = {
133
137
  port,
134
138
  middlewares,
139
+ outputFileSystem,
135
140
  listen: async () => {
136
141
  const httpServer = await (0, import_httpServer.createHttpServer)({
137
142
  https: serverConfig.https,
@@ -1,9 +1,12 @@
1
+ /// <reference types="node" />
2
+ import type fs from 'node:fs';
1
3
  import type { CompileMiddlewareAPI, DevConfig, Middlewares, ServerConfig, UpgradeEvent } from '@rsbuild/shared';
2
4
  export type RsbuildDevMiddlewareOptions = {
3
5
  pwd: string;
4
6
  dev: DevConfig;
5
7
  server: ServerConfig;
6
8
  compileMiddlewareAPI?: CompileMiddlewareAPI;
9
+ outputFileSystem: typeof fs;
7
10
  output: {
8
11
  distPath: string;
9
12
  };
@@ -58,7 +58,8 @@ const applyDefaultMiddlewares = async ({
58
58
  server,
59
59
  compileMiddlewareAPI,
60
60
  output,
61
- pwd
61
+ pwd,
62
+ outputFileSystem
62
63
  }) => {
63
64
  const upgradeEvents = [];
64
65
  if (server.compress) {
@@ -125,7 +126,8 @@ const applyDefaultMiddlewares = async ({
125
126
  (0, import_middlewares.getHtmlFallbackMiddleware)({
126
127
  distPath: (0, import_node_path.isAbsolute)(distPath) ? distPath : (0, import_node_path.join)(pwd, distPath),
127
128
  callback: compileMiddlewareAPI.middleware,
128
- htmlFallback: server.htmlFallback
129
+ htmlFallback: server.htmlFallback,
130
+ outputFileSystem
129
131
  })
130
132
  );
131
133
  if (server.historyApiFallback) {
@@ -157,12 +159,8 @@ const getMiddlewares = async (options) => {
157
159
  );
158
160
  middlewares.push(...before);
159
161
  const { onUpgrade } = await applyDefaultMiddlewares({
160
- middlewares,
161
- dev: options.dev,
162
- server: options.server,
163
- compileMiddlewareAPI,
164
- output: options.output,
165
- pwd: options.pwd
162
+ ...options,
163
+ middlewares
166
164
  });
167
165
  middlewares.push(...after);
168
166
  return {
@@ -1,4 +1,4 @@
1
- import type { DevConfig, OutputStructure, PrintUrls, Routes, RsbuildConfig, RsbuildEntry } from '@rsbuild/shared';
1
+ import type { OutputStructure, PrintUrls, Routes, RsbuildConfig, RsbuildEntry } from '@rsbuild/shared';
2
2
  export declare const formatRoutes: (entry: RsbuildEntry, prefix: string | undefined, outputStructure: OutputStructure | undefined) => Routes;
3
3
  export declare function printServerURLs({ urls: originalUrls, port, routes, protocol, printUrls, }: {
4
4
  urls: Array<{
@@ -17,7 +17,7 @@ export declare const HMR_SOCK_PATH = "/rsbuild-hmr";
17
17
  export declare const mergeDevOptions: ({ rsbuildConfig, port, }: {
18
18
  rsbuildConfig: RsbuildConfig;
19
19
  port: number;
20
- }) => DevConfig;
20
+ }) => any;
21
21
  /**
22
22
  * Get available free port.
23
23
  * @param port - Current port want to use.
@@ -45,10 +45,10 @@ export declare const getDevOptions: ({ rsbuildConfig, getPortSilently, }: {
45
45
  rsbuildConfig: RsbuildConfig;
46
46
  getPortSilently?: boolean;
47
47
  }) => Promise<{
48
- devConfig: DevConfig;
48
+ devConfig: any;
49
49
  serverConfig: import("@rsbuild/shared").ServerConfig;
50
50
  port: number;
51
51
  host: string;
52
52
  https: boolean;
53
- liveReload: boolean | undefined;
53
+ liveReload: any;
54
54
  }>;