@rsbuild/core 0.4.14 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/commands.js +1 -1
- package/dist/cli/prepare.js +2 -2
- package/dist/client/hmr.mjs +449 -230
- package/dist/createRsbuild.js +2 -2
- package/dist/index.js +1 -1
- package/dist/loadEnv.js +7 -7
- package/dist/mergeConfig.js +2 -2
- package/dist/pluginManager.js +19 -15
- package/dist/plugins/basic.js +2 -0
- package/dist/plugins/entry.js +2 -2
- package/dist/plugins/externals.js +2 -2
- package/dist/plugins/fileSize.js +2 -2
- package/dist/plugins/html.d.ts +1 -2
- package/dist/plugins/html.js +18 -38
- package/dist/plugins/moduleFederation.js +2 -2
- package/dist/plugins/rsdoctor.js +2 -2
- package/dist/plugins/splitChunks.js +4 -4
- package/dist/plugins/target.js +10 -12
- package/dist/provider/config.js +0 -1
- package/dist/provider/createContext.js +1 -1
- package/dist/provider/plugins/less.js +2 -2
- package/dist/provider/plugins/minimize.js +1 -2
- package/dist/provider/plugins/resolve.js +1 -4
- package/dist/provider/plugins/sass.js +2 -2
- package/dist/provider/plugins/transition.js +9 -1
- package/dist/provider/provider.js +6 -9
- package/dist/rspack/HtmlBasicPlugin.d.ts +25 -2
- package/dist/rspack/HtmlBasicPlugin.js +155 -25
- package/dist/rspack/HtmlCrossOriginPlugin.js +4 -8
- package/dist/rspack/HtmlNoncePlugin.js +2 -2
- package/dist/rspack/InlineChunkHtmlPlugin.js +2 -2
- package/dist/rspack/RemoveCssSourcemapPlugin.js +2 -2
- package/dist/server/devServer.d.ts +3 -10
- package/dist/server/devServer.js +108 -115
- package/dist/server/getDevMiddlewares.js +9 -7
- package/dist/server/helper.js +2 -2
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +2 -4
- package/dist/server/prodServer.js +2 -2
- package/dist/server/socketServer.js +6 -6
- package/package.json +5 -5
- package/dist/plugins/toml.d.ts +0 -0
- package/dist/plugins/toml.js +0 -1
- package/dist/plugins/yaml.d.ts +0 -0
- package/dist/plugins/yaml.js +0 -1
- package/dist/rspack/HtmlTagsPlugin.d.ts +0 -24
- package/dist/rspack/HtmlTagsPlugin.js +0 -186
package/dist/client/hmr.mjs
CHANGED
|
@@ -1,286 +1,505 @@
|
|
|
1
1
|
// src/client/formatStats.ts
|
|
2
|
+
function _array_like_to_array(arr, len) {
|
|
3
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
4
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
5
|
+
return arr2;
|
|
6
|
+
}
|
|
7
|
+
function _array_with_holes(arr) {
|
|
8
|
+
if (Array.isArray(arr)) return arr;
|
|
9
|
+
}
|
|
10
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
11
|
+
try {
|
|
12
|
+
var info = gen[key](arg);
|
|
13
|
+
var value = info.value;
|
|
14
|
+
} catch (error) {
|
|
15
|
+
reject(error);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (info.done) {
|
|
19
|
+
resolve(value);
|
|
20
|
+
} else {
|
|
21
|
+
Promise.resolve(value).then(_next, _throw);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function _async_to_generator(fn) {
|
|
25
|
+
return function() {
|
|
26
|
+
var self1 = this, args = arguments;
|
|
27
|
+
return new Promise(function(resolve, reject) {
|
|
28
|
+
var gen = fn.apply(self1, args);
|
|
29
|
+
function _next(value) {
|
|
30
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
31
|
+
}
|
|
32
|
+
function _throw(err) {
|
|
33
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
34
|
+
}
|
|
35
|
+
_next(undefined);
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function _iterable_to_array_limit(arr, i) {
|
|
40
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
41
|
+
if (_i == null) return;
|
|
42
|
+
var _arr = [];
|
|
43
|
+
var _n = true;
|
|
44
|
+
var _d = false;
|
|
45
|
+
var _s, _e;
|
|
46
|
+
try {
|
|
47
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
48
|
+
_arr.push(_s.value);
|
|
49
|
+
if (i && _arr.length === i) break;
|
|
50
|
+
}
|
|
51
|
+
} catch (err) {
|
|
52
|
+
_d = true;
|
|
53
|
+
_e = err;
|
|
54
|
+
} finally{
|
|
55
|
+
try {
|
|
56
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
57
|
+
} finally{
|
|
58
|
+
if (_d) throw _e;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return _arr;
|
|
62
|
+
}
|
|
63
|
+
function _non_iterable_rest() {
|
|
64
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
65
|
+
}
|
|
66
|
+
function _sliced_to_array(arr, i) {
|
|
67
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
68
|
+
}
|
|
69
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
70
|
+
if (!o) return;
|
|
71
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
72
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
73
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
74
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
75
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
76
|
+
}
|
|
77
|
+
function _ts_generator(thisArg, body) {
|
|
78
|
+
var f, y, t, g, _ = {
|
|
79
|
+
label: 0,
|
|
80
|
+
sent: function() {
|
|
81
|
+
if (t[0] & 1) throw t[1];
|
|
82
|
+
return t[1];
|
|
83
|
+
},
|
|
84
|
+
trys: [],
|
|
85
|
+
ops: []
|
|
86
|
+
};
|
|
87
|
+
return g = {
|
|
88
|
+
next: verb(0),
|
|
89
|
+
"throw": verb(1),
|
|
90
|
+
"return": verb(2)
|
|
91
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
92
|
+
return this;
|
|
93
|
+
}), g;
|
|
94
|
+
function verb(n) {
|
|
95
|
+
return function(v) {
|
|
96
|
+
return step([
|
|
97
|
+
n,
|
|
98
|
+
v
|
|
99
|
+
]);
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
function step(op) {
|
|
103
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
104
|
+
while(_)try {
|
|
105
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
106
|
+
if (y = 0, t) op = [
|
|
107
|
+
op[0] & 2,
|
|
108
|
+
t.value
|
|
109
|
+
];
|
|
110
|
+
switch(op[0]){
|
|
111
|
+
case 0:
|
|
112
|
+
case 1:
|
|
113
|
+
t = op;
|
|
114
|
+
break;
|
|
115
|
+
case 4:
|
|
116
|
+
_.label++;
|
|
117
|
+
return {
|
|
118
|
+
value: op[1],
|
|
119
|
+
done: false
|
|
120
|
+
};
|
|
121
|
+
case 5:
|
|
122
|
+
_.label++;
|
|
123
|
+
y = op[1];
|
|
124
|
+
op = [
|
|
125
|
+
0
|
|
126
|
+
];
|
|
127
|
+
continue;
|
|
128
|
+
case 7:
|
|
129
|
+
op = _.ops.pop();
|
|
130
|
+
_.trys.pop();
|
|
131
|
+
continue;
|
|
132
|
+
default:
|
|
133
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
134
|
+
_ = 0;
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
138
|
+
_.label = op[1];
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
142
|
+
_.label = t[1];
|
|
143
|
+
t = op;
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
if (t && _.label < t[2]) {
|
|
147
|
+
_.label = t[2];
|
|
148
|
+
_.ops.push(op);
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
if (t[2]) _.ops.pop();
|
|
152
|
+
_.trys.pop();
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
op = body.call(thisArg, _);
|
|
156
|
+
} catch (e) {
|
|
157
|
+
op = [
|
|
158
|
+
6,
|
|
159
|
+
e
|
|
160
|
+
];
|
|
161
|
+
y = 0;
|
|
162
|
+
} finally{
|
|
163
|
+
f = t = 0;
|
|
164
|
+
}
|
|
165
|
+
if (op[0] & 5) throw op[1];
|
|
166
|
+
return {
|
|
167
|
+
value: op[0] ? op[1] : void 0,
|
|
168
|
+
done: true
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
}
|
|
2
172
|
var friendlySyntaxErrorLabel = "SyntaxError:";
|
|
3
173
|
function isLikelyASyntaxError(message) {
|
|
4
|
-
|
|
174
|
+
return message.includes(friendlySyntaxErrorLabel);
|
|
5
175
|
}
|
|
6
176
|
function formatMessage(stats) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
|
|
177
|
+
var lines = [];
|
|
178
|
+
var message;
|
|
179
|
+
if (typeof stats === "object") {
|
|
180
|
+
var fileName = stats.moduleName ? "File: ".concat(stats.moduleName, "\n") : "";
|
|
181
|
+
var mainMessage = typeof stats.formatted === "string" ? stats.formatted : stats.message;
|
|
182
|
+
var details = stats.details ? "\nDetails: ".concat(stats.details, "\n") : "";
|
|
183
|
+
var stack = stats.stack ? "\n".concat(stats.stack) : "";
|
|
184
|
+
message = "".concat(fileName).concat(mainMessage).concat(details).concat(stack);
|
|
185
|
+
} else {
|
|
186
|
+
message = stats;
|
|
187
|
+
}
|
|
188
|
+
lines = message.split("\n");
|
|
189
|
+
lines = lines.map(function(line) {
|
|
190
|
+
var parsingError = /Line (\d+):(?:(\d+):)?\s*Parsing error: (.+)$/.exec(line);
|
|
191
|
+
if (!parsingError) {
|
|
192
|
+
return line;
|
|
193
|
+
}
|
|
194
|
+
var _parsingError = _sliced_to_array(parsingError, 4), errorLine = _parsingError[1], errorColumn = _parsingError[2], errorMessage = _parsingError[3];
|
|
195
|
+
return "".concat(friendlySyntaxErrorLabel, " ").concat(errorMessage, " (").concat(errorLine, ":").concat(errorColumn, ")");
|
|
196
|
+
});
|
|
197
|
+
message = lines.join("\n");
|
|
198
|
+
message = message.replace(/SyntaxError\s+\((\d+):(\d+)\)\s*(.+?)\n/g, "".concat(friendlySyntaxErrorLabel, " $3 ($1:$2)\n"));
|
|
199
|
+
lines = message.split("\n");
|
|
200
|
+
if (lines.length > 2 && lines[1].trim() === "") {
|
|
201
|
+
lines.splice(1, 1);
|
|
202
|
+
}
|
|
203
|
+
lines[0] = lines[0].replace(/^(.*) \d+:\d+-\d+$/, "$1");
|
|
204
|
+
if (lines[1] && lines[1].indexOf("Module not found:") !== -1) {
|
|
205
|
+
lines[1] = lines[1].replace("Error: ", "");
|
|
29
206
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
/SyntaxError\s+\((\d+):(\d+)\)\s*(.+?)\n/g,
|
|
36
|
-
`${friendlySyntaxErrorLabel} $3 ($1:$2)
|
|
37
|
-
`
|
|
38
|
-
);
|
|
39
|
-
lines = message.split("\n");
|
|
40
|
-
if (lines.length > 2 && lines[1].trim() === "") {
|
|
41
|
-
lines.splice(1, 1);
|
|
42
|
-
}
|
|
43
|
-
lines[0] = lines[0].replace(/^(.*) \d+:\d+-\d+$/, "$1");
|
|
44
|
-
if (lines[1] && lines[1].indexOf("Module not found:") !== -1) {
|
|
45
|
-
lines[1] = lines[1].replace("Error: ", "");
|
|
46
|
-
}
|
|
47
|
-
lines = lines.filter(
|
|
48
|
-
(line, index, arr) => index === 0 || line.trim() !== "" || line.trim() !== arr[index - 1].trim()
|
|
49
|
-
);
|
|
50
|
-
message = lines.join("\n");
|
|
51
|
-
return message.trim();
|
|
207
|
+
lines = lines.filter(function(line, index, arr) {
|
|
208
|
+
return index === 0 || line.trim() !== "" || line.trim() !== arr[index - 1].trim();
|
|
209
|
+
});
|
|
210
|
+
message = lines.join("\n");
|
|
211
|
+
return message.trim();
|
|
52
212
|
}
|
|
53
213
|
function formatStatsMessages(json) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
result.errors.length
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
214
|
+
var _json_errors, _json_warnings, _result_errors;
|
|
215
|
+
var formattedErrors = json === null || json === void 0 ? void 0 : (_json_errors = json.errors) === null || _json_errors === void 0 ? void 0 : _json_errors.map(formatMessage);
|
|
216
|
+
var formattedWarnings = json === null || json === void 0 ? void 0 : (_json_warnings = json.warnings) === null || _json_warnings === void 0 ? void 0 : _json_warnings.map(formatMessage);
|
|
217
|
+
var result = {
|
|
218
|
+
errors: formattedErrors || [],
|
|
219
|
+
warnings: formattedWarnings || [],
|
|
220
|
+
errorTips: []
|
|
221
|
+
};
|
|
222
|
+
if ((_result_errors = result.errors) === null || _result_errors === void 0 ? void 0 : _result_errors.some(isLikelyASyntaxError)) {
|
|
223
|
+
result.errors = result.errors.filter(isLikelyASyntaxError);
|
|
224
|
+
}
|
|
225
|
+
if (result.errors.length > 1) {
|
|
226
|
+
result.errors.length = 1;
|
|
227
|
+
}
|
|
228
|
+
return result;
|
|
229
|
+
}
|
|
70
230
|
// src/client/hmr/createSocketUrl.ts
|
|
71
231
|
var HMR_SOCK_PATH = "/rsbuild-hmr";
|
|
72
232
|
function createSocketUrl(resourceQuery) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
233
|
+
var searchParams = resourceQuery.substr(1).split("&");
|
|
234
|
+
var options = {};
|
|
235
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
236
|
+
try {
|
|
237
|
+
for(var _iterator = searchParams[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
238
|
+
var pair = _step.value;
|
|
239
|
+
var ary = pair.split("=");
|
|
240
|
+
options[ary[0]] = decodeURIComponent(ary[1]);
|
|
241
|
+
}
|
|
242
|
+
} catch (err) {
|
|
243
|
+
_didIteratorError = true;
|
|
244
|
+
_iteratorError = err;
|
|
245
|
+
} finally{
|
|
246
|
+
try {
|
|
247
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
248
|
+
_iterator.return();
|
|
249
|
+
}
|
|
250
|
+
} finally{
|
|
251
|
+
if (_didIteratorError) {
|
|
252
|
+
throw _iteratorError;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
var currentLocation = self.location;
|
|
257
|
+
return getSocketUrl(options, currentLocation);
|
|
258
|
+
}
|
|
259
|
+
function formatURL(param) {
|
|
260
|
+
var port = param.port, protocol = param.protocol, hostname = param.hostname, pathname = param.pathname;
|
|
261
|
+
if (typeof URL !== "undefined") {
|
|
262
|
+
var url = new URL("http://localhost");
|
|
263
|
+
url.port = port;
|
|
264
|
+
url.hostname = hostname;
|
|
265
|
+
url.protocol = protocol;
|
|
266
|
+
url.pathname = pathname;
|
|
267
|
+
return url.toString();
|
|
268
|
+
}
|
|
269
|
+
var colon = protocol.indexOf(":") === -1 ? ":" : "";
|
|
270
|
+
return "".concat(protocol).concat(colon, "//").concat(hostname, ":").concat(port).concat(pathname);
|
|
98
271
|
}
|
|
99
272
|
function getSocketUrl(urlParts, location) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
|
|
273
|
+
var host = urlParts.host, port = urlParts.port, path = urlParts.path, protocol = urlParts.protocol;
|
|
274
|
+
return formatURL({
|
|
275
|
+
protocol: protocol || (location.protocol === "https:" ? "wss" : "ws"),
|
|
276
|
+
hostname: host || location.hostname,
|
|
277
|
+
port: port || location.port,
|
|
278
|
+
pathname: path || HMR_SOCK_PATH
|
|
279
|
+
});
|
|
280
|
+
}
|
|
109
281
|
// src/client/hmr/index.ts
|
|
110
282
|
var socketUrl = createSocketUrl(__resourceQuery);
|
|
111
283
|
var isFirstCompilation = true;
|
|
112
284
|
var mostRecentCompilationHash = null;
|
|
113
285
|
var hasCompileErrors = false;
|
|
114
286
|
function clearOutdatedErrors() {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
287
|
+
if (typeof console !== "undefined" && typeof console.clear === "function") {
|
|
288
|
+
if (hasCompileErrors) {
|
|
289
|
+
console.clear();
|
|
290
|
+
}
|
|
118
291
|
}
|
|
119
|
-
}
|
|
120
292
|
}
|
|
121
293
|
function handleSuccess() {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
294
|
+
clearOutdatedErrors();
|
|
295
|
+
var isHotUpdate = !isFirstCompilation;
|
|
296
|
+
isFirstCompilation = false;
|
|
297
|
+
hasCompileErrors = false;
|
|
298
|
+
if (isHotUpdate) {
|
|
299
|
+
tryApplyUpdates();
|
|
300
|
+
}
|
|
129
301
|
}
|
|
130
302
|
function handleWarnings(warnings) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
303
|
+
clearOutdatedErrors();
|
|
304
|
+
var isHotUpdate = !isFirstCompilation;
|
|
305
|
+
isFirstCompilation = false;
|
|
306
|
+
hasCompileErrors = false;
|
|
307
|
+
function printWarnings() {
|
|
308
|
+
var formatted = formatStatsMessages({
|
|
309
|
+
warnings: warnings,
|
|
310
|
+
errors: []
|
|
311
|
+
});
|
|
312
|
+
if (typeof console !== "undefined" && typeof console.warn === "function") {
|
|
313
|
+
for(var i = 0; i < formatted.warnings.length; i++){
|
|
314
|
+
if (i === 5) {
|
|
315
|
+
console.warn("There were more warnings in other files.\nYou can find a complete log in the terminal.");
|
|
316
|
+
break;
|
|
317
|
+
}
|
|
318
|
+
console.warn(formatted.warnings[i]);
|
|
319
|
+
}
|
|
147
320
|
}
|
|
148
|
-
console.warn(formatted.warnings[i]);
|
|
149
|
-
}
|
|
150
321
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
322
|
+
printWarnings();
|
|
323
|
+
if (isHotUpdate) {
|
|
324
|
+
tryApplyUpdates();
|
|
325
|
+
}
|
|
156
326
|
}
|
|
157
327
|
function handleErrors(errors) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
328
|
+
clearOutdatedErrors();
|
|
329
|
+
isFirstCompilation = false;
|
|
330
|
+
hasCompileErrors = true;
|
|
331
|
+
var formatted = formatStatsMessages({
|
|
332
|
+
errors: errors,
|
|
333
|
+
warnings: []
|
|
334
|
+
});
|
|
335
|
+
if (typeof console !== "undefined" && typeof console.error === "function") {
|
|
336
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
337
|
+
try {
|
|
338
|
+
for(var _iterator = formatted.errors[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
339
|
+
var error = _step.value;
|
|
340
|
+
console.error(error);
|
|
341
|
+
}
|
|
342
|
+
} catch (err) {
|
|
343
|
+
_didIteratorError = true;
|
|
344
|
+
_iteratorError = err;
|
|
345
|
+
} finally{
|
|
346
|
+
try {
|
|
347
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
348
|
+
_iterator.return();
|
|
349
|
+
}
|
|
350
|
+
} finally{
|
|
351
|
+
if (_didIteratorError) {
|
|
352
|
+
throw _iteratorError;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
168
356
|
}
|
|
169
|
-
}
|
|
170
357
|
}
|
|
171
358
|
function handleAvailableHash(hash) {
|
|
172
|
-
|
|
359
|
+
mostRecentCompilationHash = hash;
|
|
173
360
|
}
|
|
174
361
|
function isUpdateAvailable() {
|
|
175
|
-
|
|
362
|
+
return mostRecentCompilationHash !== __webpack_hash__;
|
|
176
363
|
}
|
|
177
364
|
function canApplyUpdates() {
|
|
178
|
-
|
|
365
|
+
return import.meta.webpackHot.status() === "idle";
|
|
179
366
|
}
|
|
180
367
|
function tryApplyUpdates() {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
if (!canApplyUpdates()) {
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
|
-
function handleApplyUpdates(err, updatedModules) {
|
|
192
|
-
const wantsForcedReload = err || !updatedModules;
|
|
193
|
-
if (wantsForcedReload) {
|
|
194
|
-
window.location.reload();
|
|
195
|
-
return;
|
|
368
|
+
if (!isUpdateAvailable()) {
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
if (!import.meta.webpackHot) {
|
|
372
|
+
window.location.reload();
|
|
373
|
+
return;
|
|
196
374
|
}
|
|
197
|
-
if (
|
|
198
|
-
|
|
375
|
+
if (!canApplyUpdates()) {
|
|
376
|
+
return;
|
|
199
377
|
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
378
|
+
function handleApplyUpdates(err, updatedModules) {
|
|
379
|
+
var wantsForcedReload = err || !updatedModules;
|
|
380
|
+
if (wantsForcedReload) {
|
|
381
|
+
window.location.reload();
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
if (isUpdateAvailable()) {
|
|
385
|
+
tryApplyUpdates();
|
|
386
|
+
}
|
|
207
387
|
}
|
|
208
|
-
|
|
388
|
+
import.meta.webpackHot.check(true).then(function(updatedModules) {
|
|
389
|
+
handleApplyUpdates(null, updatedModules);
|
|
390
|
+
}, function(err) {
|
|
391
|
+
handleApplyUpdates(err, null);
|
|
392
|
+
});
|
|
209
393
|
}
|
|
210
394
|
var MAX_RETRIES = 100;
|
|
211
395
|
var connection = null;
|
|
212
396
|
var retry_counter = 0;
|
|
213
397
|
function onOpen() {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
398
|
+
if (typeof console !== "undefined" && typeof console.info === "function") {
|
|
399
|
+
console.info("[HMR] connected.");
|
|
400
|
+
}
|
|
217
401
|
}
|
|
218
402
|
function onMessage(e) {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
async function sleep(msec = 1e3) {
|
|
241
|
-
return new Promise((resolve) => {
|
|
242
|
-
setTimeout(resolve, msec);
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
async function onClose() {
|
|
246
|
-
if (typeof console !== "undefined" && typeof console.info === "function") {
|
|
247
|
-
console.info("[HMR] disconnected. Attempting to reconnect.");
|
|
248
|
-
}
|
|
249
|
-
removeListeners();
|
|
250
|
-
await sleep(1e3);
|
|
251
|
-
retry_counter++;
|
|
252
|
-
if (connection && (connection.readyState === connection.CONNECTING || connection.readyState === connection.OPEN)) {
|
|
253
|
-
retry_counter = 0;
|
|
254
|
-
return;
|
|
255
|
-
}
|
|
256
|
-
if (retry_counter > MAX_RETRIES) {
|
|
257
|
-
if (typeof console !== "undefined" && typeof console.info === "function") {
|
|
258
|
-
console.info(
|
|
259
|
-
"[HMR] Unable to establish a connection after exceeding the maximum retry attempts."
|
|
260
|
-
);
|
|
403
|
+
var message = JSON.parse(e.data);
|
|
404
|
+
switch(message.type){
|
|
405
|
+
case "hash":
|
|
406
|
+
handleAvailableHash(message.data);
|
|
407
|
+
break;
|
|
408
|
+
case "still-ok":
|
|
409
|
+
case "ok":
|
|
410
|
+
handleSuccess();
|
|
411
|
+
break;
|
|
412
|
+
case "content-changed":
|
|
413
|
+
window.location.reload();
|
|
414
|
+
break;
|
|
415
|
+
case "warnings":
|
|
416
|
+
handleWarnings(message.data);
|
|
417
|
+
break;
|
|
418
|
+
case "errors":
|
|
419
|
+
handleErrors(message.data);
|
|
420
|
+
break;
|
|
421
|
+
default:
|
|
261
422
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
423
|
+
}
|
|
424
|
+
function sleep() {
|
|
425
|
+
return _sleep.apply(this, arguments);
|
|
426
|
+
}
|
|
427
|
+
function _sleep() {
|
|
428
|
+
_sleep = _async_to_generator(function() {
|
|
429
|
+
var msec;
|
|
430
|
+
var _arguments = arguments;
|
|
431
|
+
return _ts_generator(this, function(_state) {
|
|
432
|
+
msec = _arguments.length > 0 && _arguments[0] !== void 0 ? _arguments[0] : 1e3;
|
|
433
|
+
return [
|
|
434
|
+
2,
|
|
435
|
+
new Promise(function(resolve) {
|
|
436
|
+
setTimeout(resolve, msec);
|
|
437
|
+
})
|
|
438
|
+
];
|
|
439
|
+
});
|
|
440
|
+
});
|
|
441
|
+
return _sleep.apply(this, arguments);
|
|
442
|
+
}
|
|
443
|
+
function onClose() {
|
|
444
|
+
return _onClose.apply(this, arguments);
|
|
445
|
+
}
|
|
446
|
+
function _onClose() {
|
|
447
|
+
_onClose = _async_to_generator(function() {
|
|
448
|
+
return _ts_generator(this, function(_state) {
|
|
449
|
+
switch(_state.label){
|
|
450
|
+
case 0:
|
|
451
|
+
if (typeof console !== "undefined" && typeof console.info === "function") {
|
|
452
|
+
console.info("[HMR] disconnected. Attempting to reconnect.");
|
|
453
|
+
}
|
|
454
|
+
removeListeners();
|
|
455
|
+
return [
|
|
456
|
+
4,
|
|
457
|
+
sleep(1e3)
|
|
458
|
+
];
|
|
459
|
+
case 1:
|
|
460
|
+
_state.sent();
|
|
461
|
+
retry_counter++;
|
|
462
|
+
if (connection && (connection.readyState === connection.CONNECTING || connection.readyState === connection.OPEN)) {
|
|
463
|
+
retry_counter = 0;
|
|
464
|
+
return [
|
|
465
|
+
2
|
|
466
|
+
];
|
|
467
|
+
}
|
|
468
|
+
if (retry_counter > MAX_RETRIES) {
|
|
469
|
+
if (typeof console !== "undefined" && typeof console.info === "function") {
|
|
470
|
+
console.info("[HMR] Unable to establish a connection after exceeding the maximum retry attempts.");
|
|
471
|
+
}
|
|
472
|
+
retry_counter = 0;
|
|
473
|
+
return [
|
|
474
|
+
2
|
|
475
|
+
];
|
|
476
|
+
}
|
|
477
|
+
reconnect();
|
|
478
|
+
return [
|
|
479
|
+
2
|
|
480
|
+
];
|
|
481
|
+
}
|
|
482
|
+
});
|
|
483
|
+
});
|
|
484
|
+
return _onClose.apply(this, arguments);
|
|
266
485
|
}
|
|
267
486
|
function connect() {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
487
|
+
connection = new WebSocket(socketUrl);
|
|
488
|
+
connection.addEventListener("open", onOpen);
|
|
489
|
+
connection.addEventListener("close", onClose);
|
|
490
|
+
connection.addEventListener("message", onMessage);
|
|
272
491
|
}
|
|
273
492
|
function removeListeners() {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
493
|
+
if (connection) {
|
|
494
|
+
connection.removeEventListener("open", onOpen);
|
|
495
|
+
connection.removeEventListener("close", onClose);
|
|
496
|
+
connection.removeEventListener("message", onMessage);
|
|
497
|
+
}
|
|
279
498
|
}
|
|
280
499
|
function reconnect() {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
500
|
+
if (connection) {
|
|
501
|
+
connection = null;
|
|
502
|
+
}
|
|
503
|
+
connect();
|
|
285
504
|
}
|
|
286
505
|
connect();
|