@doracli/rspack 0.0.2 → 0.0.4
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/README.md +1 -2
- package/lib/cjs/index.js +918 -510
- package/lib/esm/index.js +877 -505
- package/lib/type/index.d.ts +130 -54
- package/package.json +11 -11
package/lib/cjs/index.js
CHANGED
|
@@ -9,7 +9,8 @@ var filePro = require('@dorabag/file-pro');
|
|
|
9
9
|
var path = require('path');
|
|
10
10
|
var HtmlRspackPlugin = require('@rspack/plugin-html');
|
|
11
11
|
|
|
12
|
-
var _documentCurrentScript =
|
|
12
|
+
var _documentCurrentScript =
|
|
13
|
+
typeof document !== 'undefined' ? document.currentScript : null;
|
|
13
14
|
function _arrayLikeToArray(r, a) {
|
|
14
15
|
(null == a || a > r.length) && (a = r.length);
|
|
15
16
|
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
@@ -22,7 +23,10 @@ function _arrayWithoutHoles(r) {
|
|
|
22
23
|
if (Array.isArray(r)) return _arrayLikeToArray(r);
|
|
23
24
|
}
|
|
24
25
|
function _assertThisInitialized(e) {
|
|
25
|
-
if (void 0 === e)
|
|
26
|
+
if (void 0 === e)
|
|
27
|
+
throw new ReferenceError(
|
|
28
|
+
"this hasn't been initialised - super() hasn't been called"
|
|
29
|
+
);
|
|
26
30
|
return e;
|
|
27
31
|
}
|
|
28
32
|
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
@@ -41,70 +45,108 @@ function _asyncToGenerator(n) {
|
|
|
41
45
|
return new Promise(function (r, o) {
|
|
42
46
|
var a = n.apply(t, e);
|
|
43
47
|
function _next(n) {
|
|
44
|
-
asyncGeneratorStep(a, r, o, _next, _throw,
|
|
48
|
+
asyncGeneratorStep(a, r, o, _next, _throw, 'next', n);
|
|
45
49
|
}
|
|
46
50
|
function _throw(n) {
|
|
47
|
-
asyncGeneratorStep(a, r, o, _next, _throw,
|
|
51
|
+
asyncGeneratorStep(a, r, o, _next, _throw, 'throw', n);
|
|
48
52
|
}
|
|
49
53
|
_next(void 0);
|
|
50
54
|
});
|
|
51
55
|
};
|
|
52
56
|
}
|
|
53
57
|
function _callSuper(t, o, e) {
|
|
54
|
-
return
|
|
58
|
+
return (
|
|
59
|
+
(o = _getPrototypeOf(o)),
|
|
60
|
+
_possibleConstructorReturn(
|
|
61
|
+
t,
|
|
62
|
+
_isNativeReflectConstruct()
|
|
63
|
+
? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor)
|
|
64
|
+
: o.apply(t, e)
|
|
65
|
+
)
|
|
66
|
+
);
|
|
55
67
|
}
|
|
56
68
|
function _classCallCheck(a, n) {
|
|
57
|
-
if (!(a instanceof n))
|
|
69
|
+
if (!(a instanceof n))
|
|
70
|
+
throw new TypeError('Cannot call a class as a function');
|
|
58
71
|
}
|
|
59
72
|
function _defineProperties(e, r) {
|
|
60
73
|
for (var t = 0; t < r.length; t++) {
|
|
61
74
|
var o = r[t];
|
|
62
|
-
o.enumerable = o.enumerable || false
|
|
75
|
+
((o.enumerable = o.enumerable || false),
|
|
76
|
+
(o.configurable = true),
|
|
77
|
+
'value' in o && (o.writable = true),
|
|
78
|
+
Object.defineProperty(e, _toPropertyKey(o.key), o));
|
|
63
79
|
}
|
|
64
80
|
}
|
|
65
81
|
function _createClass(e, r, t) {
|
|
66
|
-
return
|
|
67
|
-
|
|
68
|
-
|
|
82
|
+
return (
|
|
83
|
+
r && _defineProperties(e.prototype, r),
|
|
84
|
+
Object.defineProperty(e, 'prototype', {
|
|
85
|
+
writable: false,
|
|
86
|
+
}),
|
|
87
|
+
e
|
|
88
|
+
);
|
|
69
89
|
}
|
|
70
90
|
function _defineProperty(e, r, t) {
|
|
71
|
-
return (
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
91
|
+
return (
|
|
92
|
+
(r = _toPropertyKey(r)) in e
|
|
93
|
+
? Object.defineProperty(e, r, {
|
|
94
|
+
value: t,
|
|
95
|
+
enumerable: true,
|
|
96
|
+
configurable: true,
|
|
97
|
+
writable: true,
|
|
98
|
+
})
|
|
99
|
+
: (e[r] = t),
|
|
100
|
+
e
|
|
101
|
+
);
|
|
77
102
|
}
|
|
78
103
|
function _getPrototypeOf(t) {
|
|
79
|
-
return
|
|
80
|
-
|
|
81
|
-
|
|
104
|
+
return (
|
|
105
|
+
(_getPrototypeOf = Object.setPrototypeOf
|
|
106
|
+
? Object.getPrototypeOf.bind()
|
|
107
|
+
: function (t) {
|
|
108
|
+
return t.__proto__ || Object.getPrototypeOf(t);
|
|
109
|
+
}),
|
|
110
|
+
_getPrototypeOf(t)
|
|
111
|
+
);
|
|
82
112
|
}
|
|
83
113
|
function _inherits(t, e) {
|
|
84
|
-
if (
|
|
85
|
-
|
|
114
|
+
if ('function' != typeof e && null !== e)
|
|
115
|
+
throw new TypeError('Super expression must either be null or a function');
|
|
116
|
+
((t.prototype = Object.create(e && e.prototype, {
|
|
86
117
|
constructor: {
|
|
87
118
|
value: t,
|
|
88
119
|
writable: true,
|
|
89
|
-
configurable: true
|
|
90
|
-
}
|
|
91
|
-
}),
|
|
92
|
-
|
|
93
|
-
|
|
120
|
+
configurable: true,
|
|
121
|
+
},
|
|
122
|
+
})),
|
|
123
|
+
Object.defineProperty(t, 'prototype', {
|
|
124
|
+
writable: false,
|
|
125
|
+
}),
|
|
126
|
+
e && _setPrototypeOf(t, e));
|
|
94
127
|
}
|
|
95
128
|
function _isNativeReflectConstruct() {
|
|
96
129
|
try {
|
|
97
|
-
var t = !Boolean.prototype.valueOf.call(
|
|
130
|
+
var t = !Boolean.prototype.valueOf.call(
|
|
131
|
+
Reflect.construct(Boolean, [], function () {})
|
|
132
|
+
);
|
|
98
133
|
} catch (t) {}
|
|
99
134
|
return (_isNativeReflectConstruct = function () {
|
|
100
135
|
return !!t;
|
|
101
136
|
})();
|
|
102
137
|
}
|
|
103
138
|
function _iterableToArray(r) {
|
|
104
|
-
if (
|
|
139
|
+
if (
|
|
140
|
+
('undefined' != typeof Symbol && null != r[Symbol.iterator]) ||
|
|
141
|
+
null != r['@@iterator']
|
|
142
|
+
)
|
|
143
|
+
return Array.from(r);
|
|
105
144
|
}
|
|
106
145
|
function _iterableToArrayLimit(r, l) {
|
|
107
|
-
var t =
|
|
146
|
+
var t =
|
|
147
|
+
null == r
|
|
148
|
+
? null
|
|
149
|
+
: ('undefined' != typeof Symbol && r[Symbol.iterator]) || r['@@iterator'];
|
|
108
150
|
if (null != t) {
|
|
109
151
|
var e,
|
|
110
152
|
n,
|
|
@@ -114,12 +156,19 @@ function _iterableToArrayLimit(r, l) {
|
|
|
114
156
|
f = true,
|
|
115
157
|
o = false;
|
|
116
158
|
try {
|
|
117
|
-
if (i = (t = t.call(r)).next, 0 === l)
|
|
159
|
+
if (((i = (t = t.call(r)).next), 0 === l));
|
|
160
|
+
else
|
|
161
|
+
for (
|
|
162
|
+
;
|
|
163
|
+
!(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l);
|
|
164
|
+
f = !0
|
|
165
|
+
);
|
|
118
166
|
} catch (r) {
|
|
119
|
-
o = true, n = r;
|
|
167
|
+
((o = true), (n = r));
|
|
120
168
|
} finally {
|
|
121
169
|
try {
|
|
122
|
-
if (!f && null != t.return && (u = t.return(), Object(u) !== u))
|
|
170
|
+
if (!f && null != t.return && ((u = t.return()), Object(u) !== u))
|
|
171
|
+
return;
|
|
123
172
|
} finally {
|
|
124
173
|
if (o) throw n;
|
|
125
174
|
}
|
|
@@ -128,29 +177,39 @@ function _iterableToArrayLimit(r, l) {
|
|
|
128
177
|
}
|
|
129
178
|
}
|
|
130
179
|
function _nonIterableRest() {
|
|
131
|
-
throw new TypeError(
|
|
180
|
+
throw new TypeError(
|
|
181
|
+
'Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.'
|
|
182
|
+
);
|
|
132
183
|
}
|
|
133
184
|
function _nonIterableSpread() {
|
|
134
|
-
throw new TypeError(
|
|
185
|
+
throw new TypeError(
|
|
186
|
+
'Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.'
|
|
187
|
+
);
|
|
135
188
|
}
|
|
136
189
|
function ownKeys(e, r) {
|
|
137
190
|
var t = Object.keys(e);
|
|
138
191
|
if (Object.getOwnPropertySymbols) {
|
|
139
192
|
var o = Object.getOwnPropertySymbols(e);
|
|
140
|
-
r &&
|
|
141
|
-
|
|
142
|
-
|
|
193
|
+
(r &&
|
|
194
|
+
(o = o.filter(function (r) {
|
|
195
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
196
|
+
})),
|
|
197
|
+
t.push.apply(t, o));
|
|
143
198
|
}
|
|
144
199
|
return t;
|
|
145
200
|
}
|
|
146
201
|
function _objectSpread2(e) {
|
|
147
202
|
for (var r = 1; r < arguments.length; r++) {
|
|
148
203
|
var t = null != arguments[r] ? arguments[r] : {};
|
|
149
|
-
r % 2
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
204
|
+
r % 2
|
|
205
|
+
? ownKeys(Object(t), true).forEach(function (r) {
|
|
206
|
+
_defineProperty(e, r, t[r]);
|
|
207
|
+
})
|
|
208
|
+
: Object.getOwnPropertyDescriptors
|
|
209
|
+
? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t))
|
|
210
|
+
: ownKeys(Object(t)).forEach(function (r) {
|
|
211
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
212
|
+
});
|
|
154
213
|
}
|
|
155
214
|
return e;
|
|
156
215
|
}
|
|
@@ -161,168 +220,264 @@ function _objectWithoutProperties(e, t) {
|
|
|
161
220
|
i = _objectWithoutPropertiesLoose(e, t);
|
|
162
221
|
if (Object.getOwnPropertySymbols) {
|
|
163
222
|
var n = Object.getOwnPropertySymbols(e);
|
|
164
|
-
for (r = 0; r < n.length; r++)
|
|
223
|
+
for (r = 0; r < n.length; r++)
|
|
224
|
+
((o = n[r]),
|
|
225
|
+
-1 === t.indexOf(o) &&
|
|
226
|
+
{}.propertyIsEnumerable.call(e, o) &&
|
|
227
|
+
(i[o] = e[o]));
|
|
165
228
|
}
|
|
166
229
|
return i;
|
|
167
230
|
}
|
|
168
231
|
function _objectWithoutPropertiesLoose(r, e) {
|
|
169
232
|
if (null == r) return {};
|
|
170
233
|
var t = {};
|
|
171
|
-
for (var n in r)
|
|
172
|
-
if (
|
|
173
|
-
|
|
174
|
-
|
|
234
|
+
for (var n in r)
|
|
235
|
+
if ({}.hasOwnProperty.call(r, n)) {
|
|
236
|
+
if (-1 !== e.indexOf(n)) continue;
|
|
237
|
+
t[n] = r[n];
|
|
238
|
+
}
|
|
175
239
|
return t;
|
|
176
240
|
}
|
|
177
241
|
function _possibleConstructorReturn(t, e) {
|
|
178
|
-
if (e && (
|
|
179
|
-
if (void 0 !== e)
|
|
242
|
+
if (e && ('object' == typeof e || 'function' == typeof e)) return e;
|
|
243
|
+
if (void 0 !== e)
|
|
244
|
+
throw new TypeError(
|
|
245
|
+
'Derived constructors may only return object or undefined'
|
|
246
|
+
);
|
|
180
247
|
return _assertThisInitialized(t);
|
|
181
248
|
}
|
|
182
249
|
function _regenerator() {
|
|
183
250
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
184
251
|
var e,
|
|
185
252
|
t,
|
|
186
|
-
r =
|
|
187
|
-
n = r.iterator ||
|
|
188
|
-
o = r.toStringTag ||
|
|
253
|
+
r = 'function' == typeof Symbol ? Symbol : {},
|
|
254
|
+
n = r.iterator || '@@iterator',
|
|
255
|
+
o = r.toStringTag || '@@toStringTag';
|
|
189
256
|
function i(r, n, o, i) {
|
|
190
257
|
var c = n && n.prototype instanceof Generator ? n : Generator,
|
|
191
258
|
u = Object.create(c.prototype);
|
|
192
|
-
return
|
|
193
|
-
|
|
194
|
-
c,
|
|
259
|
+
return (
|
|
260
|
+
_regeneratorDefine(
|
|
195
261
|
u,
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
} else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
|
|
233
|
-
} catch (t) {
|
|
234
|
-
i = e, c = 1, u = t;
|
|
235
|
-
} finally {
|
|
236
|
-
f = 1;
|
|
262
|
+
'_invoke',
|
|
263
|
+
(function (r, n, o) {
|
|
264
|
+
var i,
|
|
265
|
+
c,
|
|
266
|
+
u,
|
|
267
|
+
f = 0,
|
|
268
|
+
p = o || [],
|
|
269
|
+
y = false,
|
|
270
|
+
G = {
|
|
271
|
+
p: 0,
|
|
272
|
+
n: 0,
|
|
273
|
+
v: e,
|
|
274
|
+
a: d,
|
|
275
|
+
f: d.bind(e, 4),
|
|
276
|
+
d: function (t, r) {
|
|
277
|
+
return ((i = t), (c = 0), (u = e), (G.n = r), a);
|
|
278
|
+
},
|
|
279
|
+
};
|
|
280
|
+
function d(r, n) {
|
|
281
|
+
for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
|
|
282
|
+
var o,
|
|
283
|
+
i = p[t],
|
|
284
|
+
d = G.p,
|
|
285
|
+
l = i[2];
|
|
286
|
+
r > 3
|
|
287
|
+
? (o = l === n) &&
|
|
288
|
+
((u = i[(c = i[4]) ? 5 : ((c = 3), 3)]), (i[4] = i[5] = e))
|
|
289
|
+
: i[0] <= d &&
|
|
290
|
+
((o = r < 2 && d < i[1])
|
|
291
|
+
? ((c = 0), (G.v = n), (G.n = i[1]))
|
|
292
|
+
: d < l &&
|
|
293
|
+
(o = r < 3 || i[0] > n || n > l) &&
|
|
294
|
+
((i[4] = r), (i[5] = n), (G.n = l), (c = 0)));
|
|
295
|
+
}
|
|
296
|
+
if (o || r > 1) return a;
|
|
297
|
+
throw ((y = true), n);
|
|
237
298
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
299
|
+
return function (o, p, l) {
|
|
300
|
+
if (f > 1) throw TypeError('Generator is already running');
|
|
301
|
+
for (
|
|
302
|
+
y && 1 === p && d(p, l), c = p, u = l;
|
|
303
|
+
(t = c < 2 ? e : u) || !y;
|
|
304
|
+
|
|
305
|
+
) {
|
|
306
|
+
i ||
|
|
307
|
+
(c
|
|
308
|
+
? c < 3
|
|
309
|
+
? (c > 1 && (G.n = -1), d(c, u))
|
|
310
|
+
: (G.n = u)
|
|
311
|
+
: (G.v = u));
|
|
312
|
+
try {
|
|
313
|
+
if (((f = 2), i)) {
|
|
314
|
+
if ((c || (o = 'next'), (t = i[o]))) {
|
|
315
|
+
if (!(t = t.call(i, u)))
|
|
316
|
+
throw TypeError('iterator result is not an object');
|
|
317
|
+
if (!t.done) return t;
|
|
318
|
+
((u = t.value), c < 2 && (c = 0));
|
|
319
|
+
} else
|
|
320
|
+
(1 === c && (t = i.return) && t.call(i),
|
|
321
|
+
c < 2 &&
|
|
322
|
+
((u = TypeError(
|
|
323
|
+
"The iterator does not provide a '" + o + "' method"
|
|
324
|
+
)),
|
|
325
|
+
(c = 1)));
|
|
326
|
+
i = e;
|
|
327
|
+
} else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
|
|
328
|
+
} catch (t) {
|
|
329
|
+
((i = e), (c = 1), (u = t));
|
|
330
|
+
} finally {
|
|
331
|
+
f = 1;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
return {
|
|
335
|
+
value: t,
|
|
336
|
+
done: y,
|
|
337
|
+
};
|
|
338
|
+
};
|
|
339
|
+
})(r, o, i),
|
|
340
|
+
true
|
|
341
|
+
),
|
|
342
|
+
u
|
|
343
|
+
);
|
|
245
344
|
}
|
|
246
345
|
var a = {};
|
|
247
346
|
function Generator() {}
|
|
248
347
|
function GeneratorFunction() {}
|
|
249
348
|
function GeneratorFunctionPrototype() {}
|
|
250
349
|
t = Object.getPrototypeOf;
|
|
251
|
-
var c = [][n]
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
350
|
+
var c = [][n]
|
|
351
|
+
? t(t([][n]()))
|
|
352
|
+
: (_regeneratorDefine((t = {}), n, function () {
|
|
353
|
+
return this;
|
|
354
|
+
}),
|
|
355
|
+
t),
|
|
356
|
+
u =
|
|
357
|
+
(GeneratorFunctionPrototype.prototype =
|
|
358
|
+
Generator.prototype =
|
|
359
|
+
Object.create(c));
|
|
255
360
|
function f(e) {
|
|
256
|
-
return
|
|
361
|
+
return (
|
|
362
|
+
Object.setPrototypeOf
|
|
363
|
+
? Object.setPrototypeOf(e, GeneratorFunctionPrototype)
|
|
364
|
+
: ((e.__proto__ = GeneratorFunctionPrototype),
|
|
365
|
+
_regeneratorDefine(e, o, 'GeneratorFunction')),
|
|
366
|
+
(e.prototype = Object.create(u)),
|
|
367
|
+
e
|
|
368
|
+
);
|
|
257
369
|
}
|
|
258
|
-
return
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
370
|
+
return (
|
|
371
|
+
(GeneratorFunction.prototype = GeneratorFunctionPrototype),
|
|
372
|
+
_regeneratorDefine(u, 'constructor', GeneratorFunctionPrototype),
|
|
373
|
+
_regeneratorDefine(
|
|
374
|
+
GeneratorFunctionPrototype,
|
|
375
|
+
'constructor',
|
|
376
|
+
GeneratorFunction
|
|
377
|
+
),
|
|
378
|
+
(GeneratorFunction.displayName = 'GeneratorFunction'),
|
|
379
|
+
_regeneratorDefine(GeneratorFunctionPrototype, o, 'GeneratorFunction'),
|
|
380
|
+
_regeneratorDefine(u),
|
|
381
|
+
_regeneratorDefine(u, o, 'Generator'),
|
|
382
|
+
_regeneratorDefine(u, n, function () {
|
|
383
|
+
return this;
|
|
384
|
+
}),
|
|
385
|
+
_regeneratorDefine(u, 'toString', function () {
|
|
386
|
+
return '[object Generator]';
|
|
387
|
+
}),
|
|
388
|
+
(_regenerator = function () {
|
|
389
|
+
return {
|
|
390
|
+
w: i,
|
|
391
|
+
m: f,
|
|
392
|
+
};
|
|
393
|
+
})()
|
|
394
|
+
);
|
|
268
395
|
}
|
|
269
396
|
function _regeneratorDefine(e, r, n, t) {
|
|
270
397
|
var i = Object.defineProperty;
|
|
271
398
|
try {
|
|
272
|
-
i({},
|
|
399
|
+
i({}, '', {});
|
|
273
400
|
} catch (e) {
|
|
274
401
|
i = 0;
|
|
275
402
|
}
|
|
276
|
-
_regeneratorDefine = function (e, r, n, t) {
|
|
403
|
+
((_regeneratorDefine = function (e, r, n, t) {
|
|
277
404
|
function o(r, n) {
|
|
278
405
|
_regeneratorDefine(e, r, function (e) {
|
|
279
406
|
return this._invoke(r, n, e);
|
|
280
407
|
});
|
|
281
408
|
}
|
|
282
|
-
r
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
409
|
+
r
|
|
410
|
+
? i
|
|
411
|
+
? i(e, r, {
|
|
412
|
+
value: n,
|
|
413
|
+
enumerable: !t,
|
|
414
|
+
configurable: !t,
|
|
415
|
+
writable: !t,
|
|
416
|
+
})
|
|
417
|
+
: (e[r] = n)
|
|
418
|
+
: (o('next', 0), o('throw', 1), o('return', 2));
|
|
419
|
+
}),
|
|
420
|
+
_regeneratorDefine(e, r, n, t));
|
|
289
421
|
}
|
|
290
422
|
function _setPrototypeOf(t, e) {
|
|
291
|
-
return
|
|
292
|
-
|
|
293
|
-
|
|
423
|
+
return (
|
|
424
|
+
(_setPrototypeOf = Object.setPrototypeOf
|
|
425
|
+
? Object.setPrototypeOf.bind()
|
|
426
|
+
: function (t, e) {
|
|
427
|
+
return ((t.__proto__ = e), t);
|
|
428
|
+
}),
|
|
429
|
+
_setPrototypeOf(t, e)
|
|
430
|
+
);
|
|
294
431
|
}
|
|
295
432
|
function _slicedToArray(r, e) {
|
|
296
|
-
return
|
|
433
|
+
return (
|
|
434
|
+
_arrayWithHoles(r) ||
|
|
435
|
+
_iterableToArrayLimit(r, e) ||
|
|
436
|
+
_unsupportedIterableToArray(r, e) ||
|
|
437
|
+
_nonIterableRest()
|
|
438
|
+
);
|
|
297
439
|
}
|
|
298
440
|
function _toConsumableArray(r) {
|
|
299
|
-
return
|
|
441
|
+
return (
|
|
442
|
+
_arrayWithoutHoles(r) ||
|
|
443
|
+
_iterableToArray(r) ||
|
|
444
|
+
_unsupportedIterableToArray(r) ||
|
|
445
|
+
_nonIterableSpread()
|
|
446
|
+
);
|
|
300
447
|
}
|
|
301
448
|
function _toPrimitive(t, r) {
|
|
302
|
-
if (
|
|
449
|
+
if ('object' != typeof t || !t) return t;
|
|
303
450
|
var e = t[Symbol.toPrimitive];
|
|
304
451
|
if (void 0 !== e) {
|
|
305
452
|
var i = e.call(t, r);
|
|
306
|
-
if (
|
|
307
|
-
throw new TypeError(
|
|
453
|
+
if ('object' != typeof i) return i;
|
|
454
|
+
throw new TypeError('@@toPrimitive must return a primitive value.');
|
|
308
455
|
}
|
|
309
|
-
return (
|
|
456
|
+
return ('string' === r ? String : Number)(t);
|
|
310
457
|
}
|
|
311
458
|
function _toPropertyKey(t) {
|
|
312
|
-
var i = _toPrimitive(t,
|
|
313
|
-
return
|
|
459
|
+
var i = _toPrimitive(t, 'string');
|
|
460
|
+
return 'symbol' == typeof i ? i : i + '';
|
|
314
461
|
}
|
|
315
462
|
function _unsupportedIterableToArray(r, a) {
|
|
316
463
|
if (r) {
|
|
317
|
-
if (
|
|
464
|
+
if ('string' == typeof r) return _arrayLikeToArray(r, a);
|
|
318
465
|
var t = {}.toString.call(r).slice(8, -1);
|
|
319
|
-
return
|
|
466
|
+
return (
|
|
467
|
+
'Object' === t && r.constructor && (t = r.constructor.name),
|
|
468
|
+
'Map' === t || 'Set' === t
|
|
469
|
+
? Array.from(r)
|
|
470
|
+
: 'Arguments' === t ||
|
|
471
|
+
/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)
|
|
472
|
+
? _arrayLikeToArray(r, a)
|
|
473
|
+
: void 0
|
|
474
|
+
);
|
|
320
475
|
}
|
|
321
476
|
}
|
|
322
477
|
|
|
323
|
-
var _excluded$3 = [
|
|
324
|
-
_excluded2 = [
|
|
325
|
-
_excluded3 = [
|
|
478
|
+
var _excluded$3 = ['output'],
|
|
479
|
+
_excluded2 = ['output'],
|
|
480
|
+
_excluded3 = ['static', 'headers'];
|
|
326
481
|
var mergeRspackConfigs = function mergeRspackConfigs(first, second) {
|
|
327
482
|
if (!first) return second;
|
|
328
483
|
if (!second) return first;
|
|
@@ -334,9 +489,15 @@ var mergeRspackConfigs = function mergeRspackConfigs(first, second) {
|
|
|
334
489
|
if (lang.isObject(firstOutput) && lang.isObject(secondOutput)) {
|
|
335
490
|
output = _objectSpread2(_objectSpread2({}, firstOutput), secondOutput);
|
|
336
491
|
}
|
|
337
|
-
return _objectSpread2(
|
|
338
|
-
|
|
339
|
-
|
|
492
|
+
return _objectSpread2(
|
|
493
|
+
_objectSpread2(
|
|
494
|
+
{
|
|
495
|
+
output: output,
|
|
496
|
+
},
|
|
497
|
+
restFirst
|
|
498
|
+
),
|
|
499
|
+
restSecond
|
|
500
|
+
);
|
|
340
501
|
};
|
|
341
502
|
|
|
342
503
|
/**
|
|
@@ -347,9 +508,13 @@ var mergeRspackConfigs = function mergeRspackConfigs(first, second) {
|
|
|
347
508
|
var mergeServerConfig = function mergeServerConfig() {
|
|
348
509
|
var result = {
|
|
349
510
|
static: [],
|
|
350
|
-
headers: {}
|
|
511
|
+
headers: {},
|
|
351
512
|
};
|
|
352
|
-
for (
|
|
513
|
+
for (
|
|
514
|
+
var _len = arguments.length, configs = new Array(_len), _key = 0;
|
|
515
|
+
_key < _len;
|
|
516
|
+
_key++
|
|
517
|
+
) {
|
|
353
518
|
configs[_key] = arguments[_key];
|
|
354
519
|
}
|
|
355
520
|
configs.forEach(function (config) {
|
|
@@ -359,203 +524,303 @@ var mergeServerConfig = function mergeServerConfig() {
|
|
|
359
524
|
otherConfig = _objectWithoutProperties(config, _excluded3);
|
|
360
525
|
if (lang.isArray(result.static) && lang.isArray(staticConfig)) {
|
|
361
526
|
var _result$static;
|
|
362
|
-
(_result$static = result.static).push.apply(
|
|
527
|
+
(_result$static = result.static).push.apply(
|
|
528
|
+
_result$static,
|
|
529
|
+
_toConsumableArray(staticConfig)
|
|
530
|
+
);
|
|
363
531
|
}
|
|
364
532
|
if (headers) {
|
|
365
|
-
result.headers = _objectSpread2(
|
|
533
|
+
result.headers = _objectSpread2(
|
|
534
|
+
_objectSpread2({}, result.headers),
|
|
535
|
+
headers
|
|
536
|
+
);
|
|
366
537
|
}
|
|
367
538
|
Object.assign(result, otherConfig);
|
|
368
539
|
});
|
|
369
540
|
return result;
|
|
370
541
|
};
|
|
371
542
|
|
|
372
|
-
var Compiler = /*#__PURE__*/function (_CompilerBase) {
|
|
543
|
+
var Compiler = /*#__PURE__*/ (function (_CompilerBase) {
|
|
373
544
|
function Compiler() {
|
|
374
545
|
var _this;
|
|
375
546
|
_classCallCheck(this, Compiler);
|
|
376
|
-
for (
|
|
547
|
+
for (
|
|
548
|
+
var _len = arguments.length, args = new Array(_len), _key = 0;
|
|
549
|
+
_key < _len;
|
|
550
|
+
_key++
|
|
551
|
+
) {
|
|
377
552
|
args[_key] = arguments[_key];
|
|
378
553
|
}
|
|
379
554
|
_this = _callSuper(this, Compiler, [].concat(args));
|
|
380
|
-
_defineProperty(
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
555
|
+
_defineProperty(
|
|
556
|
+
_this,
|
|
557
|
+
'context',
|
|
558
|
+
/*#__PURE__*/ (function () {
|
|
559
|
+
var _ref = _asyncToGenerator(
|
|
560
|
+
/*#__PURE__*/ _regenerator().m(function _callee2(rspackConfig) {
|
|
561
|
+
var compiler;
|
|
562
|
+
return _regenerator().w(function (_context2) {
|
|
563
|
+
while (1)
|
|
564
|
+
switch (_context2.n) {
|
|
565
|
+
case 0:
|
|
566
|
+
compiler = rspack(
|
|
567
|
+
mergeRspackConfigs(_this.initOptions, rspackConfig)
|
|
568
|
+
);
|
|
569
|
+
return _context2.a(2, {
|
|
570
|
+
rebuild: function rebuild() {
|
|
571
|
+
return new Promise(function (resolve, reject) {
|
|
572
|
+
compiler.run(function (err, stats) {
|
|
573
|
+
if (err) return reject(err);
|
|
574
|
+
resolve({
|
|
575
|
+
err: err,
|
|
576
|
+
stats: stats,
|
|
577
|
+
});
|
|
578
|
+
});
|
|
579
|
+
});
|
|
580
|
+
},
|
|
581
|
+
cancel: (function () {
|
|
582
|
+
var _cancel = _asyncToGenerator(
|
|
583
|
+
/*#__PURE__*/ _regenerator().m(function _callee() {
|
|
584
|
+
return _regenerator().w(function (_context) {
|
|
585
|
+
while (1)
|
|
586
|
+
switch (_context.n) {
|
|
587
|
+
case 0:
|
|
588
|
+
helper.cLog.warn(
|
|
589
|
+
'build',
|
|
590
|
+
'empty',
|
|
591
|
+
'Webpack compiler cancel is empty implementation.'
|
|
592
|
+
);
|
|
593
|
+
return _context.a(2);
|
|
594
|
+
}
|
|
595
|
+
}, _callee);
|
|
596
|
+
})
|
|
597
|
+
);
|
|
598
|
+
function cancel() {
|
|
599
|
+
return _cancel.apply(this, arguments);
|
|
600
|
+
}
|
|
601
|
+
return cancel;
|
|
602
|
+
})(),
|
|
396
603
|
});
|
|
397
|
-
});
|
|
398
|
-
},
|
|
399
|
-
cancel: function () {
|
|
400
|
-
var _cancel = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
401
|
-
return _regenerator().w(function (_context) {
|
|
402
|
-
while (1) switch (_context.n) {
|
|
403
|
-
case 0:
|
|
404
|
-
helper.cLog.warn('build', 'empty', 'Webpack compiler cancel is empty implementation.');
|
|
405
|
-
return _context.a(2);
|
|
406
|
-
}
|
|
407
|
-
}, _callee);
|
|
408
|
-
}));
|
|
409
|
-
function cancel() {
|
|
410
|
-
return _cancel.apply(this, arguments);
|
|
411
|
-
}
|
|
412
|
-
return cancel;
|
|
413
|
-
}()
|
|
414
|
-
});
|
|
415
|
-
}
|
|
416
|
-
}, _callee2);
|
|
417
|
-
}));
|
|
418
|
-
return function (_x) {
|
|
419
|
-
return _ref.apply(this, arguments);
|
|
420
|
-
};
|
|
421
|
-
}());
|
|
422
|
-
_defineProperty(_this, "inOutMap", /*#__PURE__*/function () {
|
|
423
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(inputOutputMap) {
|
|
424
|
-
var entry, output;
|
|
425
|
-
return _regenerator().w(function (_context3) {
|
|
426
|
-
while (1) switch (_context3.n) {
|
|
427
|
-
case 0:
|
|
428
|
-
// 构造多入口对象
|
|
429
|
-
entry = {};
|
|
430
|
-
Object.entries(inputOutputMap).forEach(function (_ref3) {
|
|
431
|
-
var _ref4 = _slicedToArray(_ref3, 2),
|
|
432
|
-
input = _ref4[0],
|
|
433
|
-
output = _ref4[1];
|
|
434
|
-
entry[output] = input;
|
|
435
|
-
});
|
|
436
|
-
output = {
|
|
437
|
-
path: 'dist',
|
|
438
|
-
filename: '[name].js'
|
|
439
|
-
};
|
|
440
|
-
return _context3.a(2, _this.build({
|
|
441
|
-
entry: entry,
|
|
442
|
-
output: output
|
|
443
|
-
}));
|
|
444
|
-
}
|
|
445
|
-
}, _callee3);
|
|
446
|
-
}));
|
|
447
|
-
return function (_x2) {
|
|
448
|
-
return _ref2.apply(this, arguments);
|
|
449
|
-
};
|
|
450
|
-
}());
|
|
451
|
-
_defineProperty(_this, "input", /*#__PURE__*/function () {
|
|
452
|
-
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(input) {
|
|
453
|
-
return _regenerator().w(function (_context4) {
|
|
454
|
-
while (1) switch (_context4.n) {
|
|
455
|
-
case 0:
|
|
456
|
-
return _context4.a(2, {
|
|
457
|
-
output: function output(_output) {
|
|
458
|
-
return _this.build({
|
|
459
|
-
entry: input,
|
|
460
|
-
output: _output
|
|
461
|
-
});
|
|
462
604
|
}
|
|
463
|
-
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
_defineProperty(
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
605
|
+
}, _callee2);
|
|
606
|
+
})
|
|
607
|
+
);
|
|
608
|
+
return function (_x) {
|
|
609
|
+
return _ref.apply(this, arguments);
|
|
610
|
+
};
|
|
611
|
+
})()
|
|
612
|
+
);
|
|
613
|
+
_defineProperty(
|
|
614
|
+
_this,
|
|
615
|
+
'inOutMap',
|
|
616
|
+
/*#__PURE__*/ (function () {
|
|
617
|
+
var _ref2 = _asyncToGenerator(
|
|
618
|
+
/*#__PURE__*/ _regenerator().m(function _callee3(inputOutputMap) {
|
|
619
|
+
var entry, output;
|
|
620
|
+
return _regenerator().w(function (_context3) {
|
|
621
|
+
while (1)
|
|
622
|
+
switch (_context3.n) {
|
|
623
|
+
case 0:
|
|
624
|
+
// 构造多入口对象
|
|
625
|
+
entry = {};
|
|
626
|
+
Object.entries(inputOutputMap).forEach(function (_ref3) {
|
|
627
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
628
|
+
input = _ref4[0],
|
|
629
|
+
output = _ref4[1];
|
|
630
|
+
entry[output] = input;
|
|
631
|
+
});
|
|
632
|
+
output = {
|
|
633
|
+
path: 'dist',
|
|
634
|
+
filename: '[name].js',
|
|
635
|
+
};
|
|
636
|
+
return _context3.a(
|
|
637
|
+
2,
|
|
638
|
+
_this.build({
|
|
639
|
+
entry: entry,
|
|
640
|
+
output: output,
|
|
641
|
+
})
|
|
642
|
+
);
|
|
643
|
+
}
|
|
644
|
+
}, _callee3);
|
|
645
|
+
})
|
|
646
|
+
);
|
|
647
|
+
return function (_x2) {
|
|
648
|
+
return _ref2.apply(this, arguments);
|
|
649
|
+
};
|
|
650
|
+
})()
|
|
651
|
+
);
|
|
652
|
+
_defineProperty(
|
|
653
|
+
_this,
|
|
654
|
+
'input',
|
|
655
|
+
/*#__PURE__*/ (function () {
|
|
656
|
+
var _ref5 = _asyncToGenerator(
|
|
657
|
+
/*#__PURE__*/ _regenerator().m(function _callee4(input) {
|
|
658
|
+
return _regenerator().w(function (_context4) {
|
|
659
|
+
while (1)
|
|
660
|
+
switch (_context4.n) {
|
|
661
|
+
case 0:
|
|
662
|
+
return _context4.a(2, {
|
|
663
|
+
output: function output(_output) {
|
|
664
|
+
return _this.build({
|
|
665
|
+
entry: input,
|
|
666
|
+
output: _output,
|
|
667
|
+
});
|
|
668
|
+
},
|
|
669
|
+
});
|
|
670
|
+
}
|
|
671
|
+
}, _callee4);
|
|
672
|
+
})
|
|
673
|
+
);
|
|
674
|
+
return function (_x3) {
|
|
675
|
+
return _ref5.apply(this, arguments);
|
|
676
|
+
};
|
|
677
|
+
})()
|
|
678
|
+
);
|
|
679
|
+
_defineProperty(
|
|
680
|
+
_this,
|
|
681
|
+
'build',
|
|
682
|
+
/*#__PURE__*/ (function () {
|
|
683
|
+
var _ref6 = _asyncToGenerator(
|
|
684
|
+
/*#__PURE__*/ _regenerator().m(function _callee5(rspackConfig) {
|
|
685
|
+
return _regenerator().w(function (_context5) {
|
|
686
|
+
while (1)
|
|
687
|
+
switch (_context5.n) {
|
|
688
|
+
case 0:
|
|
689
|
+
return _context5.a(
|
|
690
|
+
2,
|
|
691
|
+
new Promise(function (resolve, reject) {
|
|
692
|
+
rspack(
|
|
693
|
+
mergeRspackConfigs(_this.initOptions, rspackConfig),
|
|
694
|
+
function (err, stats) {
|
|
695
|
+
if (err) return reject(err);
|
|
696
|
+
resolve({
|
|
697
|
+
err: err,
|
|
698
|
+
stats: stats,
|
|
699
|
+
});
|
|
700
|
+
}
|
|
701
|
+
);
|
|
702
|
+
})
|
|
703
|
+
);
|
|
704
|
+
}
|
|
705
|
+
}, _callee5);
|
|
706
|
+
})
|
|
707
|
+
);
|
|
708
|
+
return function (_x4) {
|
|
709
|
+
return _ref6.apply(this, arguments);
|
|
710
|
+
};
|
|
711
|
+
})()
|
|
712
|
+
);
|
|
713
|
+
_defineProperty(_this, 'watch', function (watchOptions, rspackConfig) {
|
|
714
|
+
var cb =
|
|
715
|
+
arguments.length > 2 && arguments[2] !== undefined
|
|
716
|
+
? arguments[2]
|
|
717
|
+
: lang.noop;
|
|
718
|
+
var compiler = rspack(
|
|
719
|
+
mergeRspackConfigs(_this.initOptions, rspackConfig)
|
|
720
|
+
);
|
|
495
721
|
return compiler.watch(watchOptions || {}, cb);
|
|
496
722
|
});
|
|
497
|
-
_defineProperty(
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
tempSrvConfig
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
723
|
+
_defineProperty(
|
|
724
|
+
_this,
|
|
725
|
+
'server',
|
|
726
|
+
/*#__PURE__*/ (function () {
|
|
727
|
+
var _ref7 = _asyncToGenerator(
|
|
728
|
+
/*#__PURE__*/ _regenerator().m(
|
|
729
|
+
function _callee6(serverOptions, rspackConfig) {
|
|
730
|
+
var compiler, tempSrvConfig, open, port, host, devServer$1;
|
|
731
|
+
return _regenerator().w(function (_context6) {
|
|
732
|
+
while (1)
|
|
733
|
+
switch (_context6.n) {
|
|
734
|
+
case 0:
|
|
735
|
+
compiler = rspack(
|
|
736
|
+
mergeRspackConfigs(_this.initOptions, rspackConfig)
|
|
737
|
+
);
|
|
738
|
+
tempSrvConfig = mergeServerConfig(serverOptions, {
|
|
739
|
+
client: {
|
|
740
|
+
logging: 'none',
|
|
741
|
+
},
|
|
742
|
+
devMiddleware: {
|
|
743
|
+
stats: 'none',
|
|
744
|
+
},
|
|
745
|
+
});
|
|
746
|
+
((open = tempSrvConfig.open),
|
|
747
|
+
(port = tempSrvConfig.port),
|
|
748
|
+
(host = tempSrvConfig.host));
|
|
749
|
+
devServer$1 = new devServer.RspackDevServer(
|
|
750
|
+
mergeServerConfig(
|
|
751
|
+
_objectSpread2(
|
|
752
|
+
_objectSpread2({}, tempSrvConfig),
|
|
753
|
+
{},
|
|
754
|
+
{
|
|
755
|
+
open: false,
|
|
756
|
+
}
|
|
757
|
+
)
|
|
758
|
+
),
|
|
759
|
+
compiler
|
|
760
|
+
);
|
|
761
|
+
_context6.n = 1;
|
|
762
|
+
return devServer$1.start();
|
|
763
|
+
case 1:
|
|
764
|
+
if (open) {
|
|
765
|
+
openBrowser('http://'.concat(host, ':').concat(port));
|
|
766
|
+
}
|
|
767
|
+
return _context6.a(2, devServer$1);
|
|
768
|
+
}
|
|
769
|
+
}, _callee6);
|
|
770
|
+
}
|
|
771
|
+
)
|
|
772
|
+
);
|
|
773
|
+
return function (_x5, _x6) {
|
|
774
|
+
return _ref7.apply(this, arguments);
|
|
775
|
+
};
|
|
776
|
+
})()
|
|
777
|
+
);
|
|
523
778
|
return _this;
|
|
524
779
|
}
|
|
525
780
|
_inherits(Compiler, _CompilerBase);
|
|
526
781
|
return _createClass(Compiler);
|
|
527
|
-
}(helper.CompilerBase);
|
|
782
|
+
})(helper.CompilerBase);
|
|
528
783
|
|
|
529
|
-
var _excluded$2 = [
|
|
784
|
+
var _excluded$2 = ['port'];
|
|
530
785
|
var getDevServer = function getDevServer(serviceConfig) {
|
|
531
786
|
var configPort = serviceConfig.port,
|
|
532
787
|
extServiceConfig = _objectWithoutProperties(serviceConfig, _excluded$2);
|
|
533
788
|
var host = '127.0.0.1';
|
|
534
|
-
return _objectSpread2(
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
789
|
+
return _objectSpread2(
|
|
790
|
+
_objectSpread2(
|
|
791
|
+
{
|
|
792
|
+
host: host,
|
|
793
|
+
// 地址
|
|
794
|
+
open: false,
|
|
795
|
+
// 是否自动打开,关闭
|
|
796
|
+
setupExitSignals: true,
|
|
797
|
+
// 允许在 SIGINT 和 SIGTERM 信号时关闭开发服务器和退出进程。
|
|
798
|
+
compress: false,
|
|
799
|
+
// gzip压缩,开发环境不开启,提升热更新速度
|
|
800
|
+
hot: true,
|
|
801
|
+
// 开启热更新
|
|
802
|
+
historyApiFallback: true,
|
|
803
|
+
// 解决history路由404问题
|
|
804
|
+
// 托管静态资源public文件夹
|
|
805
|
+
static: [
|
|
806
|
+
{
|
|
807
|
+
directory: filePro.resolveCwd('./public'),
|
|
808
|
+
},
|
|
809
|
+
{
|
|
810
|
+
directory: filePro.resolveCwd('./dist'),
|
|
811
|
+
},
|
|
812
|
+
],
|
|
813
|
+
headers: {
|
|
814
|
+
'Access-Control-Allow-Origin': '*',
|
|
815
|
+
},
|
|
816
|
+
},
|
|
817
|
+
extServiceConfig
|
|
818
|
+
),
|
|
819
|
+
{},
|
|
820
|
+
{
|
|
821
|
+
port: configPort || '7777',
|
|
555
822
|
}
|
|
556
|
-
|
|
557
|
-
port: configPort || '7777'
|
|
558
|
-
});
|
|
823
|
+
);
|
|
559
824
|
};
|
|
560
825
|
|
|
561
826
|
var getDevtool = function getDevtool(envParams, devtoolConfig) {
|
|
@@ -589,7 +854,11 @@ var getEntry = function getEntry(params, input) {
|
|
|
589
854
|
}, []);
|
|
590
855
|
var rightFile = filePro.lookupFile(pList, workRootDir);
|
|
591
856
|
if (!rightFile) {
|
|
592
|
-
helper.cLog.warn(
|
|
857
|
+
helper.cLog.warn(
|
|
858
|
+
'dora-wr',
|
|
859
|
+
'getEntry',
|
|
860
|
+
'需要有一个入口文件 index 或者 src/index'
|
|
861
|
+
);
|
|
593
862
|
process.exit();
|
|
594
863
|
}
|
|
595
864
|
return rightFile;
|
|
@@ -606,34 +875,87 @@ var getMode = function getMode(envParams, modeConfig) {
|
|
|
606
875
|
return action === 'server' ? 'development' : 'production';
|
|
607
876
|
};
|
|
608
877
|
|
|
609
|
-
var cssLoader = filePro.requireResolve(
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
878
|
+
var cssLoader = filePro.requireResolve(
|
|
879
|
+
typeof document === 'undefined'
|
|
880
|
+
? require('u' + 'rl').pathToFileURL(__filename).href
|
|
881
|
+
: (_documentCurrentScript &&
|
|
882
|
+
_documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' &&
|
|
883
|
+
_documentCurrentScript.src) ||
|
|
884
|
+
new URL('index.js', document.baseURI).href,
|
|
885
|
+
'css-loader'
|
|
886
|
+
);
|
|
887
|
+
var postcssLoader = filePro.requireResolve(
|
|
888
|
+
typeof document === 'undefined'
|
|
889
|
+
? require('u' + 'rl').pathToFileURL(__filename).href
|
|
890
|
+
: (_documentCurrentScript &&
|
|
891
|
+
_documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' &&
|
|
892
|
+
_documentCurrentScript.src) ||
|
|
893
|
+
new URL('index.js', document.baseURI).href,
|
|
894
|
+
'postcss-loader'
|
|
895
|
+
);
|
|
896
|
+
var styleLoader = filePro.requireResolve(
|
|
897
|
+
typeof document === 'undefined'
|
|
898
|
+
? require('u' + 'rl').pathToFileURL(__filename).href
|
|
899
|
+
: (_documentCurrentScript &&
|
|
900
|
+
_documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' &&
|
|
901
|
+
_documentCurrentScript.src) ||
|
|
902
|
+
new URL('index.js', document.baseURI).href,
|
|
903
|
+
'style-loader'
|
|
904
|
+
);
|
|
905
|
+
var lessLoader = filePro.requireResolve(
|
|
906
|
+
typeof document === 'undefined'
|
|
907
|
+
? require('u' + 'rl').pathToFileURL(__filename).href
|
|
908
|
+
: (_documentCurrentScript &&
|
|
909
|
+
_documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' &&
|
|
910
|
+
_documentCurrentScript.src) ||
|
|
911
|
+
new URL('index.js', document.baseURI).href,
|
|
912
|
+
'less-loader'
|
|
913
|
+
);
|
|
914
|
+
var swcLoader = filePro.requireResolve(
|
|
915
|
+
typeof document === 'undefined'
|
|
916
|
+
? require('u' + 'rl').pathToFileURL(__filename).href
|
|
917
|
+
: (_documentCurrentScript &&
|
|
918
|
+
_documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' &&
|
|
919
|
+
_documentCurrentScript.src) ||
|
|
920
|
+
new URL('index.js', document.baseURI).href,
|
|
921
|
+
'swc-loader'
|
|
922
|
+
);
|
|
923
|
+
var postcssPresetEnv = filePro.requireResolve(
|
|
924
|
+
typeof document === 'undefined'
|
|
925
|
+
? require('u' + 'rl').pathToFileURL(__filename).href
|
|
926
|
+
: (_documentCurrentScript &&
|
|
927
|
+
_documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' &&
|
|
928
|
+
_documentCurrentScript.src) ||
|
|
929
|
+
new URL('index.js', document.baseURI).href,
|
|
930
|
+
'postcss-preset-env'
|
|
931
|
+
);
|
|
615
932
|
|
|
616
933
|
var getCssBaseLoader = function getCssBaseLoader(envParams, options) {
|
|
617
934
|
var action = envParams.action;
|
|
618
935
|
var _ref = options || {},
|
|
619
936
|
postcssPluginExtra = _ref.postcssPluginExtra;
|
|
620
|
-
var baseCssLoaderList = [
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
937
|
+
var baseCssLoaderList = [
|
|
938
|
+
cssLoader,
|
|
939
|
+
{
|
|
940
|
+
loader: postcssLoader,
|
|
941
|
+
options: {
|
|
942
|
+
postcssOptions: {
|
|
943
|
+
plugins: [[postcssPresetEnv]].concat(
|
|
944
|
+
_toConsumableArray(postcssPluginExtra || [])
|
|
945
|
+
),
|
|
946
|
+
},
|
|
947
|
+
},
|
|
948
|
+
},
|
|
949
|
+
];
|
|
628
950
|
|
|
629
951
|
// dev环境使用style-loader
|
|
630
952
|
if (action === 'server') {
|
|
631
953
|
baseCssLoaderList.unshift({
|
|
632
|
-
loader: styleLoader
|
|
954
|
+
loader: styleLoader,
|
|
633
955
|
});
|
|
634
956
|
} else {
|
|
635
957
|
baseCssLoaderList.unshift({
|
|
636
|
-
loader: rspack.CssExtractRspackPlugin.loader
|
|
958
|
+
loader: rspack.CssExtractRspackPlugin.loader,
|
|
637
959
|
});
|
|
638
960
|
}
|
|
639
961
|
return baseCssLoaderList;
|
|
@@ -642,57 +964,64 @@ var getCssBaseLoader = function getCssBaseLoader(envParams, options) {
|
|
|
642
964
|
var getReactModulePreset = function getReactModulePreset(envParams, options) {
|
|
643
965
|
var publicCss = getCssBaseLoader(envParams, options);
|
|
644
966
|
var module = {
|
|
645
|
-
rules: [
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
967
|
+
rules: [
|
|
968
|
+
{
|
|
969
|
+
oneOf: [
|
|
970
|
+
{
|
|
971
|
+
test: /\.(js|jsx|ts|tsx)$/,
|
|
972
|
+
loader: 'swc-loader',
|
|
973
|
+
options: {
|
|
974
|
+
jsc: {
|
|
975
|
+
parser: {
|
|
976
|
+
syntax: 'typescript',
|
|
977
|
+
tsx: true, // 支持 tsx/jsx
|
|
978
|
+
},
|
|
979
|
+
transform: {
|
|
980
|
+
react: {
|
|
981
|
+
runtime: 'automatic',
|
|
982
|
+
}, // React 17+ 新 JSX
|
|
983
|
+
},
|
|
984
|
+
},
|
|
985
|
+
},
|
|
986
|
+
},
|
|
987
|
+
{
|
|
988
|
+
test: /\.css$/,
|
|
989
|
+
use: _toConsumableArray(publicCss),
|
|
990
|
+
},
|
|
991
|
+
{
|
|
992
|
+
test: /\.less$/,
|
|
993
|
+
use: [].concat(_toConsumableArray(publicCss), [lessLoader]),
|
|
994
|
+
},
|
|
995
|
+
{
|
|
996
|
+
test: /\.(jpe?g|png|gif|svg)$/i,
|
|
997
|
+
type: 'asset',
|
|
998
|
+
// 一般会转换为 "asset/resource"
|
|
999
|
+
generator: {
|
|
1000
|
+
filename: 'img/[name]_[hash:8][ext]', // 独立的配置
|
|
1001
|
+
},
|
|
651
1002
|
parser: {
|
|
652
|
-
|
|
653
|
-
|
|
1003
|
+
dataUrlCondition: {
|
|
1004
|
+
maxSize: 8 * 1024, // 8kb (低于8kb都会压缩成 base64)
|
|
1005
|
+
},
|
|
654
1006
|
},
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
// 一般会转换为 "asset/resource"
|
|
672
|
-
generator: {
|
|
673
|
-
filename: 'img/[name]_[hash:8][ext]' // 独立的配置
|
|
674
|
-
},
|
|
675
|
-
parser: {
|
|
676
|
-
dataUrlCondition: {
|
|
677
|
-
maxSize: 8 * 1024 // 8kb (低于8kb都会压缩成 base64)
|
|
678
|
-
}
|
|
679
|
-
}
|
|
1007
|
+
},
|
|
1008
|
+
// 字体文件
|
|
1009
|
+
{
|
|
1010
|
+
test: /\.(otf|eot|woff2?|ttf|svg)$/i,
|
|
1011
|
+
type: 'asset',
|
|
1012
|
+
// 一般会转换为 "asset/inline"
|
|
1013
|
+
generator: {
|
|
1014
|
+
filename: 'icon/[name]_[hash:8][ext]', // 独立的配置
|
|
1015
|
+
},
|
|
1016
|
+
parser: {
|
|
1017
|
+
dataUrlCondition: {
|
|
1018
|
+
maxSize: 2 * 1024, // 2kb (低于2kb都会压缩)
|
|
1019
|
+
},
|
|
1020
|
+
},
|
|
1021
|
+
},
|
|
1022
|
+
],
|
|
680
1023
|
},
|
|
681
|
-
|
|
682
|
-
{
|
|
683
|
-
test: /\.(otf|eot|woff2?|ttf|svg)$/i,
|
|
684
|
-
type: 'asset',
|
|
685
|
-
// 一般会转换为 "asset/inline"
|
|
686
|
-
generator: {
|
|
687
|
-
filename: 'icon/[name]_[hash:8][ext]' // 独立的配置
|
|
688
|
-
},
|
|
689
|
-
parser: {
|
|
690
|
-
dataUrlCondition: {
|
|
691
|
-
maxSize: 2 * 1024 // 2kb (低于2kb都会压缩)
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
}]
|
|
695
|
-
}]
|
|
1024
|
+
],
|
|
696
1025
|
};
|
|
697
1026
|
return module;
|
|
698
1027
|
};
|
|
@@ -701,60 +1030,84 @@ var getOptimization = function getOptimization(params) {
|
|
|
701
1030
|
var minimize = params.minimize;
|
|
702
1031
|
if (!minimize) {
|
|
703
1032
|
return {
|
|
704
|
-
minimize: false
|
|
1033
|
+
minimize: false,
|
|
705
1034
|
};
|
|
706
1035
|
}
|
|
707
1036
|
return {
|
|
708
|
-
minimize: minimize
|
|
1037
|
+
minimize: minimize,
|
|
709
1038
|
};
|
|
710
1039
|
};
|
|
711
1040
|
|
|
712
|
-
var _excluded$1 = [
|
|
1041
|
+
var _excluded$1 = ['path', 'filename'];
|
|
713
1042
|
var getOutput = function getOutput(envParams, output) {
|
|
714
1043
|
var workRootDir = envParams.workRootDir;
|
|
715
1044
|
var _ref = output || {},
|
|
716
1045
|
path$1 = _ref.path,
|
|
717
1046
|
filename = _ref.filename,
|
|
718
1047
|
extOutput = _objectWithoutProperties(_ref, _excluded$1);
|
|
719
|
-
return _objectSpread2(
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
1048
|
+
return _objectSpread2(
|
|
1049
|
+
{
|
|
1050
|
+
filename: filename || 'js/[name].[contenthash].js',
|
|
1051
|
+
path:
|
|
1052
|
+
path$1 && path.isAbsolute(path$1)
|
|
1053
|
+
? path$1
|
|
1054
|
+
: path.join(workRootDir, path$1 || 'dist'),
|
|
1055
|
+
clean: true,
|
|
1056
|
+
publicPath: '/',
|
|
1057
|
+
},
|
|
1058
|
+
extOutput
|
|
1059
|
+
);
|
|
725
1060
|
};
|
|
726
1061
|
|
|
727
|
-
var dirname = filePro.getDirname(
|
|
1062
|
+
var dirname = filePro.getDirname({
|
|
1063
|
+
url:
|
|
1064
|
+
typeof document === 'undefined'
|
|
1065
|
+
? require('u' + 'rl').pathToFileURL(__filename).href
|
|
1066
|
+
: (_documentCurrentScript &&
|
|
1067
|
+
_documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' &&
|
|
1068
|
+
_documentCurrentScript.src) ||
|
|
1069
|
+
new URL('index.js', document.baseURI).href,
|
|
1070
|
+
});
|
|
728
1071
|
var packageRootDir = filePro.getPackageRoot(dirname);
|
|
729
1072
|
var cliNodeModulesDir = path.join(packageRootDir, 'node_modules');
|
|
730
|
-
var presetHtmlTemplate = path.join(
|
|
1073
|
+
var presetHtmlTemplate = path.join(
|
|
1074
|
+
packageRootDir,
|
|
1075
|
+
'lib/preset/html/dev-preset.html'
|
|
1076
|
+
);
|
|
731
1077
|
|
|
732
|
-
var _excluded = [
|
|
1078
|
+
var _excluded = ['minimize', 'template'];
|
|
733
1079
|
var getHtmlWebpackPlugin = function getHtmlWebpackPlugin(params) {
|
|
734
1080
|
var minimize = params.minimize,
|
|
735
1081
|
template = params.template,
|
|
736
1082
|
extParams = _objectWithoutProperties(params, _excluded);
|
|
737
|
-
return new HtmlRspackPlugin.default(
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
1083
|
+
return new HtmlRspackPlugin.default(
|
|
1084
|
+
_objectSpread2(
|
|
1085
|
+
{
|
|
1086
|
+
title: 'rspack-react-ts',
|
|
1087
|
+
filename: 'index.html',
|
|
1088
|
+
// 复制 'index.html' 文件,并自动引入打包输出的所有资源(js/css)
|
|
1089
|
+
template: template || presetHtmlTemplate,
|
|
1090
|
+
inject: true,
|
|
1091
|
+
// 自动注入静态资源
|
|
1092
|
+
hash: true,
|
|
1093
|
+
cache: false,
|
|
1094
|
+
// 压缩html资源
|
|
1095
|
+
minify: minimize
|
|
1096
|
+
? {
|
|
1097
|
+
removeAttributeQuotes: true,
|
|
1098
|
+
collapseWhitespace: true,
|
|
1099
|
+
//去空格
|
|
1100
|
+
removeComments: true,
|
|
1101
|
+
// 去注释
|
|
1102
|
+
minifyJS: true,
|
|
1103
|
+
// 在脚本元素和事件属性中缩小JavaScript(使用UglifyJS)
|
|
1104
|
+
minifyCSS: true, // 缩小CSS样式元素和样式属性
|
|
1105
|
+
}
|
|
1106
|
+
: false,
|
|
1107
|
+
},
|
|
1108
|
+
extParams
|
|
1109
|
+
)
|
|
1110
|
+
);
|
|
758
1111
|
};
|
|
759
1112
|
|
|
760
1113
|
function extractEntryFiles(entry) {
|
|
@@ -762,13 +1115,16 @@ function extractEntryFiles(entry) {
|
|
|
762
1115
|
var files = [];
|
|
763
1116
|
var _push = function push(v) {
|
|
764
1117
|
if (!v) return;
|
|
765
|
-
if (typeof v === 'string') files.push(v);
|
|
1118
|
+
if (typeof v === 'string') files.push(v);
|
|
1119
|
+
else if (Array.isArray(v)) v.forEach(_push);
|
|
1120
|
+
else if (typeof v === 'object') {
|
|
766
1121
|
// 对象可能是 { import: '...' } 或 { import: ['...'] }
|
|
767
1122
|
// 也可能是其它 webpack entry 描述符
|
|
768
1123
|
// 尝试提取 import 字段
|
|
769
|
-
|
|
1124
|
+
|
|
770
1125
|
var obj = v;
|
|
771
|
-
if (obj.import) _push(obj.import);
|
|
1126
|
+
if (obj.import) _push(obj.import);
|
|
1127
|
+
else {
|
|
772
1128
|
// 可能是 nested object of entry points
|
|
773
1129
|
Object.values(obj).forEach(_push);
|
|
774
1130
|
}
|
|
@@ -777,56 +1133,77 @@ function extractEntryFiles(entry) {
|
|
|
777
1133
|
_push(entry);
|
|
778
1134
|
return files;
|
|
779
1135
|
}
|
|
780
|
-
var TsconfigPlugin = /*#__PURE__*/function () {
|
|
1136
|
+
var TsconfigPlugin = /*#__PURE__*/ (function () {
|
|
781
1137
|
function TsconfigPlugin(workRootDir) {
|
|
782
1138
|
_classCallCheck(this, TsconfigPlugin);
|
|
783
|
-
_defineProperty(this,
|
|
1139
|
+
_defineProperty(this, 'workRootDir', void 0);
|
|
784
1140
|
this.workRootDir = workRootDir;
|
|
785
1141
|
}
|
|
786
|
-
return _createClass(TsconfigPlugin, [
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
1142
|
+
return _createClass(TsconfigPlugin, [
|
|
1143
|
+
{
|
|
1144
|
+
key: 'apply',
|
|
1145
|
+
value: function apply(compiler) {
|
|
1146
|
+
var _this = this;
|
|
1147
|
+
// 使用 beforeRun.tapPromise 以 async/await 方式在构建前完成 I/O
|
|
1148
|
+
compiler.hooks.beforeRun.tapPromise(
|
|
1149
|
+
'TsconfigPlugin',
|
|
1150
|
+
/*#__PURE__*/ (function () {
|
|
1151
|
+
var _ref = _asyncToGenerator(
|
|
1152
|
+
/*#__PURE__*/ _regenerator().m(function _callee(comp) {
|
|
1153
|
+
var _ref2, entry, entryFiles, hasTs;
|
|
1154
|
+
return _regenerator().w(
|
|
1155
|
+
function (_context) {
|
|
1156
|
+
while (1)
|
|
1157
|
+
switch ((_context.p = _context.n)) {
|
|
1158
|
+
case 0:
|
|
1159
|
+
_context.p = 0;
|
|
1160
|
+
entry =
|
|
1161
|
+
(_ref2 = comp.options && comp.options.entry) !==
|
|
1162
|
+
null && _ref2 !== void 0
|
|
1163
|
+
? _ref2
|
|
1164
|
+
: {};
|
|
1165
|
+
entryFiles = extractEntryFiles(entry); // 如果 entry 是函数/动态生成,entryFiles 可能为空,保守处理
|
|
1166
|
+
hasTs = entryFiles.some(function (f) {
|
|
1167
|
+
return /\.(ts|tsx)$/.test(path.extname(String(f)));
|
|
1168
|
+
});
|
|
1169
|
+
if (hasTs) {
|
|
1170
|
+
_context.n = 1;
|
|
1171
|
+
break;
|
|
1172
|
+
}
|
|
1173
|
+
return _context.a(2);
|
|
1174
|
+
case 1:
|
|
1175
|
+
_context.n = 2;
|
|
1176
|
+
return helper.insertTsconfig(_this.workRootDir);
|
|
1177
|
+
case 2:
|
|
1178
|
+
_context.n = 4;
|
|
1179
|
+
break;
|
|
1180
|
+
case 3:
|
|
1181
|
+
_context.p = 3;
|
|
1182
|
+
_context.v;
|
|
1183
|
+
helper.cLog.error(
|
|
1184
|
+
'init',
|
|
1185
|
+
'error',
|
|
1186
|
+
'自动注入 tsconfig.json 失败'
|
|
1187
|
+
);
|
|
1188
|
+
case 4:
|
|
1189
|
+
return _context.a(2);
|
|
1190
|
+
}
|
|
1191
|
+
},
|
|
1192
|
+
_callee,
|
|
1193
|
+
null,
|
|
1194
|
+
[[0, 3]]
|
|
1195
|
+
);
|
|
1196
|
+
})
|
|
1197
|
+
);
|
|
1198
|
+
return function (_x) {
|
|
1199
|
+
return _ref.apply(this, arguments);
|
|
1200
|
+
};
|
|
1201
|
+
})()
|
|
1202
|
+
);
|
|
1203
|
+
},
|
|
1204
|
+
},
|
|
1205
|
+
]);
|
|
1206
|
+
})();
|
|
830
1207
|
|
|
831
1208
|
var getTsconfigPlugin = function getTsconfigPlugin(envParams) {
|
|
832
1209
|
return new TsconfigPlugin(envParams.workRootDir);
|
|
@@ -836,25 +1213,38 @@ var getReactPluginsPreset = function getReactPluginsPreset(envParams, options) {
|
|
|
836
1213
|
var action = envParams.action;
|
|
837
1214
|
var isDevelopment = action === 'server';
|
|
838
1215
|
options.WebpackBundleAnalyzerOptions;
|
|
839
|
-
|
|
1216
|
+
var HtmlWebpackPluginOptions = options.HtmlWebpackPluginOptions,
|
|
840
1217
|
minimize = options.minimize;
|
|
841
1218
|
|
|
842
1219
|
// html入口文件路径
|
|
843
1220
|
var rightFile = filePro.lookupFile(htmlEntryList);
|
|
844
1221
|
if (!rightFile) {
|
|
845
|
-
helper.cLog.warn(
|
|
1222
|
+
helper.cLog.warn(
|
|
1223
|
+
'init',
|
|
1224
|
+
'not_found',
|
|
1225
|
+
'未找到 html 入口文件,将使用预设配置'
|
|
1226
|
+
);
|
|
846
1227
|
}
|
|
847
1228
|
var plugins = [getTsconfigPlugin(envParams)];
|
|
848
1229
|
if (action !== 'lib') {
|
|
849
|
-
plugins.push(
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
1230
|
+
plugins.push(
|
|
1231
|
+
getHtmlWebpackPlugin(
|
|
1232
|
+
_objectSpread2(
|
|
1233
|
+
{
|
|
1234
|
+
minimize: minimize,
|
|
1235
|
+
template: rightFile || undefined,
|
|
1236
|
+
},
|
|
1237
|
+
HtmlWebpackPluginOptions
|
|
1238
|
+
)
|
|
1239
|
+
)
|
|
1240
|
+
);
|
|
853
1241
|
}
|
|
854
1242
|
if (!isDevelopment) {
|
|
855
|
-
plugins.push(
|
|
856
|
-
|
|
857
|
-
|
|
1243
|
+
plugins.push(
|
|
1244
|
+
new rspack.CssExtractRspackPlugin({
|
|
1245
|
+
filename: 'css/main.[contenthash].css',
|
|
1246
|
+
})
|
|
1247
|
+
);
|
|
858
1248
|
}
|
|
859
1249
|
|
|
860
1250
|
// if (WebpackBundleAnalyzerOptions) {
|
|
@@ -874,9 +1264,12 @@ var getReactPluginsPreset = function getReactPluginsPreset(envParams, options) {
|
|
|
874
1264
|
* @returns
|
|
875
1265
|
*/
|
|
876
1266
|
var getResolve = function getResolve(resolveConfig) {
|
|
877
|
-
var resolveObj = _objectSpread2(
|
|
878
|
-
|
|
879
|
-
|
|
1267
|
+
var resolveObj = _objectSpread2(
|
|
1268
|
+
{
|
|
1269
|
+
extensions: ['.ts', '.tsx', '.js', '.jsx'],
|
|
1270
|
+
},
|
|
1271
|
+
resolveConfig
|
|
1272
|
+
);
|
|
880
1273
|
return resolveObj;
|
|
881
1274
|
};
|
|
882
1275
|
|
|
@@ -884,49 +1277,64 @@ var getResolveLoader = function getResolveLoader() {
|
|
|
884
1277
|
return {
|
|
885
1278
|
modules: [cliNodeModulesDir],
|
|
886
1279
|
extensions: ['.js', '.json'],
|
|
887
|
-
mainFields: ['loader', 'main']
|
|
1280
|
+
mainFields: ['loader', 'main'],
|
|
888
1281
|
};
|
|
889
1282
|
};
|
|
890
1283
|
|
|
891
|
-
var Ctx = /*#__PURE__*/function () {
|
|
1284
|
+
var Ctx = /*#__PURE__*/ (function () {
|
|
892
1285
|
function Ctx(configCtx) {
|
|
893
1286
|
_classCallCheck(this, Ctx);
|
|
894
|
-
_defineProperty(this,
|
|
895
|
-
_defineProperty(this,
|
|
896
|
-
_defineProperty(this,
|
|
897
|
-
_defineProperty(this,
|
|
1287
|
+
_defineProperty(this, 'configCtx', void 0);
|
|
1288
|
+
_defineProperty(this, 'rspackConfig', {});
|
|
1289
|
+
_defineProperty(this, 'devServerConfig', {});
|
|
1290
|
+
_defineProperty(this, 'envParams', {
|
|
898
1291
|
action: 'build',
|
|
899
|
-
workRootDir: filePro.getCwd()
|
|
1292
|
+
workRootDir: filePro.getCwd(),
|
|
900
1293
|
});
|
|
901
1294
|
this.configCtx = configCtx;
|
|
902
1295
|
}
|
|
903
|
-
return _createClass(Ctx, [
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
}
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
}
|
|
1296
|
+
return _createClass(Ctx, [
|
|
1297
|
+
{
|
|
1298
|
+
key: 'updateEnvParams',
|
|
1299
|
+
value: function updateEnvParams(argv) {
|
|
1300
|
+
this.envParams = _objectSpread2(
|
|
1301
|
+
_objectSpread2({}, this.envParams),
|
|
1302
|
+
argv
|
|
1303
|
+
);
|
|
1304
|
+
},
|
|
1305
|
+
},
|
|
1306
|
+
{
|
|
1307
|
+
key: 'updateRspackConfig',
|
|
1308
|
+
value: function updateRspackConfig(config) {
|
|
1309
|
+
this.rspackConfig = _objectSpread2(
|
|
1310
|
+
_objectSpread2({}, this.rspackConfig),
|
|
1311
|
+
config
|
|
1312
|
+
);
|
|
1313
|
+
},
|
|
1314
|
+
},
|
|
1315
|
+
{
|
|
1316
|
+
key: 'updateDevServerConfig',
|
|
1317
|
+
value: function updateDevServerConfig(config) {
|
|
1318
|
+
this.devServerConfig = _objectSpread2(
|
|
1319
|
+
_objectSpread2({}, this.devServerConfig),
|
|
1320
|
+
config
|
|
1321
|
+
);
|
|
1322
|
+
},
|
|
1323
|
+
},
|
|
1324
|
+
{
|
|
1325
|
+
key: 'getDoraConfig',
|
|
1326
|
+
value: function getDoraConfig() {
|
|
1327
|
+
return this.configCtx.getDoraConfig();
|
|
1328
|
+
},
|
|
1329
|
+
},
|
|
1330
|
+
{
|
|
1331
|
+
key: 'geTDoraConfigRspack',
|
|
1332
|
+
value: function geTDoraConfigRspack() {
|
|
1333
|
+
return this.configCtx.getDoraConfig().rspackConfig || {};
|
|
1334
|
+
},
|
|
1335
|
+
},
|
|
1336
|
+
]);
|
|
1337
|
+
})();
|
|
930
1338
|
|
|
931
1339
|
exports.Compiler = Compiler;
|
|
932
1340
|
exports.Ctx = Ctx;
|