@modern-js/server-utils 2.15.0 → 2.17.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 +23 -0
- package/dist/cjs/common/index.js +69 -52
- package/dist/cjs/compilers/babel/index.js +118 -96
- package/dist/cjs/compilers/typescript/index.js +50 -78
- package/dist/cjs/compilers/typescript/tsconfigPathsPlugin.js +85 -88
- package/dist/cjs/compilers/typescript/typescriptLoader.js +29 -32
- package/dist/cjs/index.js +21 -27
- package/dist/esm/common/index.js +193 -185
- package/dist/esm/compilers/babel/index.js +294 -287
- package/dist/esm/compilers/typescript/index.js +352 -335
- package/dist/esm/compilers/typescript/tsconfigPathsPlugin.js +224 -209
- package/dist/esm/compilers/typescript/typescriptLoader.js +60 -58
- package/dist/esm/index.js +1 -2
- package/dist/esm-node/common/index.js +11 -15
- package/dist/esm-node/compilers/babel/index.js +45 -59
- package/dist/esm-node/compilers/typescript/index.js +18 -26
- package/dist/esm-node/compilers/typescript/tsconfigPathsPlugin.js +30 -48
- package/dist/esm-node/compilers/typescript/typescriptLoader.js +22 -10
- package/dist/esm-node/index.js +1 -4
- package/package.json +12 -8
|
@@ -1,179 +1,195 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
function _array_like_to_array(arr, len) {
|
|
2
|
+
if (len == null || len > arr.length)
|
|
3
|
+
len = arr.length;
|
|
4
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
5
|
+
arr2[i] = arr[i];
|
|
6
|
+
return arr2;
|
|
5
7
|
}
|
|
6
|
-
function
|
|
7
|
-
|
|
8
|
+
function _array_without_holes(arr) {
|
|
9
|
+
if (Array.isArray(arr))
|
|
10
|
+
return _array_like_to_array(arr);
|
|
8
11
|
}
|
|
9
12
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
try {
|
|
14
|
+
var info = gen[key](arg);
|
|
15
|
+
var value = info.value;
|
|
16
|
+
} catch (error) {
|
|
17
|
+
reject(error);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (info.done) {
|
|
21
|
+
resolve(value);
|
|
22
|
+
} else {
|
|
23
|
+
Promise.resolve(value).then(_next, _throw);
|
|
24
|
+
}
|
|
22
25
|
}
|
|
23
|
-
function
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
function _async_to_generator(fn) {
|
|
27
|
+
return function() {
|
|
28
|
+
var self = this, args = arguments;
|
|
29
|
+
return new Promise(function(resolve, reject) {
|
|
30
|
+
var gen = fn.apply(self, args);
|
|
31
|
+
function _next(value) {
|
|
32
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
33
|
+
}
|
|
34
|
+
function _throw(err) {
|
|
35
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
36
|
+
}
|
|
37
|
+
_next(void 0);
|
|
38
|
+
});
|
|
39
|
+
};
|
|
37
40
|
}
|
|
38
|
-
function
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
41
|
+
function _define_property(obj, key, value) {
|
|
42
|
+
if (key in obj) {
|
|
43
|
+
Object.defineProperty(obj, key, {
|
|
44
|
+
value,
|
|
45
|
+
enumerable: true,
|
|
46
|
+
configurable: true,
|
|
47
|
+
writable: true
|
|
48
|
+
});
|
|
49
|
+
} else {
|
|
50
|
+
obj[key] = value;
|
|
51
|
+
}
|
|
52
|
+
return obj;
|
|
50
53
|
}
|
|
51
|
-
function
|
|
52
|
-
|
|
54
|
+
function _iterable_to_array(iter) {
|
|
55
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null)
|
|
56
|
+
return Array.from(iter);
|
|
53
57
|
}
|
|
54
|
-
function
|
|
55
|
-
|
|
58
|
+
function _non_iterable_spread() {
|
|
59
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
56
60
|
}
|
|
57
|
-
function
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
ownKeys.forEach(function(key) {
|
|
67
|
-
_defineProperty(target, key, source[key]);
|
|
68
|
-
});
|
|
61
|
+
function _object_spread(target) {
|
|
62
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
63
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
64
|
+
var ownKeys = Object.keys(source);
|
|
65
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
66
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
67
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
68
|
+
}));
|
|
69
69
|
}
|
|
70
|
-
|
|
70
|
+
ownKeys.forEach(function(key) {
|
|
71
|
+
_define_property(target, key, source[key]);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
return target;
|
|
71
75
|
}
|
|
72
|
-
function
|
|
73
|
-
|
|
76
|
+
function _to_consumable_array(arr) {
|
|
77
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
74
78
|
}
|
|
75
|
-
function
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
80
|
+
if (!o)
|
|
81
|
+
return;
|
|
82
|
+
if (typeof o === "string")
|
|
83
|
+
return _array_like_to_array(o, minLen);
|
|
84
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
85
|
+
if (n === "Object" && o.constructor)
|
|
86
|
+
n = o.constructor.name;
|
|
87
|
+
if (n === "Map" || n === "Set")
|
|
88
|
+
return Array.from(n);
|
|
89
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
|
|
90
|
+
return _array_like_to_array(o, minLen);
|
|
82
91
|
}
|
|
83
|
-
var __generator =
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
+
var __generator = function(thisArg, body) {
|
|
93
|
+
var f, y, t, g, _ = {
|
|
94
|
+
label: 0,
|
|
95
|
+
sent: function() {
|
|
96
|
+
if (t[0] & 1)
|
|
97
|
+
throw t[1];
|
|
98
|
+
return t[1];
|
|
99
|
+
},
|
|
100
|
+
trys: [],
|
|
101
|
+
ops: []
|
|
102
|
+
};
|
|
103
|
+
return g = {
|
|
104
|
+
next: verb(0),
|
|
105
|
+
"throw": verb(1),
|
|
106
|
+
"return": verb(2)
|
|
107
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
108
|
+
return this;
|
|
109
|
+
}), g;
|
|
110
|
+
function verb(n) {
|
|
111
|
+
return function(v) {
|
|
112
|
+
return step([
|
|
113
|
+
n,
|
|
114
|
+
v
|
|
115
|
+
]);
|
|
92
116
|
};
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
break;
|
|
121
|
-
case 4:
|
|
122
|
-
_.label++;
|
|
123
|
-
return {
|
|
124
|
-
value: op[1],
|
|
125
|
-
done: false
|
|
126
|
-
};
|
|
127
|
-
case 5:
|
|
128
|
-
_.label++;
|
|
129
|
-
y = op[1];
|
|
130
|
-
op = [
|
|
131
|
-
0
|
|
132
|
-
];
|
|
133
|
-
continue;
|
|
134
|
-
case 7:
|
|
135
|
-
op = _.ops.pop();
|
|
136
|
-
_.trys.pop();
|
|
137
|
-
continue;
|
|
138
|
-
default:
|
|
139
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
140
|
-
_ = 0;
|
|
141
|
-
continue;
|
|
142
|
-
}
|
|
143
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
144
|
-
_.label = op[1];
|
|
145
|
-
break;
|
|
146
|
-
}
|
|
147
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
148
|
-
_.label = t[1];
|
|
149
|
-
t = op;
|
|
150
|
-
break;
|
|
151
|
-
}
|
|
152
|
-
if (t && _.label < t[2]) {
|
|
153
|
-
_.label = t[2];
|
|
154
|
-
_.ops.push(op);
|
|
155
|
-
break;
|
|
156
|
-
}
|
|
157
|
-
if (t[2]) _.ops.pop();
|
|
158
|
-
_.trys.pop();
|
|
159
|
-
continue;
|
|
160
|
-
}
|
|
161
|
-
op = body.call(thisArg, _);
|
|
162
|
-
} catch (e) {
|
|
117
|
+
}
|
|
118
|
+
function step(op) {
|
|
119
|
+
if (f)
|
|
120
|
+
throw new TypeError("Generator is already executing.");
|
|
121
|
+
while (_)
|
|
122
|
+
try {
|
|
123
|
+
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)
|
|
124
|
+
return t;
|
|
125
|
+
if (y = 0, t)
|
|
126
|
+
op = [
|
|
127
|
+
op[0] & 2,
|
|
128
|
+
t.value
|
|
129
|
+
];
|
|
130
|
+
switch (op[0]) {
|
|
131
|
+
case 0:
|
|
132
|
+
case 1:
|
|
133
|
+
t = op;
|
|
134
|
+
break;
|
|
135
|
+
case 4:
|
|
136
|
+
_.label++;
|
|
137
|
+
return {
|
|
138
|
+
value: op[1],
|
|
139
|
+
done: false
|
|
140
|
+
};
|
|
141
|
+
case 5:
|
|
142
|
+
_.label++;
|
|
143
|
+
y = op[1];
|
|
163
144
|
op = [
|
|
164
|
-
|
|
165
|
-
e
|
|
145
|
+
0
|
|
166
146
|
];
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
147
|
+
continue;
|
|
148
|
+
case 7:
|
|
149
|
+
op = _.ops.pop();
|
|
150
|
+
_.trys.pop();
|
|
151
|
+
continue;
|
|
152
|
+
default:
|
|
153
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
154
|
+
_ = 0;
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
158
|
+
_.label = op[1];
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
162
|
+
_.label = t[1];
|
|
163
|
+
t = op;
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
if (t && _.label < t[2]) {
|
|
167
|
+
_.label = t[2];
|
|
168
|
+
_.ops.push(op);
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
if (t[2])
|
|
172
|
+
_.ops.pop();
|
|
173
|
+
_.trys.pop();
|
|
174
|
+
continue;
|
|
170
175
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
176
|
+
op = body.call(thisArg, _);
|
|
177
|
+
} catch (e) {
|
|
178
|
+
op = [
|
|
179
|
+
6,
|
|
180
|
+
e
|
|
181
|
+
];
|
|
182
|
+
y = 0;
|
|
183
|
+
} finally {
|
|
184
|
+
f = t = 0;
|
|
185
|
+
}
|
|
186
|
+
if (op[0] & 5)
|
|
187
|
+
throw op[1];
|
|
188
|
+
return {
|
|
189
|
+
value: op[0] ? op[1] : void 0,
|
|
190
|
+
done: true
|
|
191
|
+
};
|
|
192
|
+
}
|
|
177
193
|
};
|
|
178
194
|
import path from "path";
|
|
179
195
|
import { logger, getAliasConfig, fs } from "@modern-js/utils";
|
|
@@ -181,187 +197,188 @@ import ts from "typescript";
|
|
|
181
197
|
import { TypescriptLoader } from "./typescriptLoader";
|
|
182
198
|
import { tsconfigPathsBeforeHookFactory } from "./tsconfigPathsPlugin";
|
|
183
199
|
var readTsConfigByFile = function(tsConfigFile) {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
200
|
+
var parsedCmd = ts.getParsedCommandLineOfConfigFile(tsConfigFile, void 0, ts.sys);
|
|
201
|
+
var options = parsedCmd.options, fileNames = parsedCmd.fileNames, projectReferences = parsedCmd.projectReferences;
|
|
202
|
+
return {
|
|
203
|
+
options,
|
|
204
|
+
fileNames,
|
|
205
|
+
projectReferences
|
|
206
|
+
};
|
|
191
207
|
};
|
|
192
208
|
var copyFiles = function() {
|
|
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
|
-
|
|
209
|
+
var _ref = _async_to_generator(function(from, to, appDirectory, tsconfigPath) {
|
|
210
|
+
var relativePath, targetDir;
|
|
211
|
+
return __generator(this, function(_state) {
|
|
212
|
+
switch (_state.label) {
|
|
213
|
+
case 0:
|
|
214
|
+
return [
|
|
215
|
+
4,
|
|
216
|
+
fs.pathExists(from)
|
|
217
|
+
];
|
|
218
|
+
case 1:
|
|
219
|
+
if (!_state.sent())
|
|
220
|
+
return [
|
|
221
|
+
3,
|
|
222
|
+
3
|
|
223
|
+
];
|
|
224
|
+
relativePath = path.relative(appDirectory, from);
|
|
225
|
+
targetDir = path.join(to, relativePath);
|
|
226
|
+
return [
|
|
227
|
+
4,
|
|
228
|
+
fs.copy(from, targetDir, {
|
|
229
|
+
filter: function(src) {
|
|
230
|
+
return ![
|
|
231
|
+
".ts"
|
|
232
|
+
].includes(path.extname(src)) && src !== tsconfigPath;
|
|
233
|
+
}
|
|
234
|
+
})
|
|
235
|
+
];
|
|
236
|
+
case 2:
|
|
237
|
+
_state.sent();
|
|
238
|
+
_state.label = 3;
|
|
239
|
+
case 3:
|
|
240
|
+
return [
|
|
241
|
+
2
|
|
242
|
+
];
|
|
243
|
+
}
|
|
228
244
|
});
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
245
|
+
});
|
|
246
|
+
return function copyFiles2(from, to, appDirectory, tsconfigPath) {
|
|
247
|
+
return _ref.apply(this, arguments);
|
|
248
|
+
};
|
|
232
249
|
}();
|
|
233
|
-
var compileByTs = function() {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
289
|
-
_state.label = 1;
|
|
290
|
-
case 1:
|
|
291
|
-
_state.trys.push([
|
|
292
|
-
1,
|
|
293
|
-
6,
|
|
294
|
-
7,
|
|
295
|
-
8
|
|
296
|
-
]);
|
|
297
|
-
_iterator = sourceDirs[Symbol.iterator]();
|
|
298
|
-
_state.label = 2;
|
|
299
|
-
case 2:
|
|
300
|
-
if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done)) return [
|
|
301
|
-
3,
|
|
302
|
-
5
|
|
303
|
-
];
|
|
304
|
-
source = _step.value;
|
|
305
|
-
return [
|
|
306
|
-
4,
|
|
307
|
-
copyFiles(source, distDir, appDirectory, tsconfigPath)
|
|
308
|
-
];
|
|
309
|
-
case 3:
|
|
310
|
-
_state.sent();
|
|
311
|
-
_state.label = 4;
|
|
312
|
-
case 4:
|
|
313
|
-
_iteratorNormalCompletion = true;
|
|
314
|
-
return [
|
|
315
|
-
3,
|
|
316
|
-
2
|
|
317
|
-
];
|
|
318
|
-
case 5:
|
|
319
|
-
return [
|
|
320
|
-
3,
|
|
321
|
-
8
|
|
322
|
-
];
|
|
323
|
-
case 6:
|
|
324
|
-
err = _state.sent();
|
|
325
|
-
_didIteratorError = true;
|
|
326
|
-
_iteratorError = err;
|
|
327
|
-
return [
|
|
328
|
-
3,
|
|
329
|
-
8
|
|
330
|
-
];
|
|
331
|
-
case 7:
|
|
332
|
-
try {
|
|
333
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
334
|
-
_iterator.return();
|
|
335
|
-
}
|
|
336
|
-
} finally{
|
|
337
|
-
if (_didIteratorError) {
|
|
338
|
-
throw _iteratorError;
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
return [
|
|
342
|
-
7
|
|
343
|
-
];
|
|
344
|
-
case 8:
|
|
345
|
-
logger.info("Ts compile succeed");
|
|
346
|
-
return [
|
|
347
|
-
2
|
|
348
|
-
];
|
|
250
|
+
export var compileByTs = function() {
|
|
251
|
+
var _ref = _async_to_generator(function(appDirectory, config, compileOptions) {
|
|
252
|
+
var sourceDirs, distDir, tsconfigPath, ts2, createProgram, formatHost, alias, aliasOption, _aliasOption_paths, paths, _aliasOption_absoluteBaseUrl, absoluteBaseUrl, _readTsConfigByFile, options, fileNames, projectReferences, sourcePosixPaths, rootNames, program, tsconfigPathsPlugin, emitResult, allDiagnostics, noEmitOnError, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, source, err;
|
|
253
|
+
return __generator(this, function(_state) {
|
|
254
|
+
switch (_state.label) {
|
|
255
|
+
case 0:
|
|
256
|
+
logger.info("Running ts compile...");
|
|
257
|
+
sourceDirs = compileOptions.sourceDirs, distDir = compileOptions.distDir, tsconfigPath = compileOptions.tsconfigPath;
|
|
258
|
+
if (!tsconfigPath) {
|
|
259
|
+
return [
|
|
260
|
+
2
|
|
261
|
+
];
|
|
262
|
+
}
|
|
263
|
+
ts2 = new TypescriptLoader({
|
|
264
|
+
appDirectory
|
|
265
|
+
}).load();
|
|
266
|
+
createProgram = ts2.createIncrementalProgram || ts2.createProgram;
|
|
267
|
+
formatHost = getFormatHost(ts2);
|
|
268
|
+
alias = config.alias;
|
|
269
|
+
aliasOption = getAliasConfig(alias, {
|
|
270
|
+
appDirectory,
|
|
271
|
+
tsconfigPath
|
|
272
|
+
});
|
|
273
|
+
_aliasOption_paths = aliasOption.paths, paths = _aliasOption_paths === void 0 ? {} : _aliasOption_paths, _aliasOption_absoluteBaseUrl = aliasOption.absoluteBaseUrl, absoluteBaseUrl = _aliasOption_absoluteBaseUrl === void 0 ? "./" : _aliasOption_absoluteBaseUrl;
|
|
274
|
+
_readTsConfigByFile = readTsConfigByFile(tsconfigPath), options = _readTsConfigByFile.options, fileNames = _readTsConfigByFile.fileNames, projectReferences = _readTsConfigByFile.projectReferences;
|
|
275
|
+
sourcePosixPaths = sourceDirs.map(function(sourceDir) {
|
|
276
|
+
return sourceDir.split(path.sep).join(path.posix.sep);
|
|
277
|
+
});
|
|
278
|
+
rootNames = fileNames.filter(function(fileName) {
|
|
279
|
+
return fileName.endsWith(".d.ts") || sourcePosixPaths.some(function(sourceDir) {
|
|
280
|
+
return fileName.includes(sourceDir);
|
|
281
|
+
});
|
|
282
|
+
});
|
|
283
|
+
program = createProgram.call(ts2, {
|
|
284
|
+
rootNames,
|
|
285
|
+
projectReferences,
|
|
286
|
+
options: _object_spread({
|
|
287
|
+
rootDir: appDirectory,
|
|
288
|
+
outDir: distDir
|
|
289
|
+
}, options)
|
|
290
|
+
});
|
|
291
|
+
tsconfigPathsPlugin = tsconfigPathsBeforeHookFactory(ts2, absoluteBaseUrl, paths);
|
|
292
|
+
emitResult = program.emit(void 0, void 0, void 0, void 0, {
|
|
293
|
+
before: [
|
|
294
|
+
tsconfigPathsPlugin
|
|
295
|
+
]
|
|
296
|
+
});
|
|
297
|
+
allDiagnostics = ts2.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
|
|
298
|
+
noEmitOnError = options.noEmitOnError;
|
|
299
|
+
if (allDiagnostics.length > 0) {
|
|
300
|
+
logger.error(ts2.formatDiagnosticsWithColorAndContext(_to_consumable_array(new Set(allDiagnostics)), formatHost));
|
|
301
|
+
if (typeof noEmitOnError === "undefined" || noEmitOnError === true) {
|
|
302
|
+
process.exit(1);
|
|
349
303
|
}
|
|
350
|
-
|
|
304
|
+
}
|
|
305
|
+
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
306
|
+
_state.label = 1;
|
|
307
|
+
case 1:
|
|
308
|
+
_state.trys.push([
|
|
309
|
+
1,
|
|
310
|
+
6,
|
|
311
|
+
7,
|
|
312
|
+
8
|
|
313
|
+
]);
|
|
314
|
+
_iterator = sourceDirs[Symbol.iterator]();
|
|
315
|
+
_state.label = 2;
|
|
316
|
+
case 2:
|
|
317
|
+
if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done))
|
|
318
|
+
return [
|
|
319
|
+
3,
|
|
320
|
+
5
|
|
321
|
+
];
|
|
322
|
+
source = _step.value;
|
|
323
|
+
return [
|
|
324
|
+
4,
|
|
325
|
+
copyFiles(source, distDir, appDirectory, tsconfigPath)
|
|
326
|
+
];
|
|
327
|
+
case 3:
|
|
328
|
+
_state.sent();
|
|
329
|
+
_state.label = 4;
|
|
330
|
+
case 4:
|
|
331
|
+
_iteratorNormalCompletion = true;
|
|
332
|
+
return [
|
|
333
|
+
3,
|
|
334
|
+
2
|
|
335
|
+
];
|
|
336
|
+
case 5:
|
|
337
|
+
return [
|
|
338
|
+
3,
|
|
339
|
+
8
|
|
340
|
+
];
|
|
341
|
+
case 6:
|
|
342
|
+
err = _state.sent();
|
|
343
|
+
_didIteratorError = true;
|
|
344
|
+
_iteratorError = err;
|
|
345
|
+
return [
|
|
346
|
+
3,
|
|
347
|
+
8
|
|
348
|
+
];
|
|
349
|
+
case 7:
|
|
350
|
+
try {
|
|
351
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
352
|
+
_iterator.return();
|
|
353
|
+
}
|
|
354
|
+
} finally {
|
|
355
|
+
if (_didIteratorError) {
|
|
356
|
+
throw _iteratorError;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
return [
|
|
360
|
+
7
|
|
361
|
+
];
|
|
362
|
+
case 8:
|
|
363
|
+
logger.info("Ts compile succeed");
|
|
364
|
+
return [
|
|
365
|
+
2
|
|
366
|
+
];
|
|
367
|
+
}
|
|
351
368
|
});
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
369
|
+
});
|
|
370
|
+
return function compileByTs2(appDirectory, config, compileOptions) {
|
|
371
|
+
return _ref.apply(this, arguments);
|
|
372
|
+
};
|
|
355
373
|
}();
|
|
356
374
|
var getFormatHost = function(ts2) {
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
375
|
+
return {
|
|
376
|
+
getCanonicalFileName: function(path2) {
|
|
377
|
+
return path2;
|
|
378
|
+
},
|
|
379
|
+
getCurrentDirectory: ts2.sys.getCurrentDirectory,
|
|
380
|
+
getNewLine: function() {
|
|
381
|
+
return ts2.sys.newLine;
|
|
382
|
+
}
|
|
383
|
+
};
|
|
366
384
|
};
|
|
367
|
-
export { compileByTs };
|