@modern-js/server 2.19.1 → 2.21.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/CHANGELOG.md +48 -0
- package/dist/cjs/constants.js +1 -0
- package/dist/cjs/dev-tools/dev-middleware/hmr-client/index.js +5 -9
- package/dist/cjs/dev-tools/dev-middleware/index.js +6 -22
- package/dist/cjs/dev-tools/dev-middleware/socketServer.js +9 -25
- package/dist/cjs/dev-tools/mock/index.js +4 -47
- package/dist/cjs/dev-tools/register/index.js +2 -6
- package/dist/cjs/dev-tools/watcher/dependencyTree.js +5 -21
- package/dist/cjs/dev-tools/watcher/index.js +5 -21
- package/dist/cjs/dev-tools/watcher/statsCache.js +6 -22
- package/dist/cjs/server/devServer.js +21 -67
- package/dist/esm/constants.js +1 -0
- package/dist/esm/dev-tools/dev-middleware/hmr-client/index.js +3 -3
- package/dist/esm/dev-tools/dev-middleware/index.js +10 -253
- package/dist/esm/dev-tools/dev-middleware/socketServer.js +3 -35
- package/dist/esm/dev-tools/https/index.js +3 -132
- package/dist/esm/dev-tools/mock/getMockData.js +7 -246
- package/dist/esm/dev-tools/mock/index.js +3 -132
- package/dist/esm/dev-tools/register/index.js +3 -52
- package/dist/esm/dev-tools/watcher/dependencyTree.js +4 -69
- package/dist/esm/dev-tools/watcher/index.js +5 -84
- package/dist/esm/dev-tools/watcher/statsCache.js +3 -35
- package/dist/esm/server/devServer.js +45 -348
- package/dist/esm/server/index.js +3 -76
- package/dist/esm-node/constants.js +1 -0
- package/dist/esm-node/dev-tools/dev-middleware/hmr-client/index.js +3 -3
- package/dist/esm-node/dev-tools/dev-middleware/index.js +1 -13
- package/dist/esm-node/dev-tools/dev-middleware/socketServer.js +1 -13
- package/dist/esm-node/dev-tools/watcher/dependencyTree.js +1 -13
- package/dist/esm-node/dev-tools/watcher/index.js +1 -13
- package/dist/esm-node/dev-tools/watcher/statsCache.js +1 -13
- package/dist/esm-node/server/devServer.js +10 -13
- package/dist/types/dev-tools/mock/getMockData.d.ts +0 -2
- package/dist/types/dev-tools/watcher/dependencyTree.d.ts +0 -2
- package/dist/types/index.d.ts +0 -2
- package/dist/types/types.d.ts +0 -3
- package/package.json +14 -12
|
@@ -1,337 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
if (Array.isArray(arr))
|
|
14
|
-
return _array_like_to_array(arr);
|
|
15
|
-
}
|
|
16
|
-
function _assert_this_initialized(self) {
|
|
17
|
-
if (self === void 0) {
|
|
18
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
19
|
-
}
|
|
20
|
-
return self;
|
|
21
|
-
}
|
|
22
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
23
|
-
try {
|
|
24
|
-
var info = gen[key](arg);
|
|
25
|
-
var value = info.value;
|
|
26
|
-
} catch (error) {
|
|
27
|
-
reject(error);
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
if (info.done) {
|
|
31
|
-
resolve(value);
|
|
32
|
-
} else {
|
|
33
|
-
Promise.resolve(value).then(_next, _throw);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
function _async_to_generator(fn) {
|
|
37
|
-
return function() {
|
|
38
|
-
var self = this, args = arguments;
|
|
39
|
-
return new Promise(function(resolve, reject) {
|
|
40
|
-
var gen = fn.apply(self, args);
|
|
41
|
-
function _next(value) {
|
|
42
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
43
|
-
}
|
|
44
|
-
function _throw(err) {
|
|
45
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
46
|
-
}
|
|
47
|
-
_next(void 0);
|
|
48
|
-
});
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
function _class_call_check(instance, Constructor) {
|
|
52
|
-
if (!(instance instanceof Constructor)) {
|
|
53
|
-
throw new TypeError("Cannot call a class as a function");
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
function _defineProperties(target, props) {
|
|
57
|
-
for (var i = 0; i < props.length; i++) {
|
|
58
|
-
var descriptor = props[i];
|
|
59
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
60
|
-
descriptor.configurable = true;
|
|
61
|
-
if ("value" in descriptor)
|
|
62
|
-
descriptor.writable = true;
|
|
63
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
function _create_class(Constructor, protoProps, staticProps) {
|
|
67
|
-
if (protoProps)
|
|
68
|
-
_defineProperties(Constructor.prototype, protoProps);
|
|
69
|
-
if (staticProps)
|
|
70
|
-
_defineProperties(Constructor, staticProps);
|
|
71
|
-
return Constructor;
|
|
72
|
-
}
|
|
73
|
-
function _define_property(obj, key, value) {
|
|
74
|
-
if (key in obj) {
|
|
75
|
-
Object.defineProperty(obj, key, {
|
|
76
|
-
value: value,
|
|
77
|
-
enumerable: true,
|
|
78
|
-
configurable: true,
|
|
79
|
-
writable: true
|
|
80
|
-
});
|
|
81
|
-
} else {
|
|
82
|
-
obj[key] = value;
|
|
83
|
-
}
|
|
84
|
-
return obj;
|
|
85
|
-
}
|
|
86
|
-
function _get(target, property, receiver) {
|
|
87
|
-
if (typeof Reflect !== "undefined" && Reflect.get) {
|
|
88
|
-
_get = Reflect.get;
|
|
89
|
-
} else {
|
|
90
|
-
_get = function get(target2, property2, receiver2) {
|
|
91
|
-
var base = _super_prop_base(target2, property2);
|
|
92
|
-
if (!base)
|
|
93
|
-
return;
|
|
94
|
-
var desc = Object.getOwnPropertyDescriptor(base, property2);
|
|
95
|
-
if (desc.get) {
|
|
96
|
-
return desc.get.call(receiver2 || target2);
|
|
97
|
-
}
|
|
98
|
-
return desc.value;
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
return _get(target, property, receiver || target);
|
|
102
|
-
}
|
|
103
|
-
function _get_prototype_of(o) {
|
|
104
|
-
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o2) {
|
|
105
|
-
return o2.__proto__ || Object.getPrototypeOf(o2);
|
|
106
|
-
};
|
|
107
|
-
return _get_prototype_of(o);
|
|
108
|
-
}
|
|
109
|
-
function _inherits(subClass, superClass) {
|
|
110
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
111
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
112
|
-
}
|
|
113
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
114
|
-
constructor: {
|
|
115
|
-
value: subClass,
|
|
116
|
-
writable: true,
|
|
117
|
-
configurable: true
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
if (superClass)
|
|
121
|
-
_set_prototype_of(subClass, superClass);
|
|
122
|
-
}
|
|
123
|
-
function _iterable_to_array(iter) {
|
|
124
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null)
|
|
125
|
-
return Array.from(iter);
|
|
126
|
-
}
|
|
127
|
-
function _iterable_to_array_limit(arr, i) {
|
|
128
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
129
|
-
if (_i == null)
|
|
130
|
-
return;
|
|
131
|
-
var _arr = [];
|
|
132
|
-
var _n = true;
|
|
133
|
-
var _d = false;
|
|
134
|
-
var _s, _e;
|
|
135
|
-
try {
|
|
136
|
-
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
137
|
-
_arr.push(_s.value);
|
|
138
|
-
if (i && _arr.length === i)
|
|
139
|
-
break;
|
|
140
|
-
}
|
|
141
|
-
} catch (err) {
|
|
142
|
-
_d = true;
|
|
143
|
-
_e = err;
|
|
144
|
-
} finally {
|
|
145
|
-
try {
|
|
146
|
-
if (!_n && _i["return"] != null)
|
|
147
|
-
_i["return"]();
|
|
148
|
-
} finally {
|
|
149
|
-
if (_d)
|
|
150
|
-
throw _e;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
return _arr;
|
|
154
|
-
}
|
|
155
|
-
function _non_iterable_rest() {
|
|
156
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
157
|
-
}
|
|
158
|
-
function _non_iterable_spread() {
|
|
159
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
160
|
-
}
|
|
161
|
-
function _possible_constructor_return(self, call) {
|
|
162
|
-
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
163
|
-
return call;
|
|
164
|
-
}
|
|
165
|
-
return _assert_this_initialized(self);
|
|
166
|
-
}
|
|
167
|
-
function _set_prototype_of(o, p) {
|
|
168
|
-
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o2, p2) {
|
|
169
|
-
o2.__proto__ = p2;
|
|
170
|
-
return o2;
|
|
171
|
-
};
|
|
172
|
-
return _set_prototype_of(o, p);
|
|
173
|
-
}
|
|
174
|
-
function _sliced_to_array(arr, i) {
|
|
175
|
-
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
176
|
-
}
|
|
177
|
-
function _super_prop_base(object, property) {
|
|
178
|
-
while (!Object.prototype.hasOwnProperty.call(object, property)) {
|
|
179
|
-
object = _get_prototype_of(object);
|
|
180
|
-
if (object === null)
|
|
181
|
-
break;
|
|
182
|
-
}
|
|
183
|
-
return object;
|
|
184
|
-
}
|
|
185
|
-
function _to_consumable_array(arr) {
|
|
186
|
-
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
187
|
-
}
|
|
188
|
-
function _type_of(obj) {
|
|
189
|
-
"@swc/helpers - typeof";
|
|
190
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
191
|
-
}
|
|
192
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
193
|
-
if (!o)
|
|
194
|
-
return;
|
|
195
|
-
if (typeof o === "string")
|
|
196
|
-
return _array_like_to_array(o, minLen);
|
|
197
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
198
|
-
if (n === "Object" && o.constructor)
|
|
199
|
-
n = o.constructor.name;
|
|
200
|
-
if (n === "Map" || n === "Set")
|
|
201
|
-
return Array.from(n);
|
|
202
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
|
|
203
|
-
return _array_like_to_array(o, minLen);
|
|
204
|
-
}
|
|
205
|
-
function _is_native_reflect_construct() {
|
|
206
|
-
if (typeof Reflect === "undefined" || !Reflect.construct)
|
|
207
|
-
return false;
|
|
208
|
-
if (Reflect.construct.sham)
|
|
209
|
-
return false;
|
|
210
|
-
if (typeof Proxy === "function")
|
|
211
|
-
return true;
|
|
212
|
-
try {
|
|
213
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
|
|
214
|
-
}));
|
|
215
|
-
return true;
|
|
216
|
-
} catch (e) {
|
|
217
|
-
return false;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
function _create_super(Derived) {
|
|
221
|
-
var hasNativeReflectConstruct = _is_native_reflect_construct();
|
|
222
|
-
return function _createSuperInternal() {
|
|
223
|
-
var Super = _get_prototype_of(Derived), result;
|
|
224
|
-
if (hasNativeReflectConstruct) {
|
|
225
|
-
var NewTarget = _get_prototype_of(this).constructor;
|
|
226
|
-
result = Reflect.construct(Super, arguments, NewTarget);
|
|
227
|
-
} else {
|
|
228
|
-
result = Super.apply(this, arguments);
|
|
229
|
-
}
|
|
230
|
-
return _possible_constructor_return(this, result);
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
var __generator = function(thisArg, body) {
|
|
234
|
-
var f, y, t, g, _ = {
|
|
235
|
-
label: 0,
|
|
236
|
-
sent: function() {
|
|
237
|
-
if (t[0] & 1)
|
|
238
|
-
throw t[1];
|
|
239
|
-
return t[1];
|
|
240
|
-
},
|
|
241
|
-
trys: [],
|
|
242
|
-
ops: []
|
|
243
|
-
};
|
|
244
|
-
return g = {
|
|
245
|
-
next: verb(0),
|
|
246
|
-
"throw": verb(1),
|
|
247
|
-
"return": verb(2)
|
|
248
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
249
|
-
return this;
|
|
250
|
-
}), g;
|
|
251
|
-
function verb(n) {
|
|
252
|
-
return function(v) {
|
|
253
|
-
return step([
|
|
254
|
-
n,
|
|
255
|
-
v
|
|
256
|
-
]);
|
|
257
|
-
};
|
|
258
|
-
}
|
|
259
|
-
function step(op) {
|
|
260
|
-
if (f)
|
|
261
|
-
throw new TypeError("Generator is already executing.");
|
|
262
|
-
while (_)
|
|
263
|
-
try {
|
|
264
|
-
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)
|
|
265
|
-
return t;
|
|
266
|
-
if (y = 0, t)
|
|
267
|
-
op = [
|
|
268
|
-
op[0] & 2,
|
|
269
|
-
t.value
|
|
270
|
-
];
|
|
271
|
-
switch (op[0]) {
|
|
272
|
-
case 0:
|
|
273
|
-
case 1:
|
|
274
|
-
t = op;
|
|
275
|
-
break;
|
|
276
|
-
case 4:
|
|
277
|
-
_.label++;
|
|
278
|
-
return {
|
|
279
|
-
value: op[1],
|
|
280
|
-
done: false
|
|
281
|
-
};
|
|
282
|
-
case 5:
|
|
283
|
-
_.label++;
|
|
284
|
-
y = op[1];
|
|
285
|
-
op = [
|
|
286
|
-
0
|
|
287
|
-
];
|
|
288
|
-
continue;
|
|
289
|
-
case 7:
|
|
290
|
-
op = _.ops.pop();
|
|
291
|
-
_.trys.pop();
|
|
292
|
-
continue;
|
|
293
|
-
default:
|
|
294
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
295
|
-
_ = 0;
|
|
296
|
-
continue;
|
|
297
|
-
}
|
|
298
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
299
|
-
_.label = op[1];
|
|
300
|
-
break;
|
|
301
|
-
}
|
|
302
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
303
|
-
_.label = t[1];
|
|
304
|
-
t = op;
|
|
305
|
-
break;
|
|
306
|
-
}
|
|
307
|
-
if (t && _.label < t[2]) {
|
|
308
|
-
_.label = t[2];
|
|
309
|
-
_.ops.push(op);
|
|
310
|
-
break;
|
|
311
|
-
}
|
|
312
|
-
if (t[2])
|
|
313
|
-
_.ops.pop();
|
|
314
|
-
_.trys.pop();
|
|
315
|
-
continue;
|
|
316
|
-
}
|
|
317
|
-
op = body.call(thisArg, _);
|
|
318
|
-
} catch (e) {
|
|
319
|
-
op = [
|
|
320
|
-
6,
|
|
321
|
-
e
|
|
322
|
-
];
|
|
323
|
-
y = 0;
|
|
324
|
-
} finally {
|
|
325
|
-
f = t = 0;
|
|
326
|
-
}
|
|
327
|
-
if (op[0] & 5)
|
|
328
|
-
throw op[1];
|
|
329
|
-
return {
|
|
330
|
-
value: op[0] ? op[1] : void 0,
|
|
331
|
-
done: true
|
|
332
|
-
};
|
|
333
|
-
}
|
|
334
|
-
};
|
|
1
|
+
import { _ as _assert_this_initialized } from "@swc/helpers/_/_assert_this_initialized";
|
|
2
|
+
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
3
|
+
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
|
|
4
|
+
import { _ as _create_class } from "@swc/helpers/_/_create_class";
|
|
5
|
+
import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
|
6
|
+
import { _ as _get } from "@swc/helpers/_/_get";
|
|
7
|
+
import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of";
|
|
8
|
+
import { _ as _inherits } from "@swc/helpers/_/_inherits";
|
|
9
|
+
import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
|
|
10
|
+
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
|
11
|
+
import { _ as _create_super } from "@swc/helpers/_/_create_super";
|
|
12
|
+
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
335
13
|
import { createServer } from "http";
|
|
336
14
|
import path from "path";
|
|
337
15
|
import { createServer as createHttpsServer } from "https";
|
|
@@ -433,7 +111,7 @@ export var ModernDevServer = /* @__PURE__ */ function(ModernServer2) {
|
|
|
433
111
|
};
|
|
434
112
|
return _async_to_generator(function() {
|
|
435
113
|
var dev, _this_applySetupMiddlewares, befores, afters, beforeHandlers, afterHandlers;
|
|
436
|
-
return
|
|
114
|
+
return _ts_generator(this, function(_state) {
|
|
437
115
|
switch (_state.label) {
|
|
438
116
|
case 0:
|
|
439
117
|
_this1.runner = runner;
|
|
@@ -469,7 +147,7 @@ export var ModernDevServer = /* @__PURE__ */ function(ModernServer2) {
|
|
|
469
147
|
_this1.startWatcher();
|
|
470
148
|
app.on("close", /* @__PURE__ */ _async_to_generator(function() {
|
|
471
149
|
var _this_watcher;
|
|
472
|
-
return
|
|
150
|
+
return _ts_generator(this, function(_state2) {
|
|
473
151
|
switch (_state2.label) {
|
|
474
152
|
case 0:
|
|
475
153
|
return [
|
|
@@ -499,11 +177,30 @@ export var ModernDevServer = /* @__PURE__ */ function(ModernServer2) {
|
|
|
499
177
|
value: function applyDefaultMiddlewares(app) {
|
|
500
178
|
var _this = this;
|
|
501
179
|
return _async_to_generator(function() {
|
|
502
|
-
var pwd, dev, devMiddleware, proxyHandlers,
|
|
503
|
-
return
|
|
180
|
+
var pwd, dev, devMiddleware, _ref, compression, proxyHandlers, _ref1, connectHistoryApiFallback, historyApiFallbackMiddleware;
|
|
181
|
+
return _ts_generator(this, function(_state) {
|
|
504
182
|
switch (_state.label) {
|
|
505
183
|
case 0:
|
|
506
184
|
pwd = _this.pwd, dev = _this.dev, devMiddleware = _this.devMiddleware;
|
|
185
|
+
if (!dev.compress)
|
|
186
|
+
return [
|
|
187
|
+
3,
|
|
188
|
+
2
|
|
189
|
+
];
|
|
190
|
+
return [
|
|
191
|
+
4,
|
|
192
|
+
import("http-compression")
|
|
193
|
+
];
|
|
194
|
+
case 1:
|
|
195
|
+
_ref = _state.sent(), compression = _ref.default;
|
|
196
|
+
_this.addHandler(function(ctx, next) {
|
|
197
|
+
compression({
|
|
198
|
+
gzip: true,
|
|
199
|
+
brotli: false
|
|
200
|
+
})(ctx.req, ctx.res, next);
|
|
201
|
+
});
|
|
202
|
+
_state.label = 2;
|
|
203
|
+
case 2:
|
|
507
204
|
_this.addHandler(function(ctx, next) {
|
|
508
205
|
ctx.res.setHeader("Access-Control-Allow-Origin", "*");
|
|
509
206
|
if (ctx.path.includes("hot-update")) {
|
|
@@ -571,20 +268,20 @@ export var ModernDevServer = /* @__PURE__ */ function(ModernServer2) {
|
|
|
571
268
|
if (!dev.historyApiFallback)
|
|
572
269
|
return [
|
|
573
270
|
3,
|
|
574
|
-
|
|
271
|
+
4
|
|
575
272
|
];
|
|
576
273
|
return [
|
|
577
274
|
4,
|
|
578
275
|
import("connect-history-api-fallback")
|
|
579
276
|
];
|
|
580
|
-
case
|
|
581
|
-
|
|
277
|
+
case 3:
|
|
278
|
+
_ref1 = _state.sent(), connectHistoryApiFallback = _ref1.default;
|
|
582
279
|
historyApiFallbackMiddleware = connectHistoryApiFallback(typeof dev.historyApiFallback === "boolean" ? {} : dev.historyApiFallback);
|
|
583
280
|
_this.addHandler(function(ctx, next) {
|
|
584
281
|
return historyApiFallbackMiddleware(ctx.req, ctx.res, next);
|
|
585
282
|
});
|
|
586
|
-
_state.label =
|
|
587
|
-
case
|
|
283
|
+
_state.label = 4;
|
|
284
|
+
case 4:
|
|
588
285
|
return [
|
|
589
286
|
2
|
|
590
287
|
];
|
|
@@ -612,7 +309,7 @@ export var ModernDevServer = /* @__PURE__ */ function(ModernServer2) {
|
|
|
612
309
|
var _this = this;
|
|
613
310
|
return _async_to_generator(function() {
|
|
614
311
|
var dev, devHttpsOption, genHttpsOptions, httpsOptions;
|
|
615
|
-
return
|
|
312
|
+
return _ts_generator(this, function(_state) {
|
|
616
313
|
switch (_state.label) {
|
|
617
314
|
case 0:
|
|
618
315
|
dev = _this.dev;
|
|
@@ -662,7 +359,7 @@ export var ModernDevServer = /* @__PURE__ */ function(ModernServer2) {
|
|
|
662
359
|
};
|
|
663
360
|
return _async_to_generator(function() {
|
|
664
361
|
var pwd, mock, mockPath, success, e;
|
|
665
|
-
return
|
|
362
|
+
return _ts_generator(this, function(_state) {
|
|
666
363
|
switch (_state.label) {
|
|
667
364
|
case 0:
|
|
668
365
|
pwd = _this1.pwd;
|
|
@@ -742,7 +439,7 @@ export var ModernDevServer = /* @__PURE__ */ function(ModernServer2) {
|
|
|
742
439
|
value: function setupStaticMiddleware(_) {
|
|
743
440
|
return function() {
|
|
744
441
|
var _ref = _async_to_generator(function(context, next) {
|
|
745
|
-
return
|
|
442
|
+
return _ts_generator(this, function(_state) {
|
|
746
443
|
return [
|
|
747
444
|
2,
|
|
748
445
|
next()
|
|
@@ -761,7 +458,7 @@ export var ModernDevServer = /* @__PURE__ */ function(ModernServer2) {
|
|
|
761
458
|
var _this = this;
|
|
762
459
|
return _async_to_generator(function() {
|
|
763
460
|
var runner, conf, dev, setupMids, pluginMids;
|
|
764
|
-
return
|
|
461
|
+
return _ts_generator(this, function(_state) {
|
|
765
462
|
switch (_state.label) {
|
|
766
463
|
case 0:
|
|
767
464
|
runner = _this.runner, conf = _this.conf, dev = _this.dev;
|
|
@@ -787,7 +484,7 @@ export var ModernDevServer = /* @__PURE__ */ function(ModernServer2) {
|
|
|
787
484
|
var _this = this;
|
|
788
485
|
return _async_to_generator(function() {
|
|
789
486
|
var runner, conf, dev, setupMids, pluginMids;
|
|
790
|
-
return
|
|
487
|
+
return _ts_generator(this, function(_state) {
|
|
791
488
|
switch (_state.label) {
|
|
792
489
|
case 0:
|
|
793
490
|
runner = _this.runner, conf = _this.conf, dev = _this.dev;
|
package/dist/esm/server/index.js
CHANGED
|
@@ -1,79 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
return self;
|
|
6
|
-
}
|
|
7
|
-
function _class_call_check(instance, Constructor) {
|
|
8
|
-
if (!(instance instanceof Constructor)) {
|
|
9
|
-
throw new TypeError("Cannot call a class as a function");
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
function _get_prototype_of(o) {
|
|
13
|
-
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o2) {
|
|
14
|
-
return o2.__proto__ || Object.getPrototypeOf(o2);
|
|
15
|
-
};
|
|
16
|
-
return _get_prototype_of(o);
|
|
17
|
-
}
|
|
18
|
-
function _inherits(subClass, superClass) {
|
|
19
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
20
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
21
|
-
}
|
|
22
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
23
|
-
constructor: {
|
|
24
|
-
value: subClass,
|
|
25
|
-
writable: true,
|
|
26
|
-
configurable: true
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
if (superClass)
|
|
30
|
-
_set_prototype_of(subClass, superClass);
|
|
31
|
-
}
|
|
32
|
-
function _possible_constructor_return(self, call) {
|
|
33
|
-
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
34
|
-
return call;
|
|
35
|
-
}
|
|
36
|
-
return _assert_this_initialized(self);
|
|
37
|
-
}
|
|
38
|
-
function _set_prototype_of(o, p) {
|
|
39
|
-
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o2, p2) {
|
|
40
|
-
o2.__proto__ = p2;
|
|
41
|
-
return o2;
|
|
42
|
-
};
|
|
43
|
-
return _set_prototype_of(o, p);
|
|
44
|
-
}
|
|
45
|
-
function _type_of(obj) {
|
|
46
|
-
"@swc/helpers - typeof";
|
|
47
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
48
|
-
}
|
|
49
|
-
function _is_native_reflect_construct() {
|
|
50
|
-
if (typeof Reflect === "undefined" || !Reflect.construct)
|
|
51
|
-
return false;
|
|
52
|
-
if (Reflect.construct.sham)
|
|
53
|
-
return false;
|
|
54
|
-
if (typeof Proxy === "function")
|
|
55
|
-
return true;
|
|
56
|
-
try {
|
|
57
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
|
|
58
|
-
}));
|
|
59
|
-
return true;
|
|
60
|
-
} catch (e) {
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
function _create_super(Derived) {
|
|
65
|
-
var hasNativeReflectConstruct = _is_native_reflect_construct();
|
|
66
|
-
return function _createSuperInternal() {
|
|
67
|
-
var Super = _get_prototype_of(Derived), result;
|
|
68
|
-
if (hasNativeReflectConstruct) {
|
|
69
|
-
var NewTarget = _get_prototype_of(this).constructor;
|
|
70
|
-
result = Reflect.construct(Super, arguments, NewTarget);
|
|
71
|
-
} else {
|
|
72
|
-
result = Super.apply(this, arguments);
|
|
73
|
-
}
|
|
74
|
-
return _possible_constructor_return(this, result);
|
|
75
|
-
};
|
|
76
|
-
}
|
|
1
|
+
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
|
|
2
|
+
import { _ as _inherits } from "@swc/helpers/_/_inherits";
|
|
3
|
+
import { _ as _create_super } from "@swc/helpers/_/_create_super";
|
|
77
4
|
import { Server } from "@modern-js/prod-server";
|
|
78
5
|
import { ModernDevServer } from "./devServer";
|
|
79
6
|
var createDevServer = function(options) {
|
|
@@ -5,13 +5,13 @@ const hadRuntimeError = false;
|
|
|
5
5
|
const socketUrl = createSocketUrl(__resourceQuery);
|
|
6
6
|
const connection = new WebSocket(socketUrl);
|
|
7
7
|
connection.onopen = function() {
|
|
8
|
-
if (typeof console !== "undefined" && typeof console.
|
|
9
|
-
console.
|
|
8
|
+
if (typeof console !== "undefined" && typeof console.info === "function") {
|
|
9
|
+
console.info("[HMR] connected.");
|
|
10
10
|
}
|
|
11
11
|
};
|
|
12
12
|
connection.onclose = function() {
|
|
13
13
|
if (typeof console !== "undefined" && typeof console.info === "function") {
|
|
14
|
-
console.
|
|
14
|
+
console.info("[HMR] disconnected. Refresh the page if necessary.");
|
|
15
15
|
}
|
|
16
16
|
};
|
|
17
17
|
let isFirstCompilation = true;
|
|
@@ -1,16 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
if (key in obj) {
|
|
3
|
-
Object.defineProperty(obj, key, {
|
|
4
|
-
value,
|
|
5
|
-
enumerable: true,
|
|
6
|
-
configurable: true,
|
|
7
|
-
writable: true
|
|
8
|
-
});
|
|
9
|
-
} else {
|
|
10
|
-
obj[key] = value;
|
|
11
|
-
}
|
|
12
|
-
return obj;
|
|
13
|
-
}
|
|
1
|
+
import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
|
14
2
|
import { EventEmitter } from "events";
|
|
15
3
|
import SocketServer from "./socketServer";
|
|
16
4
|
const noop = () => {
|
|
@@ -1,16 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
if (key in obj) {
|
|
3
|
-
Object.defineProperty(obj, key, {
|
|
4
|
-
value,
|
|
5
|
-
enumerable: true,
|
|
6
|
-
configurable: true,
|
|
7
|
-
writable: true
|
|
8
|
-
});
|
|
9
|
-
} else {
|
|
10
|
-
obj[key] = value;
|
|
11
|
-
}
|
|
12
|
-
return obj;
|
|
13
|
-
}
|
|
1
|
+
import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
|
14
2
|
import ws from "ws";
|
|
15
3
|
import { logger } from "@modern-js/utils";
|
|
16
4
|
class SocketServer {
|
|
@@ -1,16 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
if (key in obj) {
|
|
3
|
-
Object.defineProperty(obj, key, {
|
|
4
|
-
value,
|
|
5
|
-
enumerable: true,
|
|
6
|
-
configurable: true,
|
|
7
|
-
writable: true
|
|
8
|
-
});
|
|
9
|
-
} else {
|
|
10
|
-
obj[key] = value;
|
|
11
|
-
}
|
|
12
|
-
return obj;
|
|
13
|
-
}
|
|
1
|
+
import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
|
14
2
|
import minimatch from "minimatch";
|
|
15
3
|
export const defaultIgnores = [
|
|
16
4
|
"**/bower_components/**",
|
|
@@ -1,16 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
if (key in obj) {
|
|
3
|
-
Object.defineProperty(obj, key, {
|
|
4
|
-
value,
|
|
5
|
-
enumerable: true,
|
|
6
|
-
configurable: true,
|
|
7
|
-
writable: true
|
|
8
|
-
});
|
|
9
|
-
} else {
|
|
10
|
-
obj[key] = value;
|
|
11
|
-
}
|
|
12
|
-
return obj;
|
|
13
|
-
}
|
|
1
|
+
import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
|
14
2
|
import path from "path";
|
|
15
3
|
import { fs, chokidar } from "@modern-js/utils";
|
|
16
4
|
import { DependencyTree } from "./dependencyTree";
|
|
@@ -1,16 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
if (key in obj) {
|
|
3
|
-
Object.defineProperty(obj, key, {
|
|
4
|
-
value,
|
|
5
|
-
enumerable: true,
|
|
6
|
-
configurable: true,
|
|
7
|
-
writable: true
|
|
8
|
-
});
|
|
9
|
-
} else {
|
|
10
|
-
obj[key] = value;
|
|
11
|
-
}
|
|
12
|
-
return obj;
|
|
13
|
-
}
|
|
1
|
+
import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
|
14
2
|
import fs from "fs";
|
|
15
3
|
import crypto from "crypto";
|
|
16
4
|
export class StatsCache {
|