@modern-js/babel-compiler 2.15.0 → 2.16.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 +13 -0
- package/dist/cjs/build.js +16 -47
- package/dist/cjs/buildWatch.js +119 -89
- package/dist/cjs/compiler.js +73 -75
- package/dist/cjs/compilerErrorResult.js +28 -34
- package/dist/cjs/constants.js +7 -25
- package/dist/cjs/defaults.js +9 -27
- package/dist/cjs/getFinalOption.js +33 -50
- package/dist/cjs/index.js +29 -36
- package/dist/cjs/type.js +4 -15
- package/dist/cjs/utils.js +49 -37
- package/dist/cjs/validate.js +21 -33
- package/dist/esm/build.js +217 -210
- package/dist/esm/buildWatch.js +389 -375
- package/dist/esm/compiler.js +118 -119
- package/dist/esm/compilerErrorResult.js +103 -100
- package/dist/esm/constants.js +5 -6
- package/dist/esm/defaults.js +36 -37
- package/dist/esm/getFinalOption.js +124 -116
- package/dist/esm/index.js +154 -148
- package/dist/esm/type.js +1 -1
- package/dist/esm/utils.js +2 -3
- package/dist/esm/validate.js +31 -32
- package/dist/esm-node/build.js +4 -20
- package/dist/esm-node/buildWatch.js +60 -51
- package/dist/esm-node/compiler.js +8 -31
- package/dist/esm-node/compilerErrorResult.js +21 -12
- package/dist/esm-node/constants.js +1 -4
- package/dist/esm-node/defaults.js +1 -4
- package/dist/esm-node/getFinalOption.js +16 -24
- package/dist/esm-node/index.js +1 -4
- package/dist/esm-node/type.js +1 -0
- package/dist/esm-node/utils.js +1 -4
- package/dist/esm-node/validate.js +10 -13
- package/package.json +9 -5
package/dist/esm/buildWatch.js
CHANGED
|
@@ -1,417 +1,431 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
function _assert_this_initialized(self) {
|
|
2
|
+
if (self === void 0) {
|
|
3
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
4
|
+
}
|
|
5
|
+
return self;
|
|
6
6
|
}
|
|
7
7
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
try {
|
|
9
|
+
var info = gen[key](arg);
|
|
10
|
+
var value = info.value;
|
|
11
|
+
} catch (error) {
|
|
12
|
+
reject(error);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (info.done) {
|
|
16
|
+
resolve(value);
|
|
17
|
+
} else {
|
|
18
|
+
Promise.resolve(value).then(_next, _throw);
|
|
19
|
+
}
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
21
|
+
function _async_to_generator(fn) {
|
|
22
|
+
return function() {
|
|
23
|
+
var self = this, args = arguments;
|
|
24
|
+
return new Promise(function(resolve, reject) {
|
|
25
|
+
var gen = fn.apply(self, args);
|
|
26
|
+
function _next(value) {
|
|
27
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
28
|
+
}
|
|
29
|
+
function _throw(err) {
|
|
30
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
31
|
+
}
|
|
32
|
+
_next(void 0);
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
35
|
}
|
|
36
|
-
function
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
function _class_call_check(instance, Constructor) {
|
|
37
|
+
if (!(instance instanceof Constructor)) {
|
|
38
|
+
throw new TypeError("Cannot call a class as a function");
|
|
39
|
+
}
|
|
40
40
|
}
|
|
41
41
|
function _defineProperties(target, props) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
for (var i = 0; i < props.length; i++) {
|
|
43
|
+
var descriptor = props[i];
|
|
44
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
45
|
+
descriptor.configurable = true;
|
|
46
|
+
if ("value" in descriptor)
|
|
47
|
+
descriptor.writable = true;
|
|
48
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
49
|
+
}
|
|
49
50
|
}
|
|
50
|
-
function
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
52
|
+
if (protoProps)
|
|
53
|
+
_defineProperties(Constructor.prototype, protoProps);
|
|
54
|
+
if (staticProps)
|
|
55
|
+
_defineProperties(Constructor, staticProps);
|
|
56
|
+
return Constructor;
|
|
54
57
|
}
|
|
55
|
-
function
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
58
|
+
function _define_property(obj, key, value) {
|
|
59
|
+
if (key in obj) {
|
|
60
|
+
Object.defineProperty(obj, key, {
|
|
61
|
+
value,
|
|
62
|
+
enumerable: true,
|
|
63
|
+
configurable: true,
|
|
64
|
+
writable: true
|
|
65
|
+
});
|
|
66
|
+
} else {
|
|
67
|
+
obj[key] = value;
|
|
68
|
+
}
|
|
69
|
+
return obj;
|
|
67
70
|
}
|
|
68
|
-
function
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
function _get_prototype_of(o) {
|
|
72
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o2) {
|
|
73
|
+
return o2.__proto__ || Object.getPrototypeOf(o2);
|
|
74
|
+
};
|
|
75
|
+
return _get_prototype_of(o);
|
|
73
76
|
}
|
|
74
77
|
function _inherits(subClass, superClass) {
|
|
75
|
-
|
|
76
|
-
|
|
78
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
79
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
80
|
+
}
|
|
81
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
82
|
+
constructor: {
|
|
83
|
+
value: subClass,
|
|
84
|
+
writable: true,
|
|
85
|
+
configurable: true
|
|
77
86
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
writable: true,
|
|
82
|
-
configurable: true
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
87
|
+
});
|
|
88
|
+
if (superClass)
|
|
89
|
+
_set_prototype_of(subClass, superClass);
|
|
86
90
|
}
|
|
87
|
-
function
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
ownKeys.forEach(function(key) {
|
|
97
|
-
_defineProperty(target, key, source[key]);
|
|
98
|
-
});
|
|
91
|
+
function _object_spread(target) {
|
|
92
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
93
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
94
|
+
var ownKeys2 = Object.keys(source);
|
|
95
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
96
|
+
ownKeys2 = ownKeys2.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
97
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
98
|
+
}));
|
|
99
99
|
}
|
|
100
|
-
|
|
100
|
+
ownKeys2.forEach(function(key) {
|
|
101
|
+
_define_property(target, key, source[key]);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
return target;
|
|
101
105
|
}
|
|
102
106
|
function ownKeys(object, enumerableOnly) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
keys.push.apply(keys, symbols);
|
|
107
|
+
var keys = Object.keys(object);
|
|
108
|
+
if (Object.getOwnPropertySymbols) {
|
|
109
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
110
|
+
if (enumerableOnly) {
|
|
111
|
+
symbols = symbols.filter(function(sym) {
|
|
112
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
113
|
+
});
|
|
112
114
|
}
|
|
113
|
-
|
|
115
|
+
keys.push.apply(keys, symbols);
|
|
116
|
+
}
|
|
117
|
+
return keys;
|
|
114
118
|
}
|
|
115
|
-
function
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
119
|
+
function _object_spread_props(target, source) {
|
|
120
|
+
source = source != null ? source : {};
|
|
121
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
122
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
123
|
+
} else {
|
|
124
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
125
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
return target;
|
|
125
129
|
}
|
|
126
|
-
function
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
130
|
+
function _possible_constructor_return(self, call) {
|
|
131
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
132
|
+
return call;
|
|
133
|
+
}
|
|
134
|
+
return _assert_this_initialized(self);
|
|
131
135
|
}
|
|
132
|
-
function
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
136
|
+
function _set_prototype_of(o, p) {
|
|
137
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o2, p2) {
|
|
138
|
+
o2.__proto__ = p2;
|
|
139
|
+
return o2;
|
|
140
|
+
};
|
|
141
|
+
return _set_prototype_of(o, p);
|
|
138
142
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
};
|
|
143
|
-
function _isNativeReflectConstruct() {
|
|
144
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
145
|
-
if (Reflect.construct.sham) return false;
|
|
146
|
-
if (typeof Proxy === "function") return true;
|
|
147
|
-
try {
|
|
148
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
149
|
-
return true;
|
|
150
|
-
} catch (e) {
|
|
151
|
-
return false;
|
|
152
|
-
}
|
|
143
|
+
function _type_of(obj) {
|
|
144
|
+
"@swc/helpers - typeof";
|
|
145
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
153
146
|
}
|
|
154
|
-
function
|
|
155
|
-
|
|
156
|
-
return
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
147
|
+
function _is_native_reflect_construct() {
|
|
148
|
+
if (typeof Reflect === "undefined" || !Reflect.construct)
|
|
149
|
+
return false;
|
|
150
|
+
if (Reflect.construct.sham)
|
|
151
|
+
return false;
|
|
152
|
+
if (typeof Proxy === "function")
|
|
153
|
+
return true;
|
|
154
|
+
try {
|
|
155
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
|
|
156
|
+
}));
|
|
157
|
+
return true;
|
|
158
|
+
} catch (e) {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
166
161
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
};
|
|
177
|
-
return(g = {
|
|
178
|
-
next: verb(0),
|
|
179
|
-
"throw": verb(1),
|
|
180
|
-
"return": verb(2)
|
|
181
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
182
|
-
return this;
|
|
183
|
-
}), g);
|
|
184
|
-
function verb(n) {
|
|
185
|
-
return function(v) {
|
|
186
|
-
return step([
|
|
187
|
-
n,
|
|
188
|
-
v
|
|
189
|
-
]);
|
|
190
|
-
};
|
|
162
|
+
function _create_super(Derived) {
|
|
163
|
+
var hasNativeReflectConstruct = _is_native_reflect_construct();
|
|
164
|
+
return function _createSuperInternal() {
|
|
165
|
+
var Super = _get_prototype_of(Derived), result;
|
|
166
|
+
if (hasNativeReflectConstruct) {
|
|
167
|
+
var NewTarget = _get_prototype_of(this).constructor;
|
|
168
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
169
|
+
} else {
|
|
170
|
+
result = Super.apply(this, arguments);
|
|
191
171
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
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
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
172
|
+
return _possible_constructor_return(this, result);
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
var __generator = function(thisArg, body) {
|
|
176
|
+
var f, y, t, g, _ = {
|
|
177
|
+
label: 0,
|
|
178
|
+
sent: function() {
|
|
179
|
+
if (t[0] & 1)
|
|
180
|
+
throw t[1];
|
|
181
|
+
return t[1];
|
|
182
|
+
},
|
|
183
|
+
trys: [],
|
|
184
|
+
ops: []
|
|
185
|
+
};
|
|
186
|
+
return g = {
|
|
187
|
+
next: verb(0),
|
|
188
|
+
"throw": verb(1),
|
|
189
|
+
"return": verb(2)
|
|
190
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
191
|
+
return this;
|
|
192
|
+
}), g;
|
|
193
|
+
function verb(n) {
|
|
194
|
+
return function(v) {
|
|
195
|
+
return step([
|
|
196
|
+
n,
|
|
197
|
+
v
|
|
198
|
+
]);
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
function step(op) {
|
|
202
|
+
if (f)
|
|
203
|
+
throw new TypeError("Generator is already executing.");
|
|
204
|
+
while (_)
|
|
205
|
+
try {
|
|
206
|
+
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)
|
|
207
|
+
return t;
|
|
208
|
+
if (y = 0, t)
|
|
209
|
+
op = [
|
|
210
|
+
op[0] & 2,
|
|
211
|
+
t.value
|
|
212
|
+
];
|
|
213
|
+
switch (op[0]) {
|
|
214
|
+
case 0:
|
|
215
|
+
case 1:
|
|
216
|
+
t = op;
|
|
217
|
+
break;
|
|
218
|
+
case 4:
|
|
219
|
+
_.label++;
|
|
220
|
+
return {
|
|
221
|
+
value: op[1],
|
|
222
|
+
done: false
|
|
223
|
+
};
|
|
224
|
+
case 5:
|
|
225
|
+
_.label++;
|
|
226
|
+
y = op[1];
|
|
247
227
|
op = [
|
|
248
|
-
|
|
249
|
-
e
|
|
228
|
+
0
|
|
250
229
|
];
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
230
|
+
continue;
|
|
231
|
+
case 7:
|
|
232
|
+
op = _.ops.pop();
|
|
233
|
+
_.trys.pop();
|
|
234
|
+
continue;
|
|
235
|
+
default:
|
|
236
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
237
|
+
_ = 0;
|
|
238
|
+
continue;
|
|
239
|
+
}
|
|
240
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
241
|
+
_.label = op[1];
|
|
242
|
+
break;
|
|
243
|
+
}
|
|
244
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
245
|
+
_.label = t[1];
|
|
246
|
+
t = op;
|
|
247
|
+
break;
|
|
248
|
+
}
|
|
249
|
+
if (t && _.label < t[2]) {
|
|
250
|
+
_.label = t[2];
|
|
251
|
+
_.ops.push(op);
|
|
252
|
+
break;
|
|
253
|
+
}
|
|
254
|
+
if (t[2])
|
|
255
|
+
_.ops.pop();
|
|
256
|
+
_.trys.pop();
|
|
257
|
+
continue;
|
|
254
258
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
259
|
+
op = body.call(thisArg, _);
|
|
260
|
+
} catch (e) {
|
|
261
|
+
op = [
|
|
262
|
+
6,
|
|
263
|
+
e
|
|
264
|
+
];
|
|
265
|
+
y = 0;
|
|
266
|
+
} finally {
|
|
267
|
+
f = t = 0;
|
|
268
|
+
}
|
|
269
|
+
if (op[0] & 5)
|
|
270
|
+
throw op[1];
|
|
271
|
+
return {
|
|
272
|
+
value: op[0] ? op[1] : void 0,
|
|
273
|
+
done: true
|
|
274
|
+
};
|
|
275
|
+
}
|
|
261
276
|
};
|
|
262
277
|
import * as path from "path";
|
|
263
278
|
import * as Event from "events";
|
|
264
279
|
import { logger, watch, WatchChangeType } from "@modern-js/utils";
|
|
265
280
|
import { build } from "./build";
|
|
266
281
|
import { CompilerErrorResult } from "./compilerErrorResult";
|
|
267
|
-
var BuildWatchEvent = {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
282
|
+
export var BuildWatchEvent = {
|
|
283
|
+
firstCompiler: "first-compiler",
|
|
284
|
+
compiling: "compiling",
|
|
285
|
+
watchingCompiler: "watching-compiler"
|
|
271
286
|
};
|
|
272
|
-
var BuildWatchEmitter =
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
287
|
+
export var BuildWatchEmitter = /* @__PURE__ */ function(_Event_EventEmitter) {
|
|
288
|
+
"use strict";
|
|
289
|
+
_inherits(BuildWatchEmitter2, _Event_EventEmitter);
|
|
290
|
+
var _super = _create_super(BuildWatchEmitter2);
|
|
291
|
+
function BuildWatchEmitter2() {
|
|
292
|
+
_class_call_check(this, BuildWatchEmitter2);
|
|
293
|
+
var _this;
|
|
294
|
+
_this = _super.apply(this, arguments);
|
|
295
|
+
_define_property(_assert_this_initialized(_this), "_initFn", void 0);
|
|
296
|
+
return _this;
|
|
297
|
+
}
|
|
298
|
+
_create_class(BuildWatchEmitter2, [
|
|
299
|
+
{
|
|
300
|
+
key: "setInitFn",
|
|
301
|
+
value: function setInitFn(fn) {
|
|
302
|
+
this._initFn = fn;
|
|
303
|
+
}
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
key: "watch",
|
|
307
|
+
value: function watch2() {
|
|
308
|
+
var _this = this;
|
|
309
|
+
return _async_to_generator(function() {
|
|
310
|
+
return __generator(this, function(_state) {
|
|
311
|
+
if (typeof _this._initFn === "function") {
|
|
312
|
+
return [
|
|
313
|
+
2,
|
|
314
|
+
_this._initFn(_this)
|
|
315
|
+
];
|
|
288
316
|
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
317
|
+
return [
|
|
318
|
+
2,
|
|
319
|
+
null
|
|
320
|
+
];
|
|
321
|
+
});
|
|
322
|
+
})();
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
]);
|
|
326
|
+
return BuildWatchEmitter2;
|
|
327
|
+
}(Event.EventEmitter);
|
|
328
|
+
export var runBuildWatch = function() {
|
|
329
|
+
var _ref = _async_to_generator(function(option) {
|
|
330
|
+
var babelConfig, emitter, errorResult, watchDir, distDir, quiet, firstBuildResult, code;
|
|
331
|
+
var _arguments = arguments;
|
|
332
|
+
return __generator(this, function(_state) {
|
|
333
|
+
switch (_state.label) {
|
|
334
|
+
case 0:
|
|
335
|
+
babelConfig = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {}, emitter = _arguments.length > 2 ? _arguments[2] : void 0;
|
|
336
|
+
emitter.emit(BuildWatchEvent.compiling);
|
|
337
|
+
errorResult = new CompilerErrorResult();
|
|
338
|
+
watchDir = option.watchDir;
|
|
339
|
+
distDir = option.distDir, quiet = option.quiet;
|
|
340
|
+
return [
|
|
341
|
+
4,
|
|
342
|
+
build(option, babelConfig)
|
|
343
|
+
];
|
|
344
|
+
case 1:
|
|
345
|
+
firstBuildResult = _state.sent();
|
|
346
|
+
code = firstBuildResult.code;
|
|
347
|
+
if (code === 1) {
|
|
348
|
+
errorResult.init(firstBuildResult);
|
|
349
|
+
emitter.emit(BuildWatchEvent.firstCompiler, errorResult.value);
|
|
350
|
+
} else {
|
|
351
|
+
emitter.emit(BuildWatchEvent.firstCompiler, firstBuildResult);
|
|
352
|
+
}
|
|
353
|
+
return [
|
|
354
|
+
2,
|
|
355
|
+
watch("".concat(watchDir, "/**/*.{js,jsx,ts,tsx}"), function() {
|
|
356
|
+
var _ref2 = _async_to_generator(function(param) {
|
|
357
|
+
var changeType, changedFilePath, removeFiles, result, result1;
|
|
358
|
+
return __generator(this, function(_state2) {
|
|
359
|
+
switch (_state2.label) {
|
|
360
|
+
case 0:
|
|
361
|
+
changeType = param.changeType, changedFilePath = param.changedFilePath;
|
|
362
|
+
emitter.emit(BuildWatchEvent.compiling);
|
|
363
|
+
if (changeType === WatchChangeType.UNLINK) {
|
|
364
|
+
removeFiles = [
|
|
365
|
+
path.normalize("./".concat(distDir, "/").concat(path.relative(watchDir, changedFilePath)))
|
|
366
|
+
];
|
|
367
|
+
if (!quiet) {
|
|
368
|
+
logger.info("remove file: ".concat(removeFiles.join(",")));
|
|
301
369
|
}
|
|
370
|
+
result = {
|
|
371
|
+
code: 0,
|
|
372
|
+
message: "remove file: ".concat(removeFiles.join(",")),
|
|
373
|
+
removeFiles
|
|
374
|
+
};
|
|
375
|
+
emitter.emit(BuildWatchEvent.watchingCompiler, result);
|
|
302
376
|
return [
|
|
303
|
-
|
|
304
|
-
null
|
|
377
|
+
2
|
|
305
378
|
];
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
]);
|
|
311
|
-
return BuildWatchEmitter;
|
|
312
|
-
}(Event.EventEmitter);
|
|
313
|
-
var runBuildWatch = function() {
|
|
314
|
-
var _ref = _asyncToGenerator(function(option) {
|
|
315
|
-
var babelConfig, emitter, errorResult, watchDir, distDir, quiet, firstBuildResult, code;
|
|
316
|
-
var _arguments = arguments;
|
|
317
|
-
return __generator(this, function(_state) {
|
|
318
|
-
switch(_state.label){
|
|
319
|
-
case 0:
|
|
320
|
-
babelConfig = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {}, emitter = _arguments.length > 2 ? _arguments[2] : void 0;
|
|
321
|
-
emitter.emit(BuildWatchEvent.compiling);
|
|
322
|
-
errorResult = new CompilerErrorResult();
|
|
323
|
-
watchDir = option.watchDir;
|
|
324
|
-
distDir = option.distDir, quiet = option.quiet;
|
|
325
|
-
return [
|
|
379
|
+
}
|
|
380
|
+
return [
|
|
326
381
|
4,
|
|
327
|
-
build(option,
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
return [
|
|
366
|
-
4,
|
|
367
|
-
build(_objectSpreadProps(_objectSpread({}, option), {
|
|
368
|
-
filenames: [
|
|
369
|
-
changedFilePath
|
|
370
|
-
]
|
|
371
|
-
}), babelConfig)
|
|
372
|
-
];
|
|
373
|
-
case 1:
|
|
374
|
-
result = _state.sent();
|
|
375
|
-
if (result.code === 1) {
|
|
376
|
-
errorResult.update(result.messageDetails || []);
|
|
377
|
-
emitter.emit(BuildWatchEvent.watchingCompiler, errorResult.value);
|
|
378
|
-
!quiet && logger.info(errorResult.value.message);
|
|
379
|
-
} else {
|
|
380
|
-
errorResult.removeByFileName(changedFilePath);
|
|
381
|
-
if (errorResult.checkExistError()) {
|
|
382
|
-
emitter.emit(BuildWatchEvent.watchingCompiler, _objectSpreadProps(_objectSpread({}, errorResult.value), {
|
|
383
|
-
virtualDists: result.virtualDists
|
|
384
|
-
}));
|
|
385
|
-
!quiet && logger.info(errorResult.value.message);
|
|
386
|
-
} else {
|
|
387
|
-
emitter.emit(BuildWatchEvent.watchingCompiler, result);
|
|
388
|
-
!quiet && logger.info(result.message);
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
return [
|
|
392
|
-
2
|
|
393
|
-
];
|
|
394
|
-
}
|
|
395
|
-
});
|
|
396
|
-
});
|
|
397
|
-
return function(_) {
|
|
398
|
-
return _ref.apply(this, arguments);
|
|
399
|
-
};
|
|
400
|
-
}(), [
|
|
401
|
-
"".concat(watchDir, "/**/*.d.ts")
|
|
402
|
-
])
|
|
403
|
-
];
|
|
404
|
-
}
|
|
405
|
-
});
|
|
382
|
+
build(_object_spread_props(_object_spread({}, option), {
|
|
383
|
+
filenames: [
|
|
384
|
+
changedFilePath
|
|
385
|
+
]
|
|
386
|
+
}), babelConfig)
|
|
387
|
+
];
|
|
388
|
+
case 1:
|
|
389
|
+
result1 = _state2.sent();
|
|
390
|
+
if (result1.code === 1) {
|
|
391
|
+
errorResult.update(result1.messageDetails || []);
|
|
392
|
+
emitter.emit(BuildWatchEvent.watchingCompiler, errorResult.value);
|
|
393
|
+
!quiet && logger.info(errorResult.value.message);
|
|
394
|
+
} else {
|
|
395
|
+
errorResult.removeByFileName(changedFilePath);
|
|
396
|
+
if (errorResult.checkExistError()) {
|
|
397
|
+
emitter.emit(BuildWatchEvent.watchingCompiler, _object_spread_props(_object_spread({}, errorResult.value), {
|
|
398
|
+
virtualDists: result1.virtualDists
|
|
399
|
+
}));
|
|
400
|
+
!quiet && logger.info(errorResult.value.message);
|
|
401
|
+
} else {
|
|
402
|
+
emitter.emit(BuildWatchEvent.watchingCompiler, result1);
|
|
403
|
+
!quiet && logger.info(result1.message);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
return [
|
|
407
|
+
2
|
|
408
|
+
];
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
});
|
|
412
|
+
return function(_) {
|
|
413
|
+
return _ref2.apply(this, arguments);
|
|
414
|
+
};
|
|
415
|
+
}(), [
|
|
416
|
+
"".concat(watchDir, "/**/*.d.ts")
|
|
417
|
+
])
|
|
418
|
+
];
|
|
419
|
+
}
|
|
406
420
|
});
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
421
|
+
});
|
|
422
|
+
return function runBuildWatch2(option) {
|
|
423
|
+
return _ref.apply(this, arguments);
|
|
424
|
+
};
|
|
410
425
|
}();
|
|
411
|
-
var buildWatch = function(option) {
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
426
|
+
export var buildWatch = function(option) {
|
|
427
|
+
var babelConfig = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
428
|
+
var buildWatchEmitter = new BuildWatchEmitter();
|
|
429
|
+
buildWatchEmitter.setInitFn(runBuildWatch.bind(null, option, babelConfig));
|
|
430
|
+
return buildWatchEmitter;
|
|
416
431
|
};
|
|
417
|
-
export { BuildWatchEmitter, BuildWatchEvent, buildWatch, runBuildWatch };
|