@rushstack/heft-typescript-plugin 0.1.0-rc.4 → 0.1.0-rc.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/TypeScriptBuilder.d.ts +2 -3
- package/lib/TypeScriptBuilder.d.ts.map +1 -1
- package/lib/TypeScriptBuilder.js +136 -96
- package/lib/TypeScriptBuilder.js.map +1 -1
- package/lib/internalTypings/TypeScriptInternals.d.ts +0 -47
- package/lib/internalTypings/TypeScriptInternals.d.ts.map +1 -1
- package/lib/internalTypings/TypeScriptInternals.js.map +1 -1
- package/package.json +11 -11
- package/lib/EmitFilesPatch.d.ts +0 -28
- package/lib/EmitFilesPatch.d.ts.map +0 -1
- package/lib/EmitFilesPatch.js +0 -99
- package/lib/EmitFilesPatch.js.map +0 -1
package/dist/tsdoc-metadata.json
CHANGED
|
@@ -61,13 +61,14 @@ export declare class TypeScriptBuilder {
|
|
|
61
61
|
private _capabilities;
|
|
62
62
|
private _useSolutionBuilder;
|
|
63
63
|
private _moduleKindsToEmit;
|
|
64
|
+
private readonly _suppressedDiagnosticCodes;
|
|
64
65
|
private __tsCacheFilePath;
|
|
65
|
-
private _tsReadJsonCache;
|
|
66
66
|
private _cachedFileSystem;
|
|
67
67
|
private _tool;
|
|
68
68
|
private get _tsCacheFilePath();
|
|
69
69
|
constructor(configuration: ITypeScriptBuilderConfiguration);
|
|
70
70
|
invokeAsync(onChangeDetected?: () => void): Promise<void>;
|
|
71
|
+
private _configureProgramForMultiEmit;
|
|
71
72
|
_runWatch(tool: ITypeScriptTool): void;
|
|
72
73
|
_runBuildAsync(tool: ITypeScriptTool): Promise<void>;
|
|
73
74
|
_runSolutionBuild(tool: ITypeScriptTool): void;
|
|
@@ -76,7 +77,6 @@ export declare class TypeScriptBuilder {
|
|
|
76
77
|
private _logReadPerformance;
|
|
77
78
|
private _printDiagnosticMessage;
|
|
78
79
|
private _getAdjustedDiagnosticCategory;
|
|
79
|
-
private _emit;
|
|
80
80
|
private _validateTsconfig;
|
|
81
81
|
private _addModuleKindToEmit;
|
|
82
82
|
private _loadTsconfig;
|
|
@@ -86,7 +86,6 @@ export declare class TypeScriptBuilder {
|
|
|
86
86
|
private _buildWatchCompilerHost;
|
|
87
87
|
private _changeCompilerHostToUseCache;
|
|
88
88
|
private _buildWatchSolutionBuilderHost;
|
|
89
|
-
private _overrideTypeScriptReadJson;
|
|
90
89
|
private _parseModuleKind;
|
|
91
90
|
}
|
|
92
91
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeScriptBuilder.d.ts","sourceRoot":"","sources":["../src/TypeScriptBuilder.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,KAAK,WAAW,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"TypeScriptBuilder.d.ts","sourceRoot":"","sources":["../src/TypeScriptBuilder.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,KAAK,WAAW,MAAM,YAAY,CAAC;AAU/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,KAAK,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AAE1G,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,KAAK,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAoBnF,MAAM,WAAW,+BAAgC,SAAQ,4BAA4B;IACnF;;OAEG;IACH,eAAe,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,uBAAuB,EAAE,MAAM,CAAC;IAEhC;;OAEG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAI3B;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACH,YAAY,EAAE,aAAa,CAAC;IAE5B;;OAEG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B;IAC9C,OAAO,CAAC,mBAAmB,CAAW;IAEtC,OAAO,CAAC,kBAAkB,CAA2B;IACrD,OAAO,CAAC,QAAQ,CAAC,0BAA0B,CAA0B;IAErE,OAAO,CAAC,iBAAiB,CAAqB;IAC9C,OAAO,CAAC,iBAAiB,CAAgE;IAEzF,OAAO,CAAC,KAAK,CAA0C;IAEvD,OAAO,KAAK,gBAAgB,GAuB3B;gBAEkB,aAAa,EAAE,+BAA+B;IAMpD,WAAW,CAAC,gBAAgB,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IA6KtE,OAAO,CAAC,6BAA6B;IAmI9B,SAAS,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI;IA0ChC,cAAc,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAiH1D,iBAAiB,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI;IAyCrD,OAAO,CAAC,eAAe;IAkBvB,OAAO,CAAC,mBAAmB;IAgB3B,OAAO,CAAC,mBAAmB;IAc3B,OAAO,CAAC,uBAAuB;IA0C/B,OAAO,CAAC,8BAA8B;IAuBtC,OAAO,CAAC,iBAAiB;IAyHzB,OAAO,CAAC,oBAAoB;IA8D5B,OAAO,CAAC,aAAa;IA6CrB,OAAO,CAAC,wBAAwB;IAoFhC,OAAO,CAAC,yBAAyB;IA+BjC,OAAO,CAAC,6BAA6B;IAmBrC,OAAO,CAAC,uBAAuB;IA0B/B,OAAO,CAAC,6BAA6B;IA2CrC,OAAO,CAAC,8BAA8B;IAiBtC,OAAO,CAAC,gBAAgB;CAwBzB"}
|
package/lib/TypeScriptBuilder.js
CHANGED
|
@@ -30,17 +30,17 @@ const crypto = __importStar(require("crypto"));
|
|
|
30
30
|
const path = __importStar(require("path"));
|
|
31
31
|
const semver = __importStar(require("semver"));
|
|
32
32
|
const node_core_library_1 = require("@rushstack/node-core-library");
|
|
33
|
-
const EmitFilesPatch_1 = require("./EmitFilesPatch");
|
|
34
33
|
const TypeScriptCachedFileSystem_1 = require("./fileSystem/TypeScriptCachedFileSystem");
|
|
35
|
-
const EMPTY_JSON = {};
|
|
36
34
|
const OLDEST_SUPPORTED_TS_MAJOR_VERSION = 2;
|
|
37
35
|
const OLDEST_SUPPORTED_TS_MINOR_VERSION = 9;
|
|
38
|
-
const NEWEST_SUPPORTED_TS_MAJOR_VERSION =
|
|
39
|
-
const NEWEST_SUPPORTED_TS_MINOR_VERSION =
|
|
36
|
+
const NEWEST_SUPPORTED_TS_MAJOR_VERSION = 5;
|
|
37
|
+
const NEWEST_SUPPORTED_TS_MINOR_VERSION = 0;
|
|
38
|
+
// symbols for attaching hidden metadata to ts.Program instances.
|
|
39
|
+
const INNER_GET_COMPILER_OPTIONS_SYMBOL = Symbol('getCompilerOptions');
|
|
40
|
+
const INNER_EMIT_SYMBOL = Symbol('emit');
|
|
40
41
|
class TypeScriptBuilder {
|
|
41
42
|
constructor(configuration) {
|
|
42
|
-
this.
|
|
43
|
-
this._tsReadJsonCache = new Map();
|
|
43
|
+
this._suppressedDiagnosticCodes = new Set();
|
|
44
44
|
this._cachedFileSystem = new TypeScriptCachedFileSystem_1.TypeScriptCachedFileSystem();
|
|
45
45
|
this._tool = undefined;
|
|
46
46
|
this._configuration = configuration;
|
|
@@ -67,6 +67,7 @@ class TypeScriptBuilder {
|
|
|
67
67
|
return this.__tsCacheFilePath;
|
|
68
68
|
}
|
|
69
69
|
async invokeAsync(onChangeDetected) {
|
|
70
|
+
var _a, _b;
|
|
70
71
|
if (!this._tool) {
|
|
71
72
|
// Determine the compiler version
|
|
72
73
|
const compilerPackageJsonFilename = path.join(this._configuration.typeScriptToolPath, 'package.json');
|
|
@@ -111,6 +112,18 @@ class TypeScriptBuilder {
|
|
|
111
112
|
`(${NEWEST_SUPPORTED_TS_MAJOR_VERSION}.${NEWEST_SUPPORTED_TS_MINOR_VERSION}); it may not work correctly.`);
|
|
112
113
|
}
|
|
113
114
|
const ts = require(this._configuration.typeScriptToolPath);
|
|
115
|
+
ts.performance.enable();
|
|
116
|
+
const suppressedCodes = [
|
|
117
|
+
(_a = ts.Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor) === null || _a === void 0 ? void 0 : _a.code,
|
|
118
|
+
// This diagnostic code is not present in old versions of TypeScript
|
|
119
|
+
(_b = ts.Diagnostics
|
|
120
|
+
.Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1) === null || _b === void 0 ? void 0 : _b.code
|
|
121
|
+
];
|
|
122
|
+
for (const code of suppressedCodes) {
|
|
123
|
+
if (code !== undefined) {
|
|
124
|
+
this._suppressedDiagnosticCodes.add(code);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
114
127
|
const measureTsPerformance = (measurementName, fn) => {
|
|
115
128
|
const beforeName = `before${measurementName}`;
|
|
116
129
|
ts.performance.mark(beforeName);
|
|
@@ -175,6 +188,77 @@ class TypeScriptBuilder {
|
|
|
175
188
|
await this._runBuildAsync(this._tool);
|
|
176
189
|
}
|
|
177
190
|
}
|
|
191
|
+
_configureProgramForMultiEmit(innerProgram, ts) {
|
|
192
|
+
const program = innerProgram;
|
|
193
|
+
// Check to see if this Program has already been modified.
|
|
194
|
+
let { [INNER_EMIT_SYMBOL]: innerEmit, [INNER_GET_COMPILER_OPTIONS_SYMBOL]: innerGetCompilerOptions } = program;
|
|
195
|
+
if (!innerGetCompilerOptions) {
|
|
196
|
+
program[INNER_GET_COMPILER_OPTIONS_SYMBOL] = innerGetCompilerOptions = program.getCompilerOptions;
|
|
197
|
+
}
|
|
198
|
+
if (!innerEmit) {
|
|
199
|
+
program[INNER_EMIT_SYMBOL] = innerEmit = program.emit;
|
|
200
|
+
}
|
|
201
|
+
let foundPrimary = false;
|
|
202
|
+
let defaultModuleKind;
|
|
203
|
+
const multiEmitMap = new Map();
|
|
204
|
+
for (const moduleKindToEmit of this._moduleKindsToEmit) {
|
|
205
|
+
const kindCompilerOptions = moduleKindToEmit.isPrimary
|
|
206
|
+
? Object.assign({}, innerGetCompilerOptions()) : Object.assign(Object.assign({}, innerGetCompilerOptions()), { module: moduleKindToEmit.moduleKind, outDir: moduleKindToEmit.outFolderPath,
|
|
207
|
+
// Don't emit declarations for secondary module kinds
|
|
208
|
+
declaration: false, declarationMap: false });
|
|
209
|
+
if (!kindCompilerOptions.outDir) {
|
|
210
|
+
throw new node_core_library_1.InternalError('Expected compilerOptions.outDir to be assigned');
|
|
211
|
+
}
|
|
212
|
+
multiEmitMap.set(moduleKindToEmit, kindCompilerOptions);
|
|
213
|
+
if (moduleKindToEmit.isPrimary) {
|
|
214
|
+
if (foundPrimary) {
|
|
215
|
+
throw new Error('Multiple primary module emit kinds encountered.');
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
foundPrimary = true;
|
|
219
|
+
}
|
|
220
|
+
defaultModuleKind = moduleKindToEmit.moduleKind;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
const changedFiles = new Set();
|
|
224
|
+
program.emit = (targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) => {
|
|
225
|
+
if (emitOnlyDtsFiles) {
|
|
226
|
+
return program[INNER_EMIT_SYMBOL](targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers);
|
|
227
|
+
}
|
|
228
|
+
if (targetSourceFile && changedFiles) {
|
|
229
|
+
changedFiles.add(targetSourceFile);
|
|
230
|
+
}
|
|
231
|
+
const originalCompilerOptions = program[INNER_GET_COMPILER_OPTIONS_SYMBOL]();
|
|
232
|
+
let defaultModuleKindResult;
|
|
233
|
+
const diagnostics = [];
|
|
234
|
+
let emitSkipped = false;
|
|
235
|
+
try {
|
|
236
|
+
for (const [moduleKindToEmit, kindCompilerOptions] of multiEmitMap) {
|
|
237
|
+
program.getCompilerOptions = () => kindCompilerOptions;
|
|
238
|
+
// Need to mutate the compiler options for the `module` field specifically, because emitWorker() captures
|
|
239
|
+
// options in the closure and passes it to `ts.getTransformers()`
|
|
240
|
+
originalCompilerOptions.module = moduleKindToEmit.moduleKind;
|
|
241
|
+
const flavorResult = program[INNER_EMIT_SYMBOL](targetSourceFile, writeFile && wrapWriteFile(writeFile, moduleKindToEmit.jsExtensionOverride), cancellationToken, emitOnlyDtsFiles, customTransformers);
|
|
242
|
+
emitSkipped = emitSkipped || flavorResult.emitSkipped;
|
|
243
|
+
// Need to aggregate diagnostics because some are impacted by the target module type
|
|
244
|
+
for (const diagnostic of flavorResult.diagnostics) {
|
|
245
|
+
diagnostics.push(diagnostic);
|
|
246
|
+
}
|
|
247
|
+
if (moduleKindToEmit.moduleKind === defaultModuleKind) {
|
|
248
|
+
defaultModuleKindResult = flavorResult;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
const mergedDiagnostics = ts.sortAndDeduplicateDiagnostics(diagnostics);
|
|
252
|
+
return Object.assign(Object.assign({}, defaultModuleKindResult), { changedSourceFiles: changedFiles, diagnostics: mergedDiagnostics, emitSkipped });
|
|
253
|
+
}
|
|
254
|
+
finally {
|
|
255
|
+
// Restore the original compiler options and module kind for future calls
|
|
256
|
+
program.getCompilerOptions = program[INNER_GET_COMPILER_OPTIONS_SYMBOL];
|
|
257
|
+
originalCompilerOptions.module = defaultModuleKind;
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
return { changedFiles };
|
|
261
|
+
}
|
|
178
262
|
_runWatch(tool) {
|
|
179
263
|
const { ts, measureSync: measureTsPerformance, pendingOperations, rawDiagnostics } = tool;
|
|
180
264
|
if (!tool.solutionBuilder && !tool.watchProgram) {
|
|
@@ -214,7 +298,6 @@ class TypeScriptBuilder {
|
|
|
214
298
|
const { ts, measureSync: measureTsPerformance, measureAsync: measureTsPerformanceAsync } = tool;
|
|
215
299
|
//#region CONFIGURE
|
|
216
300
|
const { duration: configureDurationMs, tsconfig, compilerHost } = measureTsPerformance('Configure', () => {
|
|
217
|
-
this._overrideTypeScriptReadJson(ts);
|
|
218
301
|
const _tsconfig = this._loadTsconfig(ts);
|
|
219
302
|
this._validateTsconfig(ts, _tsconfig);
|
|
220
303
|
const _compilerHost = this._buildIncrementalCompilerHost(tool, _tsconfig);
|
|
@@ -228,13 +311,13 @@ class TypeScriptBuilder {
|
|
|
228
311
|
//#region PROGRAM
|
|
229
312
|
// There will be only one program here; emit will get a bit abused if we produce multiple outputs
|
|
230
313
|
let builderProgram = undefined;
|
|
231
|
-
let
|
|
314
|
+
let innerProgram;
|
|
232
315
|
if (tsconfig.options.incremental) {
|
|
233
|
-
builderProgram =
|
|
234
|
-
|
|
316
|
+
builderProgram = this._getCreateBuilderProgram(ts)(tsconfig.fileNames, tsconfig.options, compilerHost, ts.readBuilderProgram(tsconfig.options, compilerHost), ts.getConfigFileParsingDiagnostics(tsconfig), tsconfig.projectReferences);
|
|
317
|
+
innerProgram = builderProgram.getProgram();
|
|
235
318
|
}
|
|
236
319
|
else {
|
|
237
|
-
|
|
320
|
+
innerProgram = ts.createProgram({
|
|
238
321
|
rootNames: tsconfig.fileNames,
|
|
239
322
|
options: tsconfig.options,
|
|
240
323
|
projectReferences: tsconfig.projectReferences,
|
|
@@ -244,7 +327,7 @@ class TypeScriptBuilder {
|
|
|
244
327
|
});
|
|
245
328
|
}
|
|
246
329
|
// Prefer the builder program, since it is what gives us incremental builds
|
|
247
|
-
const genericProgram = builderProgram ||
|
|
330
|
+
const genericProgram = builderProgram || innerProgram;
|
|
248
331
|
this._logReadPerformance(ts);
|
|
249
332
|
//#endregion
|
|
250
333
|
//#region ANALYSIS
|
|
@@ -261,7 +344,12 @@ class TypeScriptBuilder {
|
|
|
261
344
|
this._typescriptTerminal.writeVerboseLine(`Analyze: ${diagnosticsDurationMs}ms`);
|
|
262
345
|
//#endregion
|
|
263
346
|
//#region EMIT
|
|
264
|
-
const
|
|
347
|
+
const filesToWrite = [];
|
|
348
|
+
const writeFileCallback = (filePath, data) => {
|
|
349
|
+
filesToWrite.push({ filePath, data });
|
|
350
|
+
};
|
|
351
|
+
const { changedFiles } = this._configureProgramForMultiEmit(innerProgram, ts);
|
|
352
|
+
const emitResult = genericProgram.emit(undefined, writeFileCallback);
|
|
265
353
|
//#endregion
|
|
266
354
|
this._logEmitPerformance(ts);
|
|
267
355
|
//#region FINAL_ANALYSIS
|
|
@@ -271,15 +359,15 @@ class TypeScriptBuilder {
|
|
|
271
359
|
//#region WRITE
|
|
272
360
|
// Using async file system I/O for theoretically better peak performance
|
|
273
361
|
// Also allows to run concurrently with linting
|
|
274
|
-
const writePromise = measureTsPerformanceAsync('Write', () => node_core_library_1.Async.forEachAsync(
|
|
362
|
+
const writePromise = measureTsPerformanceAsync('Write', () => node_core_library_1.Async.forEachAsync(filesToWrite, async ({ filePath, data }) => this._cachedFileSystem.writeFile(filePath, data, { ensureFolderExists: true }), { concurrency: this._configuration.maxWriteParallelism }));
|
|
275
363
|
//#endregion
|
|
276
364
|
const { duration: writeDuration } = await writePromise;
|
|
277
|
-
this._typescriptTerminal.writeVerboseLine(`I/O Write: ${writeDuration}ms (${
|
|
365
|
+
this._typescriptTerminal.writeVerboseLine(`I/O Write: ${writeDuration}ms (${filesToWrite.length} files)`);
|
|
278
366
|
this._logDiagnostics(ts, rawDiagnostics);
|
|
279
367
|
// Reset performance counters in case any are used in the callback
|
|
280
368
|
ts.performance.disable();
|
|
281
369
|
ts.performance.enable();
|
|
282
|
-
this._configuration.emitChangedFilesCallback(
|
|
370
|
+
this._configuration.emitChangedFilesCallback(innerProgram, changedFiles);
|
|
283
371
|
}
|
|
284
372
|
_runSolutionBuild(tool) {
|
|
285
373
|
this._typescriptTerminal.writeVerboseLine(`Using solution mode`);
|
|
@@ -382,31 +470,11 @@ class TypeScriptBuilder {
|
|
|
382
470
|
return ts.DiagnosticCategory.Warning;
|
|
383
471
|
}
|
|
384
472
|
// These pedantic checks also should not be treated as hard errors
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
.code:
|
|
388
|
-
case ts.Diagnostics
|
|
389
|
-
.Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1.code:
|
|
390
|
-
return ts.DiagnosticCategory.Warning;
|
|
473
|
+
if (this._suppressedDiagnosticCodes.has(diagnostic.code)) {
|
|
474
|
+
return ts.DiagnosticCategory.Warning;
|
|
391
475
|
}
|
|
392
476
|
return diagnostic.category;
|
|
393
477
|
}
|
|
394
|
-
_emit(ts, genericProgram) {
|
|
395
|
-
const filesToWrite = [];
|
|
396
|
-
const changedFiles = new Set();
|
|
397
|
-
EmitFilesPatch_1.EmitFilesPatch.install(ts, genericProgram.getCompilerOptions(), this._moduleKindsToEmit, changedFiles);
|
|
398
|
-
const writeFileCallback = (filePath, data) => {
|
|
399
|
-
filesToWrite.push({ filePath, data });
|
|
400
|
-
};
|
|
401
|
-
try {
|
|
402
|
-
const result = genericProgram.emit(undefined, // Target source file
|
|
403
|
-
writeFileCallback);
|
|
404
|
-
return Object.assign(Object.assign({}, result), { changedSourceFiles: changedFiles, filesToWrite });
|
|
405
|
-
}
|
|
406
|
-
finally {
|
|
407
|
-
EmitFilesPatch_1.EmitFilesPatch.uninstall(ts);
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
478
|
_validateTsconfig(ts, tsconfig) {
|
|
411
479
|
if ((tsconfig.options.module && !tsconfig.options.outDir) ||
|
|
412
480
|
(!tsconfig.options.module && tsconfig.options.outDir)) {
|
|
@@ -552,10 +620,9 @@ class TypeScriptBuilder {
|
|
|
552
620
|
}
|
|
553
621
|
return tsconfig;
|
|
554
622
|
}
|
|
555
|
-
_getCreateBuilderProgram(
|
|
556
|
-
const {
|
|
557
|
-
const
|
|
558
|
-
const createMultiEmitProgram = (fileNames, compilerOptions, host, oldProgram, configFileParsingDiagnostics, projectReferences) => {
|
|
623
|
+
_getCreateBuilderProgram(ts) {
|
|
624
|
+
const { _configuration: { emitChangedFilesCallback } } = this;
|
|
625
|
+
const createMultiEmitBuilderProgram = (fileNames, compilerOptions, host, oldProgram, configFileParsingDiagnostics, projectReferences) => {
|
|
559
626
|
// Reset performance counters
|
|
560
627
|
ts.performance.disable();
|
|
561
628
|
ts.performance.enable();
|
|
@@ -563,30 +630,24 @@ class TypeScriptBuilder {
|
|
|
563
630
|
const newProgram = ts.createEmitAndSemanticDiagnosticsBuilderProgram(fileNames, compilerOptions, host, oldProgram, configFileParsingDiagnostics, projectReferences);
|
|
564
631
|
this._logReadPerformance(ts);
|
|
565
632
|
const { emit: originalEmit } = newProgram;
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
const
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
emitChangedFilesCallback(newProgram.getProgram(), changedFiles);
|
|
580
|
-
return result;
|
|
581
|
-
}
|
|
582
|
-
finally {
|
|
583
|
-
EmitFilesPatch_1.EmitFilesPatch.uninstall(ts);
|
|
584
|
-
}
|
|
633
|
+
const emit = (outerTargetSourceFile, outerWriteFile, outerCancellationToken, outerEmitOnlyDtsFiles, outerCustomTransformers) => {
|
|
634
|
+
const innerProgram = newProgram.getProgram();
|
|
635
|
+
const innerCompilerOptions = innerProgram.getCompilerOptions();
|
|
636
|
+
const { changedFiles } = this._configureProgramForMultiEmit(innerProgram, ts);
|
|
637
|
+
const result = originalEmit.call(newProgram, outerTargetSourceFile, outerWriteFile, outerCancellationToken, outerEmitOnlyDtsFiles, outerCustomTransformers);
|
|
638
|
+
result.changedSourceFiles = changedFiles;
|
|
639
|
+
this._typescriptTerminal.writeVerboseLine(`Emitting program "${innerCompilerOptions.configFilePath}"`);
|
|
640
|
+
this._logEmitPerformance(ts);
|
|
641
|
+
// Reset performance counters
|
|
642
|
+
ts.performance.disable();
|
|
643
|
+
ts.performance.enable();
|
|
644
|
+
emitChangedFilesCallback(innerProgram, changedFiles);
|
|
645
|
+
return result;
|
|
585
646
|
};
|
|
586
647
|
newProgram.emit = emit;
|
|
587
648
|
return newProgram;
|
|
588
649
|
};
|
|
589
|
-
return
|
|
650
|
+
return createMultiEmitBuilderProgram;
|
|
590
651
|
}
|
|
591
652
|
_buildSolutionBuilderHost(tool) {
|
|
592
653
|
const reportSolutionBuilderStatus = tool.reportDiagnostic;
|
|
@@ -594,7 +655,7 @@ class TypeScriptBuilder {
|
|
|
594
655
|
// Do nothing
|
|
595
656
|
};
|
|
596
657
|
const { ts } = tool;
|
|
597
|
-
const solutionBuilderHost = ts.createSolutionBuilderHost(ts.sys, this._getCreateBuilderProgram(
|
|
658
|
+
const solutionBuilderHost = ts.createSolutionBuilderHost(ts.sys, this._getCreateBuilderProgram(ts), tool.reportDiagnostic, reportSolutionBuilderStatus, reportEmitErrorSummary);
|
|
598
659
|
solutionBuilderHost.afterProgramEmitAndDiagnostics = (program) => {
|
|
599
660
|
// Use the native metric since we aren't overwriting the writer
|
|
600
661
|
this._typescriptTerminal.writeVerboseLine(`I/O Write: ${ts.performance.getDuration('I/O Write')}ms (${ts.performance.getCount('beforeIOWrite')} files)`);
|
|
@@ -618,7 +679,7 @@ class TypeScriptBuilder {
|
|
|
618
679
|
const reportWatchStatus = (diagnostic) => {
|
|
619
680
|
this._printDiagnosticMessage(ts, diagnostic);
|
|
620
681
|
};
|
|
621
|
-
const compilerHost = ts.createWatchCompilerHost(tsconfig.fileNames, tsconfig.options, ts.sys, this._getCreateBuilderProgram(
|
|
682
|
+
const compilerHost = ts.createWatchCompilerHost(tsconfig.fileNames, tsconfig.options, ts.sys, this._getCreateBuilderProgram(ts), tool.reportDiagnostic, reportWatchStatus, tsconfig.projectReferences);
|
|
622
683
|
compilerHost.clearTimeout = tool.clearTimeout;
|
|
623
684
|
compilerHost.setTimeout = tool.setTimeout;
|
|
624
685
|
return compilerHost;
|
|
@@ -651,42 +712,11 @@ class TypeScriptBuilder {
|
|
|
651
712
|
}
|
|
652
713
|
_buildWatchSolutionBuilderHost(tool) {
|
|
653
714
|
const { reportDiagnostic, ts } = tool;
|
|
654
|
-
const host = ts.createSolutionBuilderWithWatchHost(ts.sys, this._getCreateBuilderProgram(
|
|
715
|
+
const host = ts.createSolutionBuilderWithWatchHost(ts.sys, this._getCreateBuilderProgram(ts), reportDiagnostic, reportDiagnostic, reportDiagnostic);
|
|
655
716
|
host.clearTimeout = tool.clearTimeout;
|
|
656
717
|
host.setTimeout = tool.setTimeout;
|
|
657
718
|
return host;
|
|
658
719
|
}
|
|
659
|
-
_overrideTypeScriptReadJson(ts) {
|
|
660
|
-
const cachedReadJson = (filePath) => {
|
|
661
|
-
let jsonData = this._tsReadJsonCache.get(filePath);
|
|
662
|
-
if (jsonData) {
|
|
663
|
-
return jsonData;
|
|
664
|
-
}
|
|
665
|
-
else {
|
|
666
|
-
try {
|
|
667
|
-
const fileContents = this._cachedFileSystem.readFile(filePath);
|
|
668
|
-
if (!fileContents) {
|
|
669
|
-
jsonData = EMPTY_JSON;
|
|
670
|
-
}
|
|
671
|
-
else {
|
|
672
|
-
const parsedFile = ts.parseConfigFileTextToJson(filePath, fileContents);
|
|
673
|
-
if (parsedFile.error) {
|
|
674
|
-
jsonData = EMPTY_JSON;
|
|
675
|
-
}
|
|
676
|
-
else {
|
|
677
|
-
jsonData = parsedFile.config;
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
catch (error) {
|
|
682
|
-
jsonData = EMPTY_JSON;
|
|
683
|
-
}
|
|
684
|
-
this._tsReadJsonCache.set(filePath, jsonData);
|
|
685
|
-
return jsonData;
|
|
686
|
-
}
|
|
687
|
-
};
|
|
688
|
-
ts.readJson = cachedReadJson;
|
|
689
|
-
}
|
|
690
720
|
_parseModuleKind(ts, moduleKindName) {
|
|
691
721
|
switch (moduleKindName.toLowerCase()) {
|
|
692
722
|
case 'commonjs':
|
|
@@ -707,4 +737,14 @@ class TypeScriptBuilder {
|
|
|
707
737
|
}
|
|
708
738
|
}
|
|
709
739
|
exports.TypeScriptBuilder = TypeScriptBuilder;
|
|
740
|
+
const JS_EXTENSION_REGEX = /\.js(\.map)?$/;
|
|
741
|
+
function wrapWriteFile(baseWriteFile, jsExtensionOverride) {
|
|
742
|
+
if (!jsExtensionOverride) {
|
|
743
|
+
return baseWriteFile;
|
|
744
|
+
}
|
|
745
|
+
const replacementExtension = `${jsExtensionOverride}$1`;
|
|
746
|
+
return (fileName, data, writeBOM, onError, sourceFiles) => {
|
|
747
|
+
return baseWriteFile(fileName.replace(JS_EXTENSION_REGEX, replacementExtension), data, writeBOM, onError, sourceFiles);
|
|
748
|
+
};
|
|
749
|
+
}
|
|
710
750
|
//# sourceMappingURL=TypeScriptBuilder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeScriptBuilder.js","sourceRoot":"","sources":["../src/TypeScriptBuilder.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,+CAAiC;AACjC,2CAA6B;AAC7B,+CAAiC;AAEjC,oEAA8G;AAI9G,qDAA8E;AAC9E,wFAAqF;AAuDrF,MAAM,UAAU,GAAW,EAAE,CAAC;AAqC9B,MAAM,iCAAiC,GAAW,CAAC,CAAC;AACpD,MAAM,iCAAiC,GAAW,CAAC,CAAC;AAEpD,MAAM,iCAAiC,GAAW,CAAC,CAAC;AACpD,MAAM,iCAAiC,GAAW,CAAC,CAAC;AAuBpD,MAAa,iBAAiB;IA4C5B,YAAmB,aAA8C;QA/BzD,sBAAiB,GAAuB,SAAS,CAAC;QAClD,qBAAgB,GAAwB,IAAI,GAAG,EAAkB,CAAC;QAClE,sBAAiB,GAA+B,IAAI,uDAA0B,EAAE,CAAC;QAEjF,UAAK,GAAgC,SAAS,CAAC;QA4BrD,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;QACpC,IAAI,CAAC,iBAAiB,GAAG,aAAa,CAAC,YAAY,CAAC;QACpD,IAAI,CAAC,mBAAmB,GAAG,aAAa,CAAC,YAAY,CAAC,QAAQ,CAAC;IACjE,CAAC;IA7BD,IAAY,gBAAgB;QAC1B,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AAQ,cAAc,CAAC,WAAW,EAAE,EAAE;YACpC,KAAK,UAAU;gBACb,OAAO,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC;YAEhC,KAAK,KAAK;gBACR,OAAO,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC;YAE3B,KAAK,KAAK;gBACR,OAAO,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC;YAE3B,KAAK,QAAQ;gBACX,OAAO,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC;YAE9B,KAAK,QAAQ;gBACX,OAAO,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC;YAE9B,KAAK,QAAQ;gBACX,OAAO,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC;YAE9B;gBACE,MAAM,IAAI,KAAK,CAAC,IAAI,cAAc,oCAAoC,CAAC,CAAC;SAC3E;IACH,CAAC;CACF;AA9hCD,8CA8hCC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as crypto from 'crypto';\nimport * as path from 'path';\nimport * as semver from 'semver';\nimport type * as TTypescript from 'typescript';\nimport { type ITerminal, JsonFile, IPackageJson, Path, Async, FileError } from '@rushstack/node-core-library';\nimport type { IScopedLogger } from '@rushstack/heft';\n\nimport type { ExtendedTypeScript, IExtendedSolutionBuilder } from './internalTypings/TypeScriptInternals';\nimport { EmitFilesPatch, type ICachedEmitModuleKind } from './EmitFilesPatch';\nimport { TypeScriptCachedFileSystem } from './fileSystem/TypeScriptCachedFileSystem';\nimport type { ITypeScriptConfigurationJson } from './TypeScriptPlugin';\nimport type { PerformanceMeasurer, PerformanceMeasurerAsync } from './Performance';\n\nexport interface ITypeScriptBuilderConfiguration extends ITypeScriptConfigurationJson {\n /**\n * The root folder of the build.\n */\n buildFolderPath: string;\n\n /**\n * The folder to write build metadata.\n */\n buildMetadataFolderPath: string;\n\n /**\n * The path to the TypeScript tool.\n */\n typeScriptToolPath: string;\n\n // watchMode: boolean;\n\n /**\n * The path to the tsconfig file being built.\n */\n tsconfigPath: string;\n\n /**\n * Set this to change the maximum number of file handles that will be opened concurrently for writing.\n * The default is 50.\n */\n maxWriteParallelism: number;\n\n /**\n * The scoped logger that the builder will log to.\n */\n scopedLogger: IScopedLogger;\n\n /**\n * The callback used to emit the typescript program (or programs) from the builder.\n */\n emitChangedFilesCallback: (\n program: TTypescript.Program,\n changedFiles?: Set<TTypescript.SourceFile>\n ) => void;\n}\n\ntype TSolutionHost = TTypescript.SolutionBuilderHost<TTypescript.EmitAndSemanticDiagnosticsBuilderProgram>;\ntype TWatchCompilerHost =\n TTypescript.WatchCompilerHostOfFilesAndCompilerOptions<TTypescript.EmitAndSemanticDiagnosticsBuilderProgram>;\ntype TWatchSolutionHost =\n TTypescript.SolutionBuilderWithWatchHost<TTypescript.EmitAndSemanticDiagnosticsBuilderProgram>;\ntype TWatchProgram =\n TTypescript.WatchOfFilesAndCompilerOptions<TTypescript.EmitAndSemanticDiagnosticsBuilderProgram>;\n\nconst EMPTY_JSON: object = {};\n\ninterface ICompilerCapabilities {\n /**\n * Support for incremental compilation via `ts.createIncrementalProgram()`.\n * Introduced with TypeScript 3.6.\n */\n incrementalProgram: boolean;\n\n /**\n * Support for composite projects via `ts.createSolutionBuilder()`.\n * Introduced with TypeScript 3.0.\n */\n solutionBuilder: boolean;\n}\n\ninterface IFileToWrite {\n filePath: string;\n data: string;\n}\n\ninterface IModuleKindReason {\n kind: keyof typeof TTypescript.ModuleKind;\n outDir: string;\n extension: '.js' | '.cjs' | '.mjs';\n reason: string;\n}\n\ninterface IExtendedEmitResult extends TTypescript.EmitResult {\n changedSourceFiles: Set<TTypescript.SourceFile>;\n filesToWrite: IFileToWrite[];\n}\n\ninterface IPendingWork {\n (): void;\n}\n\nconst OLDEST_SUPPORTED_TS_MAJOR_VERSION: number = 2;\nconst OLDEST_SUPPORTED_TS_MINOR_VERSION: number = 9;\n\nconst NEWEST_SUPPORTED_TS_MAJOR_VERSION: number = 4;\nconst NEWEST_SUPPORTED_TS_MINOR_VERSION: number = 8;\n\ninterface ITypeScriptTool {\n ts: ExtendedTypeScript;\n measureSync: PerformanceMeasurer;\n measureAsync: PerformanceMeasurerAsync;\n\n sourceFileCache: Map<string, TTypescript.SourceFile>;\n\n watchProgram: TWatchProgram | undefined;\n\n solutionBuilder: IExtendedSolutionBuilder | undefined;\n\n rawDiagnostics: TTypescript.Diagnostic[];\n pendingOperations: Set<IPendingWork>;\n\n executing: boolean;\n\n reportDiagnostic: TTypescript.DiagnosticReporter;\n clearTimeout: (timeout: IPendingWork) => void;\n setTimeout: <T extends unknown[]>(timeout: (...args: T) => void, ms: number, ...args: T) => IPendingWork;\n}\n\nexport class TypeScriptBuilder {\n private readonly _configuration: ITypeScriptBuilderConfiguration;\n private readonly _typescriptLogger: IScopedLogger;\n private readonly _typescriptTerminal: ITerminal;\n\n private _typescriptVersion!: string;\n private _typescriptParsedVersion!: semver.SemVer;\n\n private _capabilities!: ICompilerCapabilities;\n private _useSolutionBuilder!: boolean;\n\n private _moduleKindsToEmit!: ICachedEmitModuleKind[];\n\n private __tsCacheFilePath: string | undefined = undefined;\n private _tsReadJsonCache: Map<string, object> = new Map<string, object>();\n private _cachedFileSystem: TypeScriptCachedFileSystem = new TypeScriptCachedFileSystem();\n\n private _tool: ITypeScriptTool | undefined = undefined;\n\n private get _tsCacheFilePath(): string {\n if (!this.__tsCacheFilePath) {\n // TypeScript internally handles if the tsconfig options have changed from when the tsbuildinfo file was created.\n // We only need to hash our additional Heft configuration.\n const configHash: crypto.Hash = crypto.createHash('sha1');\n\n configHash.update(JSON.stringify(this._configuration.additionalModuleKindsToEmit || {}));\n const serializedConfigHash: string = configHash\n .digest('base64')\n .slice(0, 8)\n .replace(/\\+/g, '-')\n .replace(/\\//g, '_');\n\n // This conversion is theoretically redundant, but it is here to make absolutely sure that the path is formatted\n // using only '/' as the directory separator so that incremental builds don't break on Windows.\n // TypeScript will normalize to '/' when serializing, but not on the direct input, and uses exact string equality.\n const normalizedCacheFolderPath: string = Path.convertToSlashes(\n this._configuration.buildMetadataFolderPath\n );\n this.__tsCacheFilePath = `${normalizedCacheFolderPath}/ts_${serializedConfigHash}.json`;\n }\n\n return this.__tsCacheFilePath;\n }\n\n public constructor(configuration: ITypeScriptBuilderConfiguration) {\n this._configuration = configuration;\n this._typescriptLogger = configuration.scopedLogger;\n this._typescriptTerminal = configuration.scopedLogger.terminal;\n }\n\n public async invokeAsync(onChangeDetected?: () => void): Promise<void> {\n if (!this._tool) {\n // Determine the compiler version\n const compilerPackageJsonFilename: string = path.join(\n this._configuration.typeScriptToolPath,\n 'package.json'\n );\n const packageJson: IPackageJson = await JsonFile.loadAsync(compilerPackageJsonFilename);\n this._typescriptVersion = packageJson.version;\n const parsedVersion: semver.SemVer | null = semver.parse(this._typescriptVersion);\n if (!parsedVersion) {\n throw new Error(\n `Unable to parse version \"${this._typescriptVersion}\" for TypeScript compiler package in: ` +\n compilerPackageJsonFilename\n );\n }\n this._typescriptParsedVersion = parsedVersion;\n\n // Detect what features this compiler supports. Note that manually comparing major/minor numbers\n // loosens the matching to accept prereleases such as \"3.6.0-dev.20190530\"\n this._capabilities = {\n incrementalProgram: false,\n solutionBuilder: this._typescriptParsedVersion.major >= 3\n };\n\n if (\n this._typescriptParsedVersion.major > 3 ||\n (this._typescriptParsedVersion.major === 3 && this._typescriptParsedVersion.minor >= 6)\n ) {\n this._capabilities.incrementalProgram = true;\n }\n\n this._useSolutionBuilder = !!this._configuration.buildProjectReferences;\n if (this._useSolutionBuilder && !this._capabilities.solutionBuilder) {\n throw new Error(\n `Building project references requires TypeScript@>=3.0, but the current version is ${this._typescriptVersion}`\n );\n }\n\n // Report a warning if the TypeScript version is too old/new. The current oldest supported version is\n // TypeScript 2.9. Prior to that the \"ts.getConfigFileParsingDiagnostics()\" API is missing; more fixups\n // would be required to deal with that. We won't do that work unless someone requests it.\n if (\n this._typescriptParsedVersion.major < OLDEST_SUPPORTED_TS_MAJOR_VERSION ||\n (this._typescriptParsedVersion.major === OLDEST_SUPPORTED_TS_MAJOR_VERSION &&\n this._typescriptParsedVersion.minor < OLDEST_SUPPORTED_TS_MINOR_VERSION)\n ) {\n // We don't use writeWarningLine() here because, if the person wants to take their chances with\n // a seemingly unsupported compiler, their build should be allowed to succeed.\n this._typescriptTerminal.writeLine(\n `The TypeScript compiler version ${this._typescriptVersion} is very old` +\n ` and has not been tested with Heft; it may not work correctly.`\n );\n } else if (\n this._typescriptParsedVersion.major > NEWEST_SUPPORTED_TS_MAJOR_VERSION ||\n (this._typescriptParsedVersion.major === NEWEST_SUPPORTED_TS_MAJOR_VERSION &&\n this._typescriptParsedVersion.minor > NEWEST_SUPPORTED_TS_MINOR_VERSION)\n ) {\n this._typescriptTerminal.writeLine(\n `The TypeScript compiler version ${this._typescriptVersion} is newer` +\n ' than the latest version that was tested with Heft ' +\n `(${NEWEST_SUPPORTED_TS_MAJOR_VERSION}.${NEWEST_SUPPORTED_TS_MINOR_VERSION}); it may not work correctly.`\n );\n }\n\n const ts: ExtendedTypeScript = require(this._configuration.typeScriptToolPath);\n\n const measureTsPerformance: PerformanceMeasurer = <TResult extends object | void>(\n measurementName: string,\n fn: () => TResult\n ) => {\n const beforeName: string = `before${measurementName}`;\n ts.performance.mark(beforeName);\n const result: TResult = fn();\n const afterName: string = `after${measurementName}`;\n ts.performance.mark(afterName);\n ts.performance.measure(measurementName, beforeName, afterName);\n return {\n ...result,\n duration: ts.performance.getDuration(measurementName),\n count: ts.performance.getCount(beforeName)\n };\n };\n\n const measureTsPerformanceAsync: PerformanceMeasurerAsync = async <TResult extends object | void>(\n measurementName: string,\n fn: () => Promise<TResult>\n ) => {\n const beforeName: string = `before${measurementName}`;\n ts.performance.mark(beforeName);\n const resultPromise: Promise<TResult> = fn();\n const result: TResult = await resultPromise;\n const afterName: string = `after${measurementName}`;\n ts.performance.mark(afterName);\n ts.performance.measure(measurementName, beforeName, afterName);\n return {\n ...result,\n duration: ts.performance.getDuration(measurementName)\n };\n };\n\n this._typescriptTerminal.writeLine(`Using TypeScript version ${ts.version}`);\n\n const rawDiagnostics: TTypescript.Diagnostic[] = [];\n\n const pendingOperations: Set<IPendingWork> = new Set();\n\n this._tool = {\n ts,\n\n measureSync: measureTsPerformance,\n measureAsync: measureTsPerformanceAsync,\n\n sourceFileCache: new Map(),\n\n watchProgram: undefined,\n solutionBuilder: undefined,\n\n rawDiagnostics,\n\n pendingOperations,\n\n executing: false,\n\n reportDiagnostic: (diagnostic: TTypescript.Diagnostic) => {\n rawDiagnostics.push(diagnostic);\n },\n\n clearTimeout(timeout: IPendingWork): void {\n pendingOperations.delete(timeout);\n },\n\n setTimeout<T extends unknown[]>(fn: (...args: T) => void, ms: number, ...args: T): IPendingWork {\n const timeout: IPendingWork = () => {\n fn(...args);\n };\n pendingOperations.add(timeout);\n if (!this.executing && onChangeDetected) {\n onChangeDetected();\n }\n return timeout;\n }\n };\n }\n\n const { performance } = this._tool.ts;\n // Reset the performance counters to 0 to avoid contamination from previous runs\n performance.disable();\n performance.enable();\n\n if (onChangeDetected !== undefined) {\n this._runWatch(this._tool);\n } else if (this._useSolutionBuilder) {\n this._runSolutionBuild(this._tool);\n } else {\n await this._runBuildAsync(this._tool);\n }\n }\n\n public _runWatch(tool: ITypeScriptTool): void {\n const { ts, measureSync: measureTsPerformance, pendingOperations, rawDiagnostics } = tool;\n\n if (!tool.solutionBuilder && !tool.watchProgram) {\n //#region CONFIGURE\n const { duration: configureDurationMs, tsconfig } = measureTsPerformance('Configure', () => {\n const _tsconfig: TTypescript.ParsedCommandLine = this._loadTsconfig(ts);\n this._validateTsconfig(ts, _tsconfig);\n\n return {\n tsconfig: _tsconfig\n };\n });\n this._typescriptTerminal.writeVerboseLine(`Configure: ${configureDurationMs}ms`);\n //#endregion\n\n if (this._useSolutionBuilder) {\n const solutionHost: TWatchSolutionHost = this._buildWatchSolutionBuilderHost(tool);\n const builder: TTypescript.SolutionBuilder<TTypescript.EmitAndSemanticDiagnosticsBuilderProgram> =\n ts.createSolutionBuilderWithWatch(solutionHost, [this._configuration.tsconfigPath], {});\n\n tool.solutionBuilder = builder as IExtendedSolutionBuilder;\n\n builder.build();\n } else {\n const compilerHost: TWatchCompilerHost = this._buildWatchCompilerHost(tool, tsconfig);\n tool.watchProgram = ts.createWatchProgram(compilerHost);\n }\n }\n\n if (pendingOperations.size > 0) {\n rawDiagnostics.length = 0;\n tool.executing = true;\n for (const operation of pendingOperations) {\n pendingOperations.delete(operation);\n operation();\n }\n tool.executing = false;\n }\n this._logDiagnostics(ts, rawDiagnostics);\n }\n\n public async _runBuildAsync(tool: ITypeScriptTool): Promise<void> {\n const { ts, measureSync: measureTsPerformance, measureAsync: measureTsPerformanceAsync } = tool;\n\n //#region CONFIGURE\n const {\n duration: configureDurationMs,\n tsconfig,\n compilerHost\n } = measureTsPerformance('Configure', () => {\n this._overrideTypeScriptReadJson(ts);\n const _tsconfig: TTypescript.ParsedCommandLine = this._loadTsconfig(ts);\n this._validateTsconfig(ts, _tsconfig);\n\n const _compilerHost: TTypescript.CompilerHost = this._buildIncrementalCompilerHost(tool, _tsconfig);\n\n return {\n tsconfig: _tsconfig,\n compilerHost: _compilerHost\n };\n });\n this._typescriptTerminal.writeVerboseLine(`Configure: ${configureDurationMs}ms`);\n //#endregion\n\n //#region PROGRAM\n // There will be only one program here; emit will get a bit abused if we produce multiple outputs\n let builderProgram: TTypescript.EmitAndSemanticDiagnosticsBuilderProgram | undefined = undefined;\n let tsProgram: TTypescript.Program;\n\n if (tsconfig.options.incremental) {\n builderProgram = ts.createEmitAndSemanticDiagnosticsBuilderProgram(\n tsconfig.fileNames,\n tsconfig.options,\n compilerHost,\n ts.readBuilderProgram(tsconfig.options, compilerHost),\n ts.getConfigFileParsingDiagnostics(tsconfig),\n tsconfig.projectReferences\n );\n tsProgram = builderProgram.getProgram();\n } else {\n tsProgram = ts.createProgram({\n rootNames: tsconfig.fileNames,\n options: tsconfig.options,\n projectReferences: tsconfig.projectReferences,\n host: compilerHost,\n oldProgram: undefined,\n configFileParsingDiagnostics: ts.getConfigFileParsingDiagnostics(tsconfig)\n });\n }\n\n // Prefer the builder program, since it is what gives us incremental builds\n const genericProgram: TTypescript.BuilderProgram | TTypescript.Program = builderProgram || tsProgram;\n\n this._logReadPerformance(ts);\n //#endregion\n\n //#region ANALYSIS\n const { duration: diagnosticsDurationMs, diagnostics: preDiagnostics } = measureTsPerformance(\n 'Analyze',\n () => {\n const rawDiagnostics: TTypescript.Diagnostic[] = [\n ...genericProgram.getConfigFileParsingDiagnostics(),\n ...genericProgram.getOptionsDiagnostics(),\n ...genericProgram.getSyntacticDiagnostics(),\n ...genericProgram.getGlobalDiagnostics(),\n ...genericProgram.getSemanticDiagnostics()\n ];\n return { diagnostics: rawDiagnostics };\n }\n );\n this._typescriptTerminal.writeVerboseLine(`Analyze: ${diagnosticsDurationMs}ms`);\n //#endregion\n\n //#region EMIT\n const emitResult: IExtendedEmitResult = this._emit(ts, genericProgram);\n //#endregion\n\n this._logEmitPerformance(ts);\n\n //#region FINAL_ANALYSIS\n // Need to ensure that we include emit diagnostics, since they might not be part of the other sets\n const rawDiagnostics: TTypescript.Diagnostic[] = [...preDiagnostics, ...emitResult.diagnostics];\n //#endregion\n\n //#region WRITE\n // Using async file system I/O for theoretically better peak performance\n // Also allows to run concurrently with linting\n const writePromise: Promise<{ duration: number }> = measureTsPerformanceAsync('Write', () =>\n Async.forEachAsync(\n emitResult.filesToWrite,\n async ({ filePath, data }: { filePath: string; data: string }) =>\n this._cachedFileSystem.writeFile(filePath, data, { ensureFolderExists: true }),\n { concurrency: this._configuration.maxWriteParallelism }\n )\n );\n //#endregion\n\n const { duration: writeDuration } = await writePromise;\n this._typescriptTerminal.writeVerboseLine(\n `I/O Write: ${writeDuration}ms (${emitResult.filesToWrite.length} files)`\n );\n\n this._logDiagnostics(ts, rawDiagnostics);\n // Reset performance counters in case any are used in the callback\n ts.performance.disable();\n ts.performance.enable();\n this._configuration.emitChangedFilesCallback(tsProgram, emitResult.changedSourceFiles);\n }\n\n public _runSolutionBuild(tool: ITypeScriptTool): void {\n this._typescriptTerminal.writeVerboseLine(`Using solution mode`);\n\n const { ts, measureSync, rawDiagnostics } = tool;\n rawDiagnostics.length = 0;\n\n if (!tool.solutionBuilder) {\n //#region CONFIGURE\n const { duration: configureDurationMs, solutionBuilderHost } = measureSync('Configure', () => {\n const _tsconfig: TTypescript.ParsedCommandLine = this._loadTsconfig(ts);\n this._validateTsconfig(ts, _tsconfig);\n\n const _solutionBuilderHost: TSolutionHost = this._buildSolutionBuilderHost(tool);\n\n return {\n solutionBuilderHost: _solutionBuilderHost\n };\n });\n this._typescriptTerminal.writeVerboseLine(`Configure: ${configureDurationMs}ms`);\n //#endregion\n\n tool.solutionBuilder = ts.createSolutionBuilder(\n solutionBuilderHost,\n [this._configuration.tsconfigPath],\n {}\n ) as IExtendedSolutionBuilder;\n } else {\n // Force reload everything from disk\n for (const project of tool.solutionBuilder.getBuildOrder()) {\n tool.solutionBuilder.invalidateProject(project, 1);\n }\n }\n\n //#region EMIT\n // Ignoring the exit status because we only care about presence of diagnostics\n tool.solutionBuilder.build();\n //#endregion\n\n this._logDiagnostics(ts, rawDiagnostics);\n }\n\n private _logDiagnostics(ts: ExtendedTypeScript, rawDiagnostics: TTypescript.Diagnostic[]): void {\n const diagnostics: readonly TTypescript.Diagnostic[] = ts.sortAndDeduplicateDiagnostics(rawDiagnostics);\n\n if (diagnostics.length > 0) {\n this._typescriptTerminal.writeLine(\n `Encountered ${diagnostics.length} TypeScript issue${diagnostics.length > 1 ? 's' : ''}:`\n );\n for (const diagnostic of diagnostics) {\n const diagnosticCategory: TTypescript.DiagnosticCategory = this._getAdjustedDiagnosticCategory(\n diagnostic,\n ts\n );\n\n this._printDiagnosticMessage(ts, diagnostic, diagnosticCategory);\n }\n }\n }\n\n private _logEmitPerformance(ts: ExtendedTypeScript): void {\n this._typescriptTerminal.writeVerboseLine(`Bind: ${ts.performance.getDuration('Bind')}ms`);\n this._typescriptTerminal.writeVerboseLine(`Check: ${ts.performance.getDuration('Check')}ms`);\n this._typescriptTerminal.writeVerboseLine(\n `Transform: ${ts.performance.getDuration('transformTime')}ms ` +\n `(${ts.performance.getCount('beforeTransform')} files)`\n );\n this._typescriptTerminal.writeVerboseLine(\n `Print: ${ts.performance.getDuration('printTime')}ms ` +\n `(${ts.performance.getCount('beforePrint')} files) (Includes Transform)`\n );\n this._typescriptTerminal.writeVerboseLine(\n `Emit: ${ts.performance.getDuration('Emit')}ms (Includes Print)`\n );\n }\n\n private _logReadPerformance(ts: ExtendedTypeScript): void {\n this._typescriptTerminal.writeVerboseLine(\n `I/O Read: ${ts.performance.getDuration('I/O Read')}ms (${ts.performance.getCount(\n 'beforeIORead'\n )} files)`\n );\n this._typescriptTerminal.writeVerboseLine(\n `Parse: ${ts.performance.getDuration('Parse')}ms (${ts.performance.getCount('beforeParse')} files)`\n );\n this._typescriptTerminal.writeVerboseLine(\n `Program (includes Read + Parse): ${ts.performance.getDuration('Program')}ms`\n );\n }\n\n private _printDiagnosticMessage(\n ts: ExtendedTypeScript,\n diagnostic: TTypescript.Diagnostic,\n diagnosticCategory: TTypescript.DiagnosticCategory = this._getAdjustedDiagnosticCategory(diagnostic, ts)\n ): void {\n // Code taken from reference example\n let diagnosticMessage: string;\n let errorObject: Error;\n if (diagnostic.file) {\n const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start!);\n const message: string = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\\n');\n const formattedMessage: string = `(TS${diagnostic.code}) ${message}`;\n errorObject = new FileError(formattedMessage, {\n absolutePath: diagnostic.file.fileName,\n projectFolder: this._configuration.buildFolderPath,\n line: line + 1,\n column: character + 1\n });\n diagnosticMessage = errorObject.toString();\n } else {\n diagnosticMessage = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\\n');\n errorObject = new Error(diagnosticMessage);\n }\n\n switch (diagnosticCategory) {\n case ts.DiagnosticCategory.Error: {\n this._typescriptLogger.emitError(errorObject);\n break;\n }\n\n case ts.DiagnosticCategory.Warning: {\n this._typescriptLogger.emitWarning(errorObject);\n break;\n }\n\n default: {\n this._typescriptTerminal.writeLine(...diagnosticMessage);\n break;\n }\n }\n }\n\n private _getAdjustedDiagnosticCategory(\n diagnostic: TTypescript.Diagnostic,\n ts: ExtendedTypeScript\n ): TTypescript.DiagnosticCategory {\n // Workaround for https://github.com/microsoft/TypeScript/issues/40058\n // The compiler reports a hard error for issues such as this:\n //\n // error TS6133: 'x' is declared but its value is never read.\n //\n // These should properly be treated as warnings, because they are purely cosmetic issues.\n // TODO: Maybe heft should provide a config file for managing DiagnosticCategory mappings.\n if (diagnostic.reportsUnnecessary && diagnostic.category === ts.DiagnosticCategory.Error) {\n return ts.DiagnosticCategory.Warning;\n }\n\n // These pedantic checks also should not be treated as hard errors\n switch (diagnostic.code) {\n case ts.Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor\n .code:\n case ts.Diagnostics\n .Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1.code:\n return ts.DiagnosticCategory.Warning;\n }\n\n return diagnostic.category;\n }\n\n private _emit(\n ts: ExtendedTypeScript,\n genericProgram: TTypescript.BuilderProgram | TTypescript.Program\n ): IExtendedEmitResult {\n const filesToWrite: IFileToWrite[] = [];\n\n const changedFiles: Set<TTypescript.SourceFile> = new Set();\n EmitFilesPatch.install(ts, genericProgram.getCompilerOptions(), this._moduleKindsToEmit, changedFiles);\n\n const writeFileCallback: TTypescript.WriteFileCallback = (filePath: string, data: string) => {\n filesToWrite.push({ filePath, data });\n };\n\n try {\n const result: TTypescript.EmitResult = genericProgram.emit(\n undefined, // Target source file\n writeFileCallback\n );\n\n return {\n ...result,\n changedSourceFiles: changedFiles,\n filesToWrite\n };\n } finally {\n EmitFilesPatch.uninstall(ts);\n }\n }\n\n private _validateTsconfig(ts: ExtendedTypeScript, tsconfig: TTypescript.ParsedCommandLine): void {\n if (\n (tsconfig.options.module && !tsconfig.options.outDir) ||\n (!tsconfig.options.module && tsconfig.options.outDir)\n ) {\n throw new Error(\n 'If either the module or the outDir option is provided in the tsconfig compilerOptions, both must be provided'\n );\n }\n\n this._moduleKindsToEmit = [];\n const specifiedKinds: Map<TTypescript.ModuleKind, IModuleKindReason> = new Map();\n const specifiedOutDirs: Map<string, IModuleKindReason> = new Map();\n\n if (!tsconfig.options.module) {\n throw new Error(\n 'If the module tsconfig compilerOption is not provided, the builder must be provided with the ' +\n 'additionalModuleKindsToEmit configuration option.'\n );\n }\n\n if (this._configuration.emitCjsExtensionForCommonJS) {\n this._addModuleKindToEmit(\n ts.ModuleKind.CommonJS,\n tsconfig.options.outDir!,\n /* isPrimary */ tsconfig.options.module === ts.ModuleKind.CommonJS,\n '.cjs'\n );\n\n const cjsReason: IModuleKindReason = {\n outDir: tsconfig.options.outDir!,\n kind: 'CommonJS',\n extension: '.cjs',\n reason: 'emitCjsExtensionForCommonJS'\n };\n\n specifiedKinds.set(ts.ModuleKind.CommonJS, cjsReason);\n specifiedOutDirs.set(`${tsconfig.options.outDir!}:.cjs`, cjsReason);\n }\n\n if (this._configuration.emitMjsExtensionForESModule) {\n this._addModuleKindToEmit(\n ts.ModuleKind.ESNext,\n tsconfig.options.outDir!,\n /* isPrimary */ tsconfig.options.module === ts.ModuleKind.ESNext,\n '.mjs'\n );\n\n const mjsReason: IModuleKindReason = {\n outDir: tsconfig.options.outDir!,\n kind: 'ESNext',\n extension: '.mjs',\n reason: 'emitMjsExtensionForESModule'\n };\n\n specifiedKinds.set(ts.ModuleKind.ESNext, mjsReason);\n specifiedOutDirs.set(`${tsconfig.options.outDir!}:.mjs`, mjsReason);\n }\n\n if (!specifiedKinds.has(tsconfig.options.module)) {\n this._addModuleKindToEmit(\n tsconfig.options.module,\n tsconfig.options.outDir!,\n /* isPrimary */ true,\n /* jsExtensionOverride */ undefined\n );\n\n const tsConfigReason: IModuleKindReason = {\n outDir: tsconfig.options.outDir!,\n kind: ts.ModuleKind[tsconfig.options.module] as keyof typeof TTypescript.ModuleKind,\n extension: '.js',\n reason: 'tsconfig.json'\n };\n\n specifiedKinds.set(tsconfig.options.module, tsConfigReason);\n specifiedOutDirs.set(`${tsconfig.options.outDir!}:.js`, tsConfigReason);\n }\n\n if (this._configuration.additionalModuleKindsToEmit) {\n for (const additionalModuleKindToEmit of this._configuration.additionalModuleKindsToEmit) {\n const moduleKind: TTypescript.ModuleKind = this._parseModuleKind(\n ts,\n additionalModuleKindToEmit.moduleKind\n );\n\n const outDirKey: string = `${additionalModuleKindToEmit.outFolderName}:.js`;\n const moduleKindReason: IModuleKindReason = {\n kind: ts.ModuleKind[moduleKind] as keyof typeof TTypescript.ModuleKind,\n outDir: additionalModuleKindToEmit.outFolderName,\n extension: '.js',\n reason: `additionalModuleKindsToEmit`\n };\n\n const existingKind: IModuleKindReason | undefined = specifiedKinds.get(moduleKind);\n const existingDir: IModuleKindReason | undefined = specifiedOutDirs.get(outDirKey);\n\n if (existingKind) {\n throw new Error(\n `Module kind \"${additionalModuleKindToEmit.moduleKind}\" is already emitted at ${existingKind.outDir} with extension '${existingKind.extension}' by option ${existingKind.reason}.`\n );\n } else if (existingDir) {\n throw new Error(\n `Output folder \"${additionalModuleKindToEmit.outFolderName}\" already contains module kind ${existingDir.kind} with extension '${existingDir.extension}', specified by option ${existingDir.reason}.`\n );\n } else {\n const outFolderKey: string | undefined = this._addModuleKindToEmit(\n moduleKind,\n additionalModuleKindToEmit.outFolderName,\n /* isPrimary */ false,\n undefined\n );\n\n if (outFolderKey) {\n specifiedKinds.set(moduleKind, moduleKindReason);\n specifiedOutDirs.set(outFolderKey, moduleKindReason);\n }\n }\n }\n }\n }\n\n private _addModuleKindToEmit(\n moduleKind: TTypescript.ModuleKind,\n outFolderPath: string,\n isPrimary: boolean,\n jsExtensionOverride: string | undefined\n ): string | undefined {\n let outFolderName: string;\n if (path.isAbsolute(outFolderPath)) {\n outFolderName = path.relative(this._configuration.buildFolderPath, outFolderPath);\n } else {\n outFolderName = outFolderPath;\n outFolderPath = path.resolve(this._configuration.buildFolderPath, outFolderPath);\n }\n\n outFolderPath = Path.convertToSlashes(outFolderPath);\n outFolderPath = outFolderPath.replace(/\\/*$/, '/'); // Ensure the outFolderPath ends with a slash\n\n for (const existingModuleKindToEmit of this._moduleKindsToEmit) {\n let errorText: string | undefined;\n\n if (existingModuleKindToEmit.outFolderPath === outFolderPath) {\n if (existingModuleKindToEmit.jsExtensionOverride === jsExtensionOverride) {\n errorText =\n 'Unable to output two different module kinds with the same ' +\n `module extension (${jsExtensionOverride || '.js'}) to the same ` +\n `folder (\"${outFolderPath}\").`;\n }\n } else {\n let parentFolder: string | undefined;\n let childFolder: string | undefined;\n if (outFolderPath.startsWith(existingModuleKindToEmit.outFolderPath)) {\n parentFolder = outFolderPath;\n childFolder = existingModuleKindToEmit.outFolderPath;\n } else if (existingModuleKindToEmit.outFolderPath.startsWith(outFolderPath)) {\n parentFolder = existingModuleKindToEmit.outFolderPath;\n childFolder = outFolderPath;\n }\n\n if (parentFolder) {\n errorText =\n 'Unable to output two different module kinds to nested folders ' +\n `(\"${parentFolder}\" and \"${childFolder}\").`;\n }\n }\n\n if (errorText) {\n this._typescriptLogger.emitError(new Error(errorText));\n return undefined;\n }\n }\n\n this._moduleKindsToEmit.push({\n outFolderPath,\n moduleKind,\n jsExtensionOverride,\n\n isPrimary\n });\n\n return `${outFolderName}:${jsExtensionOverride || '.js'}`;\n }\n\n private _loadTsconfig(ts: ExtendedTypeScript): TTypescript.ParsedCommandLine {\n const parsedConfigFile: ReturnType<typeof ts.readConfigFile> = ts.readConfigFile(\n this._configuration.tsconfigPath,\n this._cachedFileSystem.readFile\n );\n\n const currentFolder: string = path.dirname(this._configuration.tsconfigPath);\n const tsconfig: TTypescript.ParsedCommandLine = ts.parseJsonConfigFileContent(\n parsedConfigFile.config,\n {\n fileExists: this._cachedFileSystem.exists,\n readFile: this._cachedFileSystem.readFile,\n readDirectory: (\n folderPath: string,\n extensions?: ReadonlyArray<string>,\n excludes?: ReadonlyArray<string>,\n includes?: ReadonlyArray<string>,\n depth?: number\n ) =>\n ts.matchFiles(\n folderPath,\n extensions,\n excludes,\n includes,\n /* useCaseSensitiveFileNames */ true,\n currentFolder,\n depth,\n this._cachedFileSystem.readFolderFilesAndDirectories.bind(this._cachedFileSystem),\n this._cachedFileSystem.getRealPath.bind(this._cachedFileSystem),\n this._cachedFileSystem.directoryExists.bind(this._cachedFileSystem)\n ),\n useCaseSensitiveFileNames: true\n },\n currentFolder,\n /*existingOptions:*/ undefined,\n this._configuration.tsconfigPath\n );\n\n if (tsconfig.options.incremental) {\n tsconfig.options.tsBuildInfoFile = this._tsCacheFilePath;\n }\n\n return tsconfig;\n }\n\n private _getCreateBuilderProgram(\n tool: ITypeScriptTool\n ): TTypescript.CreateProgram<TTypescript.EmitAndSemanticDiagnosticsBuilderProgram> {\n const {\n _moduleKindsToEmit: moduleKindsToEmit,\n _configuration: { emitChangedFilesCallback }\n } = this;\n\n const { ts } = tool;\n\n const createMultiEmitProgram: TTypescript.CreateProgram<\n TTypescript.EmitAndSemanticDiagnosticsBuilderProgram\n > = (\n fileNames: readonly string[] | undefined,\n compilerOptions: TTypescript.CompilerOptions | undefined,\n host: TTypescript.CompilerHost | undefined,\n oldProgram: TTypescript.EmitAndSemanticDiagnosticsBuilderProgram | undefined,\n configFileParsingDiagnostics: readonly TTypescript.Diagnostic[] | undefined,\n projectReferences: readonly TTypescript.ProjectReference[] | undefined\n ): TTypescript.EmitAndSemanticDiagnosticsBuilderProgram => {\n // Reset performance counters\n ts.performance.disable();\n ts.performance.enable();\n\n this._typescriptTerminal.writeVerboseLine(`Reading program \"${compilerOptions!.configFilePath}\"`);\n\n const newProgram: TTypescript.EmitAndSemanticDiagnosticsBuilderProgram =\n ts.createEmitAndSemanticDiagnosticsBuilderProgram(\n fileNames,\n compilerOptions,\n host,\n oldProgram,\n configFileParsingDiagnostics,\n projectReferences\n );\n\n this._logReadPerformance(ts);\n\n const { emit: originalEmit } = newProgram;\n\n if (!compilerOptions) {\n throw new Error(`Expected compilerOptions!`);\n }\n\n const emit: typeof originalEmit = (\n targetSourceFile?: TTypescript.SourceFile,\n writeFile?: TTypescript.WriteFileCallback,\n cancellationToken?: TTypescript.CancellationToken,\n emitOnlyDtsFiles?: boolean,\n customTransformers?: TTypescript.CustomTransformers\n ) => {\n const changedFiles: Set<TTypescript.SourceFile> = new Set();\n try {\n EmitFilesPatch.install(ts, compilerOptions, moduleKindsToEmit, changedFiles);\n\n const result: TTypescript.EmitResult = originalEmit.call(\n newProgram,\n targetSourceFile,\n writeFile,\n cancellationToken,\n emitOnlyDtsFiles,\n customTransformers\n );\n\n this._typescriptTerminal.writeVerboseLine(`Emitting program \"${compilerOptions!.configFilePath}\"`);\n\n this._logEmitPerformance(ts);\n\n // Reset performance counters\n ts.performance.disable();\n ts.performance.enable();\n\n emitChangedFilesCallback(newProgram.getProgram(), changedFiles);\n\n return result;\n } finally {\n EmitFilesPatch.uninstall(ts);\n }\n };\n\n newProgram.emit = emit;\n\n return newProgram;\n };\n\n return createMultiEmitProgram;\n }\n\n private _buildSolutionBuilderHost(tool: ITypeScriptTool): TSolutionHost {\n const reportSolutionBuilderStatus: TTypescript.DiagnosticReporter = tool.reportDiagnostic;\n const reportEmitErrorSummary: TTypescript.ReportEmitErrorSummary = (errorCount: number): void => {\n // Do nothing\n };\n\n const { ts } = tool;\n\n const solutionBuilderHost: TTypescript.SolutionBuilderHost<TTypescript.EmitAndSemanticDiagnosticsBuilderProgram> =\n ts.createSolutionBuilderHost(\n ts.sys,\n this._getCreateBuilderProgram(tool),\n tool.reportDiagnostic,\n reportSolutionBuilderStatus,\n reportEmitErrorSummary\n );\n\n solutionBuilderHost.afterProgramEmitAndDiagnostics = (\n program: TTypescript.EmitAndSemanticDiagnosticsBuilderProgram\n ) => {\n // Use the native metric since we aren't overwriting the writer\n this._typescriptTerminal.writeVerboseLine(\n `I/O Write: ${ts.performance.getDuration('I/O Write')}ms (${ts.performance.getCount(\n 'beforeIOWrite'\n )} files)`\n );\n };\n\n return solutionBuilderHost;\n }\n\n private _buildIncrementalCompilerHost(\n tool: ITypeScriptTool,\n tsconfig: TTypescript.ParsedCommandLine\n ): TTypescript.CompilerHost {\n const { ts } = tool;\n\n let compilerHost: TTypescript.CompilerHost | undefined;\n\n if (tsconfig.options.incremental) {\n compilerHost = ts.createIncrementalCompilerHost(tsconfig.options, ts.sys);\n } else {\n compilerHost = ts.createCompilerHost(tsconfig.options);\n }\n\n this._changeCompilerHostToUseCache(compilerHost, tool);\n\n return compilerHost;\n }\n\n private _buildWatchCompilerHost(\n tool: ITypeScriptTool,\n tsconfig: TTypescript.ParsedCommandLine\n ): TWatchCompilerHost {\n const { ts } = tool;\n\n const reportWatchStatus: TTypescript.DiagnosticReporter = (diagnostic: TTypescript.Diagnostic): void => {\n this._printDiagnosticMessage(ts, diagnostic);\n };\n\n const compilerHost: TWatchCompilerHost = ts.createWatchCompilerHost(\n tsconfig.fileNames,\n tsconfig.options,\n ts.sys,\n this._getCreateBuilderProgram(tool),\n tool.reportDiagnostic,\n reportWatchStatus,\n tsconfig.projectReferences\n );\n\n compilerHost.clearTimeout = tool.clearTimeout;\n compilerHost.setTimeout = tool.setTimeout;\n\n return compilerHost;\n }\n\n private _changeCompilerHostToUseCache(compilerHost: TTypescript.CompilerHost, tool: ITypeScriptTool): void {\n const { sourceFileCache } = tool;\n\n const { getSourceFile: innerGetSourceFile } = compilerHost;\n if ((innerGetSourceFile as { cache?: typeof sourceFileCache }).cache === sourceFileCache) {\n return;\n }\n\n // Enable source file persistence\n const getSourceFile: typeof innerGetSourceFile & {\n cache?: typeof sourceFileCache;\n } = (\n fileName: string,\n languageVersionOrOptions: TTypescript.ScriptTarget | TTypescript.CreateSourceFileOptions,\n onError?: ((message: string) => void) | undefined,\n shouldCreateNewSourceFile?: boolean | undefined\n ): TTypescript.SourceFile | undefined => {\n if (!shouldCreateNewSourceFile) {\n const cachedSourceFile: TTypescript.SourceFile | undefined = sourceFileCache.get(fileName);\n if (cachedSourceFile) {\n return cachedSourceFile;\n }\n }\n\n const result: TTypescript.SourceFile | undefined = innerGetSourceFile(\n fileName,\n languageVersionOrOptions,\n onError,\n shouldCreateNewSourceFile\n );\n if (result) {\n sourceFileCache.set(fileName, result);\n } else {\n sourceFileCache.delete(fileName);\n }\n return result;\n };\n\n getSourceFile.cache = sourceFileCache;\n\n compilerHost.getSourceFile = getSourceFile;\n }\n\n private _buildWatchSolutionBuilderHost(tool: ITypeScriptTool): TWatchSolutionHost {\n const { reportDiagnostic, ts } = tool;\n\n const host: TWatchSolutionHost = ts.createSolutionBuilderWithWatchHost(\n ts.sys,\n this._getCreateBuilderProgram(tool),\n reportDiagnostic,\n reportDiagnostic,\n reportDiagnostic\n );\n\n host.clearTimeout = tool.clearTimeout;\n host.setTimeout = tool.setTimeout;\n\n return host;\n }\n\n private _overrideTypeScriptReadJson(ts: ExtendedTypeScript): void {\n const cachedReadJson: (filePath: string) => object = (filePath: string) => {\n let jsonData: object | undefined = this._tsReadJsonCache.get(filePath);\n if (jsonData) {\n return jsonData;\n } else {\n try {\n const fileContents: string = this._cachedFileSystem.readFile(filePath);\n if (!fileContents) {\n jsonData = EMPTY_JSON;\n } else {\n const parsedFile: ReturnType<typeof ts.parseConfigFileTextToJson> = ts.parseConfigFileTextToJson(\n filePath,\n fileContents\n );\n if (parsedFile.error) {\n jsonData = EMPTY_JSON;\n } else {\n jsonData = parsedFile.config as object;\n }\n }\n } catch (error) {\n jsonData = EMPTY_JSON;\n }\n\n this._tsReadJsonCache.set(filePath, jsonData);\n return jsonData;\n }\n };\n ts.readJson = cachedReadJson;\n }\n\n private _parseModuleKind(ts: ExtendedTypeScript, moduleKindName: string): TTypescript.ModuleKind {\n switch (moduleKindName.toLowerCase()) {\n case 'commonjs':\n return ts.ModuleKind.CommonJS;\n\n case 'amd':\n return ts.ModuleKind.AMD;\n\n case 'umd':\n return ts.ModuleKind.UMD;\n\n case 'system':\n return ts.ModuleKind.System;\n\n case 'es2015':\n return ts.ModuleKind.ES2015;\n\n case 'esnext':\n return ts.ModuleKind.ESNext;\n\n default:\n throw new Error(`\"${moduleKindName}\" is not a valid module kind name.`);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TypeScriptBuilder.js","sourceRoot":"","sources":["../src/TypeScriptBuilder.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,+CAAiC;AACjC,2CAA6B;AAC7B,+CAAiC;AAEjC,oEAQsC;AAItC,wFAAqF;AA4GrF,MAAM,iCAAiC,GAAW,CAAC,CAAC;AACpD,MAAM,iCAAiC,GAAW,CAAC,CAAC;AAEpD,MAAM,iCAAiC,GAAW,CAAC,CAAC;AACpD,MAAM,iCAAiC,GAAW,CAAC,CAAC;AAEpD,iEAAiE;AACjE,MAAM,iCAAiC,GAAkB,MAAM,CAAC,oBAAoB,CAAC,CAAC;AACtF,MAAM,iBAAiB,GAAkB,MAAM,CAAC,MAAM,CAAC,CAAC;AAuBxD,MAAa,iBAAiB;IA4C5B,YAAmB,aAA8C;QAhChD,+BAA0B,GAAgB,IAAI,GAAG,EAAE,CAAC;QAG7D,sBAAiB,GAA+B,IAAI,uDAA0B,EAAE,CAAC;QAEjF,UAAK,GAAgC,SAAS,CAAC;QA4BrD,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;QACpC,IAAI,CAAC,iBAAiB,GAAG,aAAa,CAAC,YAAY,CAAC;QACpD,IAAI,CAAC,mBAAmB,GAAG,aAAa,CAAC,YAAY,CAAC,QAAQ,CAAC;IACjE,CAAC;IA7BD,IAAY,gBAAgB;QAC1B,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE;YAC3B,iHAAiH;YACjH,0DAA0D;YAC1D,MAAM,UAAU,GAAgB,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;YAE1D,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,I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,CAClB,QAAQ,CAAC,OAAO,CAAC,kBAAkB,EAAE,oBAAoB,CAAC,EAC1D,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,WAAW,CACZ,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as crypto from 'crypto';\nimport * as path from 'path';\nimport * as semver from 'semver';\nimport type * as TTypescript from 'typescript';\nimport {\n type ITerminal,\n JsonFile,\n type IPackageJson,\n Path,\n Async,\n FileError,\n InternalError\n} from '@rushstack/node-core-library';\nimport type { IScopedLogger } from '@rushstack/heft';\n\nimport type { ExtendedTypeScript, IExtendedSolutionBuilder } from './internalTypings/TypeScriptInternals';\nimport { TypeScriptCachedFileSystem } from './fileSystem/TypeScriptCachedFileSystem';\nimport type { ITypeScriptConfigurationJson } from './TypeScriptPlugin';\nimport type { PerformanceMeasurer, PerformanceMeasurerAsync } from './Performance';\n\ninterface ICachedEmitModuleKind {\n moduleKind: TTypescript.ModuleKind;\n\n outFolderPath: string;\n\n /**\n * File extension to use instead of '.js' for emitted ECMAScript files.\n * For example, '.cjs' to indicate commonjs content, or '.mjs' to indicate ECMAScript modules.\n */\n jsExtensionOverride: string | undefined;\n\n /**\n * Set to true if this is the emit kind that is specified in the tsconfig.json.\n * Declarations are only emitted for the primary module kind.\n */\n isPrimary: boolean;\n}\n\nexport interface ITypeScriptBuilderConfiguration extends ITypeScriptConfigurationJson {\n /**\n * The root folder of the build.\n */\n buildFolderPath: string;\n\n /**\n * The folder to write build metadata.\n */\n buildMetadataFolderPath: string;\n\n /**\n * The path to the TypeScript tool.\n */\n typeScriptToolPath: string;\n\n // watchMode: boolean;\n\n /**\n * The path to the tsconfig file being built.\n */\n tsconfigPath: string;\n\n /**\n * Set this to change the maximum number of file handles that will be opened concurrently for writing.\n * The default is 50.\n */\n maxWriteParallelism: number;\n\n /**\n * The scoped logger that the builder will log to.\n */\n scopedLogger: IScopedLogger;\n\n /**\n * The callback used to emit the typescript program (or programs) from the builder.\n */\n emitChangedFilesCallback: (\n program: TTypescript.Program,\n changedFiles?: Set<TTypescript.SourceFile>\n ) => void;\n}\n\ntype TSolutionHost = TTypescript.SolutionBuilderHost<TTypescript.EmitAndSemanticDiagnosticsBuilderProgram>;\ntype TWatchCompilerHost =\n TTypescript.WatchCompilerHostOfFilesAndCompilerOptions<TTypescript.EmitAndSemanticDiagnosticsBuilderProgram>;\ntype TWatchSolutionHost =\n TTypescript.SolutionBuilderWithWatchHost<TTypescript.EmitAndSemanticDiagnosticsBuilderProgram>;\ntype TWatchProgram =\n TTypescript.WatchOfFilesAndCompilerOptions<TTypescript.EmitAndSemanticDiagnosticsBuilderProgram>;\n\ninterface ICompilerCapabilities {\n /**\n * Support for incremental compilation via `ts.createIncrementalProgram()`.\n * Introduced with TypeScript 3.6.\n */\n incrementalProgram: boolean;\n\n /**\n * Support for composite projects via `ts.createSolutionBuilder()`.\n * Introduced with TypeScript 3.0.\n */\n solutionBuilder: boolean;\n}\n\ninterface IFileToWrite {\n filePath: string;\n data: string;\n}\n\ninterface IModuleKindReason {\n kind: keyof typeof TTypescript.ModuleKind;\n outDir: string;\n extension: '.js' | '.cjs' | '.mjs';\n reason: string;\n}\n\ninterface IExtendedEmitResult extends TTypescript.EmitResult {\n changedSourceFiles: Set<TTypescript.SourceFile>;\n filesToWrite: IFileToWrite[];\n}\n\ninterface IPendingWork {\n (): void;\n}\n\nconst OLDEST_SUPPORTED_TS_MAJOR_VERSION: number = 2;\nconst OLDEST_SUPPORTED_TS_MINOR_VERSION: number = 9;\n\nconst NEWEST_SUPPORTED_TS_MAJOR_VERSION: number = 5;\nconst NEWEST_SUPPORTED_TS_MINOR_VERSION: number = 0;\n\n// symbols for attaching hidden metadata to ts.Program instances.\nconst INNER_GET_COMPILER_OPTIONS_SYMBOL: unique symbol = Symbol('getCompilerOptions');\nconst INNER_EMIT_SYMBOL: unique symbol = Symbol('emit');\n\ninterface ITypeScriptTool {\n ts: ExtendedTypeScript;\n measureSync: PerformanceMeasurer;\n measureAsync: PerformanceMeasurerAsync;\n\n sourceFileCache: Map<string, TTypescript.SourceFile>;\n\n watchProgram: TWatchProgram | undefined;\n\n solutionBuilder: IExtendedSolutionBuilder | undefined;\n\n rawDiagnostics: TTypescript.Diagnostic[];\n pendingOperations: Set<IPendingWork>;\n\n executing: boolean;\n\n reportDiagnostic: TTypescript.DiagnosticReporter;\n clearTimeout: (timeout: IPendingWork) => void;\n setTimeout: <T extends unknown[]>(timeout: (...args: T) => void, ms: number, ...args: T) => IPendingWork;\n}\n\nexport class TypeScriptBuilder {\n private readonly _configuration: ITypeScriptBuilderConfiguration;\n private readonly _typescriptLogger: IScopedLogger;\n private readonly _typescriptTerminal: ITerminal;\n\n private _typescriptVersion!: string;\n private _typescriptParsedVersion!: semver.SemVer;\n\n private _capabilities!: ICompilerCapabilities;\n private _useSolutionBuilder!: boolean;\n\n private _moduleKindsToEmit!: ICachedEmitModuleKind[];\n private readonly _suppressedDiagnosticCodes: Set<number> = new Set();\n\n private __tsCacheFilePath: string | undefined;\n private _cachedFileSystem: TypeScriptCachedFileSystem = new TypeScriptCachedFileSystem();\n\n private _tool: ITypeScriptTool | undefined = undefined;\n\n private get _tsCacheFilePath(): string {\n if (!this.__tsCacheFilePath) {\n // TypeScript internally handles if the tsconfig options have changed from when the tsbuildinfo file was created.\n // We only need to hash our additional Heft configuration.\n const configHash: crypto.Hash = crypto.createHash('sha1');\n\n configHash.update(JSON.stringify(this._configuration.additionalModuleKindsToEmit || {}));\n const serializedConfigHash: string = configHash\n .digest('base64')\n .slice(0, 8)\n .replace(/\\+/g, '-')\n .replace(/\\//g, '_');\n\n // This conversion is theoretically redundant, but it is here to make absolutely sure that the path is formatted\n // using only '/' as the directory separator so that incremental builds don't break on Windows.\n // TypeScript will normalize to '/' when serializing, but not on the direct input, and uses exact string equality.\n const normalizedCacheFolderPath: string = Path.convertToSlashes(\n this._configuration.buildMetadataFolderPath\n );\n this.__tsCacheFilePath = `${normalizedCacheFolderPath}/ts_${serializedConfigHash}.json`;\n }\n\n return this.__tsCacheFilePath;\n }\n\n public constructor(configuration: ITypeScriptBuilderConfiguration) {\n this._configuration = configuration;\n this._typescriptLogger = configuration.scopedLogger;\n this._typescriptTerminal = configuration.scopedLogger.terminal;\n }\n\n public async invokeAsync(onChangeDetected?: () => void): Promise<void> {\n if (!this._tool) {\n // Determine the compiler version\n const compilerPackageJsonFilename: string = path.join(\n this._configuration.typeScriptToolPath,\n 'package.json'\n );\n const packageJson: IPackageJson = await JsonFile.loadAsync(compilerPackageJsonFilename);\n this._typescriptVersion = packageJson.version;\n const parsedVersion: semver.SemVer | null = semver.parse(this._typescriptVersion);\n if (!parsedVersion) {\n throw new Error(\n `Unable to parse version \"${this._typescriptVersion}\" for TypeScript compiler package in: ` +\n compilerPackageJsonFilename\n );\n }\n this._typescriptParsedVersion = parsedVersion;\n\n // Detect what features this compiler supports. Note that manually comparing major/minor numbers\n // loosens the matching to accept prereleases such as \"3.6.0-dev.20190530\"\n this._capabilities = {\n incrementalProgram: false,\n solutionBuilder: this._typescriptParsedVersion.major >= 3\n };\n\n if (\n this._typescriptParsedVersion.major > 3 ||\n (this._typescriptParsedVersion.major === 3 && this._typescriptParsedVersion.minor >= 6)\n ) {\n this._capabilities.incrementalProgram = true;\n }\n\n this._useSolutionBuilder = !!this._configuration.buildProjectReferences;\n if (this._useSolutionBuilder && !this._capabilities.solutionBuilder) {\n throw new Error(\n `Building project references requires TypeScript@>=3.0, but the current version is ${this._typescriptVersion}`\n );\n }\n\n // Report a warning if the TypeScript version is too old/new. The current oldest supported version is\n // TypeScript 2.9. Prior to that the \"ts.getConfigFileParsingDiagnostics()\" API is missing; more fixups\n // would be required to deal with that. We won't do that work unless someone requests it.\n if (\n this._typescriptParsedVersion.major < OLDEST_SUPPORTED_TS_MAJOR_VERSION ||\n (this._typescriptParsedVersion.major === OLDEST_SUPPORTED_TS_MAJOR_VERSION &&\n this._typescriptParsedVersion.minor < OLDEST_SUPPORTED_TS_MINOR_VERSION)\n ) {\n // We don't use writeWarningLine() here because, if the person wants to take their chances with\n // a seemingly unsupported compiler, their build should be allowed to succeed.\n this._typescriptTerminal.writeLine(\n `The TypeScript compiler version ${this._typescriptVersion} is very old` +\n ` and has not been tested with Heft; it may not work correctly.`\n );\n } else if (\n this._typescriptParsedVersion.major > NEWEST_SUPPORTED_TS_MAJOR_VERSION ||\n (this._typescriptParsedVersion.major === NEWEST_SUPPORTED_TS_MAJOR_VERSION &&\n this._typescriptParsedVersion.minor > NEWEST_SUPPORTED_TS_MINOR_VERSION)\n ) {\n this._typescriptTerminal.writeLine(\n `The TypeScript compiler version ${this._typescriptVersion} is newer` +\n ' than the latest version that was tested with Heft ' +\n `(${NEWEST_SUPPORTED_TS_MAJOR_VERSION}.${NEWEST_SUPPORTED_TS_MINOR_VERSION}); it may not work correctly.`\n );\n }\n\n const ts: ExtendedTypeScript = require(this._configuration.typeScriptToolPath);\n\n ts.performance.enable();\n\n const suppressedCodes: (number | undefined)[] = [\n ts.Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor?.code,\n // This diagnostic code is not present in old versions of TypeScript\n ts.Diagnostics\n .Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1?.code\n ];\n for (const code of suppressedCodes) {\n if (code !== undefined) {\n this._suppressedDiagnosticCodes.add(code);\n }\n }\n\n const measureTsPerformance: PerformanceMeasurer = <TResult extends object | void>(\n measurementName: string,\n fn: () => TResult\n ) => {\n const beforeName: string = `before${measurementName}`;\n ts.performance.mark(beforeName);\n const result: TResult = fn();\n const afterName: string = `after${measurementName}`;\n ts.performance.mark(afterName);\n ts.performance.measure(measurementName, beforeName, afterName);\n return {\n ...result,\n duration: ts.performance.getDuration(measurementName),\n count: ts.performance.getCount(beforeName)\n };\n };\n\n const measureTsPerformanceAsync: PerformanceMeasurerAsync = async <TResult extends object | void>(\n measurementName: string,\n fn: () => Promise<TResult>\n ) => {\n const beforeName: string = `before${measurementName}`;\n ts.performance.mark(beforeName);\n const resultPromise: Promise<TResult> = fn();\n const result: TResult = await resultPromise;\n const afterName: string = `after${measurementName}`;\n ts.performance.mark(afterName);\n ts.performance.measure(measurementName, beforeName, afterName);\n return {\n ...result,\n duration: ts.performance.getDuration(measurementName)\n };\n };\n\n this._typescriptTerminal.writeLine(`Using TypeScript version ${ts.version}`);\n\n const rawDiagnostics: TTypescript.Diagnostic[] = [];\n\n const pendingOperations: Set<IPendingWork> = new Set();\n\n this._tool = {\n ts,\n\n measureSync: measureTsPerformance,\n measureAsync: measureTsPerformanceAsync,\n\n sourceFileCache: new Map(),\n\n watchProgram: undefined,\n solutionBuilder: undefined,\n\n rawDiagnostics,\n\n pendingOperations,\n\n executing: false,\n\n reportDiagnostic: (diagnostic: TTypescript.Diagnostic) => {\n rawDiagnostics.push(diagnostic);\n },\n\n clearTimeout(timeout: IPendingWork): void {\n pendingOperations.delete(timeout);\n },\n\n setTimeout<T extends unknown[]>(fn: (...args: T) => void, ms: number, ...args: T): IPendingWork {\n const timeout: IPendingWork = () => {\n fn(...args);\n };\n pendingOperations.add(timeout);\n if (!this.executing && onChangeDetected) {\n onChangeDetected();\n }\n return timeout;\n }\n };\n }\n\n const { performance } = this._tool.ts;\n // Reset the performance counters to 0 to avoid contamination from previous runs\n performance.disable();\n performance.enable();\n\n if (onChangeDetected !== undefined) {\n this._runWatch(this._tool);\n } else if (this._useSolutionBuilder) {\n this._runSolutionBuild(this._tool);\n } else {\n await this._runBuildAsync(this._tool);\n }\n }\n\n private _configureProgramForMultiEmit(\n innerProgram: TTypescript.Program,\n ts: ExtendedTypeScript\n ): { changedFiles: Set<TTypescript.SourceFile> } {\n interface IProgramWithMultiEmit extends TTypescript.Program {\n // Attach the originals to the Program instance to avoid modifying the same Program twice.\n // Don't use WeakMap because this Program could theoretically get a { ... } applied to it.\n [INNER_GET_COMPILER_OPTIONS_SYMBOL]?: TTypescript.Program['getCompilerOptions'];\n [INNER_EMIT_SYMBOL]?: TTypescript.Program['emit'];\n }\n\n const program: IProgramWithMultiEmit = innerProgram;\n\n // Check to see if this Program has already been modified.\n let { [INNER_EMIT_SYMBOL]: innerEmit, [INNER_GET_COMPILER_OPTIONS_SYMBOL]: innerGetCompilerOptions } =\n program;\n\n if (!innerGetCompilerOptions) {\n program[INNER_GET_COMPILER_OPTIONS_SYMBOL] = innerGetCompilerOptions = program.getCompilerOptions;\n }\n\n if (!innerEmit) {\n program[INNER_EMIT_SYMBOL] = innerEmit = program.emit;\n }\n\n let foundPrimary: boolean = false;\n let defaultModuleKind: TTypescript.ModuleKind;\n\n const multiEmitMap: Map<ICachedEmitModuleKind, TTypescript.CompilerOptions> = new Map();\n for (const moduleKindToEmit of this._moduleKindsToEmit) {\n const kindCompilerOptions: TTypescript.CompilerOptions = moduleKindToEmit.isPrimary\n ? {\n ...innerGetCompilerOptions()\n }\n : {\n ...innerGetCompilerOptions(),\n module: moduleKindToEmit.moduleKind,\n outDir: moduleKindToEmit.outFolderPath,\n\n // Don't emit declarations for secondary module kinds\n declaration: false,\n declarationMap: false\n };\n if (!kindCompilerOptions.outDir) {\n throw new InternalError('Expected compilerOptions.outDir to be assigned');\n }\n multiEmitMap.set(moduleKindToEmit, kindCompilerOptions);\n\n if (moduleKindToEmit.isPrimary) {\n if (foundPrimary) {\n throw new Error('Multiple primary module emit kinds encountered.');\n } else {\n foundPrimary = true;\n }\n\n defaultModuleKind = moduleKindToEmit.moduleKind;\n }\n }\n\n const changedFiles: Set<TTypescript.SourceFile> = new Set();\n\n program.emit = (\n targetSourceFile?: TTypescript.SourceFile,\n writeFile?: TTypescript.WriteFileCallback,\n cancellationToken?: TTypescript.CancellationToken,\n emitOnlyDtsFiles?: boolean,\n customTransformers?: TTypescript.CustomTransformers\n ) => {\n if (emitOnlyDtsFiles) {\n return program[INNER_EMIT_SYMBOL]!(\n targetSourceFile,\n writeFile,\n cancellationToken,\n emitOnlyDtsFiles,\n customTransformers\n );\n }\n\n if (targetSourceFile && changedFiles) {\n changedFiles.add(targetSourceFile);\n }\n\n const originalCompilerOptions: TTypescript.CompilerOptions =\n program[INNER_GET_COMPILER_OPTIONS_SYMBOL]!();\n\n let defaultModuleKindResult: TTypescript.EmitResult;\n const diagnostics: TTypescript.Diagnostic[] = [];\n let emitSkipped: boolean = false;\n try {\n for (const [moduleKindToEmit, kindCompilerOptions] of multiEmitMap) {\n program.getCompilerOptions = () => kindCompilerOptions;\n // Need to mutate the compiler options for the `module` field specifically, because emitWorker() captures\n // options in the closure and passes it to `ts.getTransformers()`\n originalCompilerOptions.module = moduleKindToEmit.moduleKind;\n const flavorResult: TTypescript.EmitResult = program[INNER_EMIT_SYMBOL]!(\n targetSourceFile,\n writeFile && wrapWriteFile(writeFile, moduleKindToEmit.jsExtensionOverride),\n cancellationToken,\n emitOnlyDtsFiles,\n customTransformers\n );\n\n emitSkipped = emitSkipped || flavorResult.emitSkipped;\n // Need to aggregate diagnostics because some are impacted by the target module type\n for (const diagnostic of flavorResult.diagnostics) {\n diagnostics.push(diagnostic);\n }\n\n if (moduleKindToEmit.moduleKind === defaultModuleKind) {\n defaultModuleKindResult = flavorResult;\n }\n }\n\n const mergedDiagnostics: readonly TTypescript.Diagnostic[] =\n ts.sortAndDeduplicateDiagnostics(diagnostics);\n\n return {\n ...defaultModuleKindResult!,\n changedSourceFiles: changedFiles,\n diagnostics: mergedDiagnostics,\n emitSkipped\n };\n } finally {\n // Restore the original compiler options and module kind for future calls\n program.getCompilerOptions = program[INNER_GET_COMPILER_OPTIONS_SYMBOL]!;\n originalCompilerOptions.module = defaultModuleKind;\n }\n };\n return { changedFiles };\n }\n\n public _runWatch(tool: ITypeScriptTool): void {\n const { ts, measureSync: measureTsPerformance, pendingOperations, rawDiagnostics } = tool;\n\n if (!tool.solutionBuilder && !tool.watchProgram) {\n //#region CONFIGURE\n const { duration: configureDurationMs, tsconfig } = measureTsPerformance('Configure', () => {\n const _tsconfig: TTypescript.ParsedCommandLine = this._loadTsconfig(ts);\n this._validateTsconfig(ts, _tsconfig);\n\n return {\n tsconfig: _tsconfig\n };\n });\n this._typescriptTerminal.writeVerboseLine(`Configure: ${configureDurationMs}ms`);\n //#endregion\n\n if (this._useSolutionBuilder) {\n const solutionHost: TWatchSolutionHost = this._buildWatchSolutionBuilderHost(tool);\n const builder: TTypescript.SolutionBuilder<TTypescript.EmitAndSemanticDiagnosticsBuilderProgram> =\n ts.createSolutionBuilderWithWatch(solutionHost, [this._configuration.tsconfigPath], {});\n\n tool.solutionBuilder = builder as IExtendedSolutionBuilder;\n\n builder.build();\n } else {\n const compilerHost: TWatchCompilerHost = this._buildWatchCompilerHost(tool, tsconfig);\n tool.watchProgram = ts.createWatchProgram(compilerHost);\n }\n }\n\n if (pendingOperations.size > 0) {\n rawDiagnostics.length = 0;\n tool.executing = true;\n for (const operation of pendingOperations) {\n pendingOperations.delete(operation);\n operation();\n }\n tool.executing = false;\n }\n this._logDiagnostics(ts, rawDiagnostics);\n }\n\n public async _runBuildAsync(tool: ITypeScriptTool): Promise<void> {\n const { ts, measureSync: measureTsPerformance, measureAsync: measureTsPerformanceAsync } = tool;\n\n //#region CONFIGURE\n const {\n duration: configureDurationMs,\n tsconfig,\n compilerHost\n } = measureTsPerformance('Configure', () => {\n const _tsconfig: TTypescript.ParsedCommandLine = this._loadTsconfig(ts);\n this._validateTsconfig(ts, _tsconfig);\n\n const _compilerHost: TTypescript.CompilerHost = this._buildIncrementalCompilerHost(tool, _tsconfig);\n\n return {\n tsconfig: _tsconfig,\n compilerHost: _compilerHost\n };\n });\n this._typescriptTerminal.writeVerboseLine(`Configure: ${configureDurationMs}ms`);\n //#endregion\n\n //#region PROGRAM\n // There will be only one program here; emit will get a bit abused if we produce multiple outputs\n let builderProgram: TTypescript.BuilderProgram | undefined = undefined;\n let innerProgram: TTypescript.Program;\n\n if (tsconfig.options.incremental) {\n builderProgram = this._getCreateBuilderProgram(ts)(\n tsconfig.fileNames,\n tsconfig.options,\n compilerHost,\n ts.readBuilderProgram(tsconfig.options, compilerHost),\n ts.getConfigFileParsingDiagnostics(tsconfig),\n tsconfig.projectReferences\n );\n innerProgram = builderProgram.getProgram();\n } else {\n innerProgram = ts.createProgram({\n rootNames: tsconfig.fileNames,\n options: tsconfig.options,\n projectReferences: tsconfig.projectReferences,\n host: compilerHost,\n oldProgram: undefined,\n configFileParsingDiagnostics: ts.getConfigFileParsingDiagnostics(tsconfig)\n });\n }\n\n // Prefer the builder program, since it is what gives us incremental builds\n const genericProgram: TTypescript.BuilderProgram | TTypescript.Program = builderProgram || innerProgram;\n\n this._logReadPerformance(ts);\n //#endregion\n\n //#region ANALYSIS\n const { duration: diagnosticsDurationMs, diagnostics: preDiagnostics } = measureTsPerformance(\n 'Analyze',\n () => {\n const rawDiagnostics: TTypescript.Diagnostic[] = [\n ...genericProgram.getConfigFileParsingDiagnostics(),\n ...genericProgram.getOptionsDiagnostics(),\n ...genericProgram.getSyntacticDiagnostics(),\n ...genericProgram.getGlobalDiagnostics(),\n ...genericProgram.getSemanticDiagnostics()\n ];\n return { diagnostics: rawDiagnostics };\n }\n );\n this._typescriptTerminal.writeVerboseLine(`Analyze: ${diagnosticsDurationMs}ms`);\n //#endregion\n\n //#region EMIT\n const filesToWrite: IFileToWrite[] = [];\n\n const writeFileCallback: TTypescript.WriteFileCallback = (filePath: string, data: string) => {\n filesToWrite.push({ filePath, data });\n };\n\n const { changedFiles } = this._configureProgramForMultiEmit(innerProgram, ts);\n\n const emitResult: TTypescript.EmitResult = genericProgram.emit(undefined, writeFileCallback);\n //#endregion\n\n this._logEmitPerformance(ts);\n\n //#region FINAL_ANALYSIS\n // Need to ensure that we include emit diagnostics, since they might not be part of the other sets\n const rawDiagnostics: TTypescript.Diagnostic[] = [...preDiagnostics, ...emitResult.diagnostics];\n //#endregion\n\n //#region WRITE\n // Using async file system I/O for theoretically better peak performance\n // Also allows to run concurrently with linting\n const writePromise: Promise<{ duration: number }> = measureTsPerformanceAsync('Write', () =>\n Async.forEachAsync(\n filesToWrite,\n async ({ filePath, data }: { filePath: string; data: string }) =>\n this._cachedFileSystem.writeFile(filePath, data, { ensureFolderExists: true }),\n { concurrency: this._configuration.maxWriteParallelism }\n )\n );\n //#endregion\n\n const { duration: writeDuration } = await writePromise;\n this._typescriptTerminal.writeVerboseLine(`I/O Write: ${writeDuration}ms (${filesToWrite.length} files)`);\n\n this._logDiagnostics(ts, rawDiagnostics);\n // Reset performance counters in case any are used in the callback\n ts.performance.disable();\n ts.performance.enable();\n this._configuration.emitChangedFilesCallback(innerProgram, changedFiles);\n }\n\n public _runSolutionBuild(tool: ITypeScriptTool): void {\n this._typescriptTerminal.writeVerboseLine(`Using solution mode`);\n\n const { ts, measureSync, rawDiagnostics } = tool;\n rawDiagnostics.length = 0;\n\n if (!tool.solutionBuilder) {\n //#region CONFIGURE\n const { duration: configureDurationMs, solutionBuilderHost } = measureSync('Configure', () => {\n const _tsconfig: TTypescript.ParsedCommandLine = this._loadTsconfig(ts);\n this._validateTsconfig(ts, _tsconfig);\n\n const _solutionBuilderHost: TSolutionHost = this._buildSolutionBuilderHost(tool);\n\n return {\n solutionBuilderHost: _solutionBuilderHost\n };\n });\n this._typescriptTerminal.writeVerboseLine(`Configure: ${configureDurationMs}ms`);\n //#endregion\n\n tool.solutionBuilder = ts.createSolutionBuilder(\n solutionBuilderHost,\n [this._configuration.tsconfigPath],\n {}\n ) as IExtendedSolutionBuilder;\n } else {\n // Force reload everything from disk\n for (const project of tool.solutionBuilder.getBuildOrder()) {\n tool.solutionBuilder.invalidateProject(project, 1);\n }\n }\n\n //#region EMIT\n // Ignoring the exit status because we only care about presence of diagnostics\n tool.solutionBuilder.build();\n //#endregion\n\n this._logDiagnostics(ts, rawDiagnostics);\n }\n\n private _logDiagnostics(ts: ExtendedTypeScript, rawDiagnostics: TTypescript.Diagnostic[]): void {\n const diagnostics: readonly TTypescript.Diagnostic[] = ts.sortAndDeduplicateDiagnostics(rawDiagnostics);\n\n if (diagnostics.length > 0) {\n this._typescriptTerminal.writeLine(\n `Encountered ${diagnostics.length} TypeScript issue${diagnostics.length > 1 ? 's' : ''}:`\n );\n for (const diagnostic of diagnostics) {\n const diagnosticCategory: TTypescript.DiagnosticCategory = this._getAdjustedDiagnosticCategory(\n diagnostic,\n ts\n );\n\n this._printDiagnosticMessage(ts, diagnostic, diagnosticCategory);\n }\n }\n }\n\n private _logEmitPerformance(ts: ExtendedTypeScript): void {\n this._typescriptTerminal.writeVerboseLine(`Bind: ${ts.performance.getDuration('Bind')}ms`);\n this._typescriptTerminal.writeVerboseLine(`Check: ${ts.performance.getDuration('Check')}ms`);\n this._typescriptTerminal.writeVerboseLine(\n `Transform: ${ts.performance.getDuration('transformTime')}ms ` +\n `(${ts.performance.getCount('beforeTransform')} files)`\n );\n this._typescriptTerminal.writeVerboseLine(\n `Print: ${ts.performance.getDuration('printTime')}ms ` +\n `(${ts.performance.getCount('beforePrint')} files) (Includes Transform)`\n );\n this._typescriptTerminal.writeVerboseLine(\n `Emit: ${ts.performance.getDuration('Emit')}ms (Includes Print)`\n );\n }\n\n private _logReadPerformance(ts: ExtendedTypeScript): void {\n this._typescriptTerminal.writeVerboseLine(\n `I/O Read: ${ts.performance.getDuration('I/O Read')}ms (${ts.performance.getCount(\n 'beforeIORead'\n )} files)`\n );\n this._typescriptTerminal.writeVerboseLine(\n `Parse: ${ts.performance.getDuration('Parse')}ms (${ts.performance.getCount('beforeParse')} files)`\n );\n this._typescriptTerminal.writeVerboseLine(\n `Program (includes Read + Parse): ${ts.performance.getDuration('Program')}ms`\n );\n }\n\n private _printDiagnosticMessage(\n ts: ExtendedTypeScript,\n diagnostic: TTypescript.Diagnostic,\n diagnosticCategory: TTypescript.DiagnosticCategory = this._getAdjustedDiagnosticCategory(diagnostic, ts)\n ): void {\n // Code taken from reference example\n let diagnosticMessage: string;\n let errorObject: Error;\n if (diagnostic.file) {\n const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start!);\n const message: string = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\\n');\n const formattedMessage: string = `(TS${diagnostic.code}) ${message}`;\n errorObject = new FileError(formattedMessage, {\n absolutePath: diagnostic.file.fileName,\n projectFolder: this._configuration.buildFolderPath,\n line: line + 1,\n column: character + 1\n });\n diagnosticMessage = errorObject.toString();\n } else {\n diagnosticMessage = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\\n');\n errorObject = new Error(diagnosticMessage);\n }\n\n switch (diagnosticCategory) {\n case ts.DiagnosticCategory.Error: {\n this._typescriptLogger.emitError(errorObject);\n break;\n }\n\n case ts.DiagnosticCategory.Warning: {\n this._typescriptLogger.emitWarning(errorObject);\n break;\n }\n\n default: {\n this._typescriptTerminal.writeLine(...diagnosticMessage);\n break;\n }\n }\n }\n\n private _getAdjustedDiagnosticCategory(\n diagnostic: TTypescript.Diagnostic,\n ts: ExtendedTypeScript\n ): TTypescript.DiagnosticCategory {\n // Workaround for https://github.com/microsoft/TypeScript/issues/40058\n // The compiler reports a hard error for issues such as this:\n //\n // error TS6133: 'x' is declared but its value is never read.\n //\n // These should properly be treated as warnings, because they are purely cosmetic issues.\n // TODO: Maybe heft should provide a config file for managing DiagnosticCategory mappings.\n if (diagnostic.reportsUnnecessary && diagnostic.category === ts.DiagnosticCategory.Error) {\n return ts.DiagnosticCategory.Warning;\n }\n\n // These pedantic checks also should not be treated as hard errors\n if (this._suppressedDiagnosticCodes.has(diagnostic.code)) {\n return ts.DiagnosticCategory.Warning;\n }\n\n return diagnostic.category;\n }\n\n private _validateTsconfig(ts: ExtendedTypeScript, tsconfig: TTypescript.ParsedCommandLine): void {\n if (\n (tsconfig.options.module && !tsconfig.options.outDir) ||\n (!tsconfig.options.module && tsconfig.options.outDir)\n ) {\n throw new Error(\n 'If either the module or the outDir option is provided in the tsconfig compilerOptions, both must be provided'\n );\n }\n\n this._moduleKindsToEmit = [];\n const specifiedKinds: Map<TTypescript.ModuleKind, IModuleKindReason> = new Map();\n const specifiedOutDirs: Map<string, IModuleKindReason> = new Map();\n\n if (!tsconfig.options.module) {\n throw new Error(\n 'If the module tsconfig compilerOption is not provided, the builder must be provided with the ' +\n 'additionalModuleKindsToEmit configuration option.'\n );\n }\n\n if (this._configuration.emitCjsExtensionForCommonJS) {\n this._addModuleKindToEmit(\n ts.ModuleKind.CommonJS,\n tsconfig.options.outDir!,\n /* isPrimary */ tsconfig.options.module === ts.ModuleKind.CommonJS,\n '.cjs'\n );\n\n const cjsReason: IModuleKindReason = {\n outDir: tsconfig.options.outDir!,\n kind: 'CommonJS',\n extension: '.cjs',\n reason: 'emitCjsExtensionForCommonJS'\n };\n\n specifiedKinds.set(ts.ModuleKind.CommonJS, cjsReason);\n specifiedOutDirs.set(`${tsconfig.options.outDir!}:.cjs`, cjsReason);\n }\n\n if (this._configuration.emitMjsExtensionForESModule) {\n this._addModuleKindToEmit(\n ts.ModuleKind.ESNext,\n tsconfig.options.outDir!,\n /* isPrimary */ tsconfig.options.module === ts.ModuleKind.ESNext,\n '.mjs'\n );\n\n const mjsReason: IModuleKindReason = {\n outDir: tsconfig.options.outDir!,\n kind: 'ESNext',\n extension: '.mjs',\n reason: 'emitMjsExtensionForESModule'\n };\n\n specifiedKinds.set(ts.ModuleKind.ESNext, mjsReason);\n specifiedOutDirs.set(`${tsconfig.options.outDir!}:.mjs`, mjsReason);\n }\n\n if (!specifiedKinds.has(tsconfig.options.module)) {\n this._addModuleKindToEmit(\n tsconfig.options.module,\n tsconfig.options.outDir!,\n /* isPrimary */ true,\n /* jsExtensionOverride */ undefined\n );\n\n const tsConfigReason: IModuleKindReason = {\n outDir: tsconfig.options.outDir!,\n kind: ts.ModuleKind[tsconfig.options.module] as keyof typeof TTypescript.ModuleKind,\n extension: '.js',\n reason: 'tsconfig.json'\n };\n\n specifiedKinds.set(tsconfig.options.module, tsConfigReason);\n specifiedOutDirs.set(`${tsconfig.options.outDir!}:.js`, tsConfigReason);\n }\n\n if (this._configuration.additionalModuleKindsToEmit) {\n for (const additionalModuleKindToEmit of this._configuration.additionalModuleKindsToEmit) {\n const moduleKind: TTypescript.ModuleKind = this._parseModuleKind(\n ts,\n additionalModuleKindToEmit.moduleKind\n );\n\n const outDirKey: string = `${additionalModuleKindToEmit.outFolderName}:.js`;\n const moduleKindReason: IModuleKindReason = {\n kind: ts.ModuleKind[moduleKind] as keyof typeof TTypescript.ModuleKind,\n outDir: additionalModuleKindToEmit.outFolderName,\n extension: '.js',\n reason: `additionalModuleKindsToEmit`\n };\n\n const existingKind: IModuleKindReason | undefined = specifiedKinds.get(moduleKind);\n const existingDir: IModuleKindReason | undefined = specifiedOutDirs.get(outDirKey);\n\n if (existingKind) {\n throw new Error(\n `Module kind \"${additionalModuleKindToEmit.moduleKind}\" is already emitted at ${existingKind.outDir} with extension '${existingKind.extension}' by option ${existingKind.reason}.`\n );\n } else if (existingDir) {\n throw new Error(\n `Output folder \"${additionalModuleKindToEmit.outFolderName}\" already contains module kind ${existingDir.kind} with extension '${existingDir.extension}', specified by option ${existingDir.reason}.`\n );\n } else {\n const outFolderKey: string | undefined = this._addModuleKindToEmit(\n moduleKind,\n additionalModuleKindToEmit.outFolderName,\n /* isPrimary */ false,\n undefined\n );\n\n if (outFolderKey) {\n specifiedKinds.set(moduleKind, moduleKindReason);\n specifiedOutDirs.set(outFolderKey, moduleKindReason);\n }\n }\n }\n }\n }\n\n private _addModuleKindToEmit(\n moduleKind: TTypescript.ModuleKind,\n outFolderPath: string,\n isPrimary: boolean,\n jsExtensionOverride: string | undefined\n ): string | undefined {\n let outFolderName: string;\n if (path.isAbsolute(outFolderPath)) {\n outFolderName = path.relative(this._configuration.buildFolderPath, outFolderPath);\n } else {\n outFolderName = outFolderPath;\n outFolderPath = path.resolve(this._configuration.buildFolderPath, outFolderPath);\n }\n\n outFolderPath = Path.convertToSlashes(outFolderPath);\n outFolderPath = outFolderPath.replace(/\\/*$/, '/'); // Ensure the outFolderPath ends with a slash\n\n for (const existingModuleKindToEmit of this._moduleKindsToEmit) {\n let errorText: string | undefined;\n\n if (existingModuleKindToEmit.outFolderPath === outFolderPath) {\n if (existingModuleKindToEmit.jsExtensionOverride === jsExtensionOverride) {\n errorText =\n 'Unable to output two different module kinds with the same ' +\n `module extension (${jsExtensionOverride || '.js'}) to the same ` +\n `folder (\"${outFolderPath}\").`;\n }\n } else {\n let parentFolder: string | undefined;\n let childFolder: string | undefined;\n if (outFolderPath.startsWith(existingModuleKindToEmit.outFolderPath)) {\n parentFolder = outFolderPath;\n childFolder = existingModuleKindToEmit.outFolderPath;\n } else if (existingModuleKindToEmit.outFolderPath.startsWith(outFolderPath)) {\n parentFolder = existingModuleKindToEmit.outFolderPath;\n childFolder = outFolderPath;\n }\n\n if (parentFolder) {\n errorText =\n 'Unable to output two different module kinds to nested folders ' +\n `(\"${parentFolder}\" and \"${childFolder}\").`;\n }\n }\n\n if (errorText) {\n this._typescriptLogger.emitError(new Error(errorText));\n return undefined;\n }\n }\n\n this._moduleKindsToEmit.push({\n outFolderPath,\n moduleKind,\n jsExtensionOverride,\n\n isPrimary\n });\n\n return `${outFolderName}:${jsExtensionOverride || '.js'}`;\n }\n\n private _loadTsconfig(ts: ExtendedTypeScript): TTypescript.ParsedCommandLine {\n const parsedConfigFile: ReturnType<typeof ts.readConfigFile> = ts.readConfigFile(\n this._configuration.tsconfigPath,\n this._cachedFileSystem.readFile\n );\n\n const currentFolder: string = path.dirname(this._configuration.tsconfigPath);\n const tsconfig: TTypescript.ParsedCommandLine = ts.parseJsonConfigFileContent(\n parsedConfigFile.config,\n {\n fileExists: this._cachedFileSystem.exists,\n readFile: this._cachedFileSystem.readFile,\n readDirectory: (\n folderPath: string,\n extensions?: ReadonlyArray<string>,\n excludes?: ReadonlyArray<string>,\n includes?: ReadonlyArray<string>,\n depth?: number\n ) =>\n ts.matchFiles(\n folderPath,\n extensions,\n excludes,\n includes,\n /* useCaseSensitiveFileNames */ true,\n currentFolder,\n depth,\n this._cachedFileSystem.readFolderFilesAndDirectories.bind(this._cachedFileSystem),\n this._cachedFileSystem.getRealPath.bind(this._cachedFileSystem),\n this._cachedFileSystem.directoryExists.bind(this._cachedFileSystem)\n ),\n useCaseSensitiveFileNames: true\n },\n currentFolder,\n /*existingOptions:*/ undefined,\n this._configuration.tsconfigPath\n );\n\n if (tsconfig.options.incremental) {\n tsconfig.options.tsBuildInfoFile = this._tsCacheFilePath;\n }\n\n return tsconfig;\n }\n\n private _getCreateBuilderProgram(\n ts: ExtendedTypeScript\n ): TTypescript.CreateProgram<TTypescript.EmitAndSemanticDiagnosticsBuilderProgram> {\n const {\n _configuration: { emitChangedFilesCallback }\n } = this;\n\n const createMultiEmitBuilderProgram: TTypescript.CreateProgram<\n TTypescript.EmitAndSemanticDiagnosticsBuilderProgram\n > = (\n fileNames: readonly string[] | undefined,\n compilerOptions: TTypescript.CompilerOptions | undefined,\n host: TTypescript.CompilerHost | undefined,\n oldProgram: TTypescript.EmitAndSemanticDiagnosticsBuilderProgram | undefined,\n configFileParsingDiagnostics: readonly TTypescript.Diagnostic[] | undefined,\n projectReferences: readonly TTypescript.ProjectReference[] | undefined\n ): TTypescript.EmitAndSemanticDiagnosticsBuilderProgram => {\n // Reset performance counters\n ts.performance.disable();\n ts.performance.enable();\n\n this._typescriptTerminal.writeVerboseLine(`Reading program \"${compilerOptions!.configFilePath}\"`);\n\n const newProgram: TTypescript.EmitAndSemanticDiagnosticsBuilderProgram =\n ts.createEmitAndSemanticDiagnosticsBuilderProgram(\n fileNames,\n compilerOptions,\n host,\n oldProgram,\n configFileParsingDiagnostics,\n projectReferences\n );\n\n this._logReadPerformance(ts);\n\n const { emit: originalEmit } = newProgram;\n\n const emit: TTypescript.Program['emit'] = (\n outerTargetSourceFile?: TTypescript.SourceFile,\n outerWriteFile?: TTypescript.WriteFileCallback,\n outerCancellationToken?: TTypescript.CancellationToken,\n outerEmitOnlyDtsFiles?: boolean,\n outerCustomTransformers?: TTypescript.CustomTransformers\n ) => {\n const innerProgram: TTypescript.Program = newProgram.getProgram();\n\n const innerCompilerOptions: TTypescript.CompilerOptions = innerProgram.getCompilerOptions();\n\n const { changedFiles } = this._configureProgramForMultiEmit(innerProgram, ts);\n\n const result: TTypescript.EmitResult = originalEmit.call(\n newProgram,\n outerTargetSourceFile,\n outerWriteFile,\n outerCancellationToken,\n outerEmitOnlyDtsFiles,\n outerCustomTransformers\n );\n\n (result as IExtendedEmitResult).changedSourceFiles = changedFiles;\n\n this._typescriptTerminal.writeVerboseLine(\n `Emitting program \"${innerCompilerOptions!.configFilePath}\"`\n );\n\n this._logEmitPerformance(ts);\n\n // Reset performance counters\n ts.performance.disable();\n ts.performance.enable();\n\n emitChangedFilesCallback(innerProgram, changedFiles);\n\n return result;\n };\n\n newProgram.emit = emit;\n\n return newProgram;\n };\n\n return createMultiEmitBuilderProgram;\n }\n\n private _buildSolutionBuilderHost(tool: ITypeScriptTool): TSolutionHost {\n const reportSolutionBuilderStatus: TTypescript.DiagnosticReporter = tool.reportDiagnostic;\n const reportEmitErrorSummary: TTypescript.ReportEmitErrorSummary = (errorCount: number): void => {\n // Do nothing\n };\n\n const { ts } = tool;\n\n const solutionBuilderHost: TTypescript.SolutionBuilderHost<TTypescript.EmitAndSemanticDiagnosticsBuilderProgram> =\n ts.createSolutionBuilderHost(\n ts.sys,\n this._getCreateBuilderProgram(ts),\n tool.reportDiagnostic,\n reportSolutionBuilderStatus,\n reportEmitErrorSummary\n );\n\n solutionBuilderHost.afterProgramEmitAndDiagnostics = (\n program: TTypescript.EmitAndSemanticDiagnosticsBuilderProgram\n ) => {\n // Use the native metric since we aren't overwriting the writer\n this._typescriptTerminal.writeVerboseLine(\n `I/O Write: ${ts.performance.getDuration('I/O Write')}ms (${ts.performance.getCount(\n 'beforeIOWrite'\n )} files)`\n );\n };\n\n return solutionBuilderHost;\n }\n\n private _buildIncrementalCompilerHost(\n tool: ITypeScriptTool,\n tsconfig: TTypescript.ParsedCommandLine\n ): TTypescript.CompilerHost {\n const { ts } = tool;\n\n let compilerHost: TTypescript.CompilerHost | undefined;\n\n if (tsconfig.options.incremental) {\n compilerHost = ts.createIncrementalCompilerHost(tsconfig.options, ts.sys);\n } else {\n compilerHost = ts.createCompilerHost(tsconfig.options);\n }\n\n this._changeCompilerHostToUseCache(compilerHost, tool);\n\n return compilerHost;\n }\n\n private _buildWatchCompilerHost(\n tool: ITypeScriptTool,\n tsconfig: TTypescript.ParsedCommandLine\n ): TWatchCompilerHost {\n const { ts } = tool;\n\n const reportWatchStatus: TTypescript.DiagnosticReporter = (diagnostic: TTypescript.Diagnostic): void => {\n this._printDiagnosticMessage(ts, diagnostic);\n };\n\n const compilerHost: TWatchCompilerHost = ts.createWatchCompilerHost(\n tsconfig.fileNames,\n tsconfig.options,\n ts.sys,\n this._getCreateBuilderProgram(ts),\n tool.reportDiagnostic,\n reportWatchStatus,\n tsconfig.projectReferences\n );\n\n compilerHost.clearTimeout = tool.clearTimeout;\n compilerHost.setTimeout = tool.setTimeout;\n\n return compilerHost;\n }\n\n private _changeCompilerHostToUseCache(compilerHost: TTypescript.CompilerHost, tool: ITypeScriptTool): void {\n const { sourceFileCache } = tool;\n\n const { getSourceFile: innerGetSourceFile } = compilerHost;\n if ((innerGetSourceFile as { cache?: typeof sourceFileCache }).cache === sourceFileCache) {\n return;\n }\n\n // Enable source file persistence\n const getSourceFile: typeof innerGetSourceFile & {\n cache?: typeof sourceFileCache;\n } = (\n fileName: string,\n languageVersionOrOptions: TTypescript.ScriptTarget | TTypescript.CreateSourceFileOptions,\n onError?: ((message: string) => void) | undefined,\n shouldCreateNewSourceFile?: boolean | undefined\n ): TTypescript.SourceFile | undefined => {\n if (!shouldCreateNewSourceFile) {\n const cachedSourceFile: TTypescript.SourceFile | undefined = sourceFileCache.get(fileName);\n if (cachedSourceFile) {\n return cachedSourceFile;\n }\n }\n\n const result: TTypescript.SourceFile | undefined = innerGetSourceFile(\n fileName,\n languageVersionOrOptions,\n onError,\n shouldCreateNewSourceFile\n );\n if (result) {\n sourceFileCache.set(fileName, result);\n } else {\n sourceFileCache.delete(fileName);\n }\n return result;\n };\n\n getSourceFile.cache = sourceFileCache;\n\n compilerHost.getSourceFile = getSourceFile;\n }\n\n private _buildWatchSolutionBuilderHost(tool: ITypeScriptTool): TWatchSolutionHost {\n const { reportDiagnostic, ts } = tool;\n\n const host: TWatchSolutionHost = ts.createSolutionBuilderWithWatchHost(\n ts.sys,\n this._getCreateBuilderProgram(ts),\n reportDiagnostic,\n reportDiagnostic,\n reportDiagnostic\n );\n\n host.clearTimeout = tool.clearTimeout;\n host.setTimeout = tool.setTimeout;\n\n return host;\n }\n\n private _parseModuleKind(ts: ExtendedTypeScript, moduleKindName: string): TTypescript.ModuleKind {\n switch (moduleKindName.toLowerCase()) {\n case 'commonjs':\n return ts.ModuleKind.CommonJS;\n\n case 'amd':\n return ts.ModuleKind.AMD;\n\n case 'umd':\n return ts.ModuleKind.UMD;\n\n case 'system':\n return ts.ModuleKind.System;\n\n case 'es2015':\n return ts.ModuleKind.ES2015;\n\n case 'esnext':\n return ts.ModuleKind.ESNext;\n\n default:\n throw new Error(`\"${moduleKindName}\" is not a valid module kind name.`);\n }\n }\n}\n\nconst JS_EXTENSION_REGEX: RegExp = /\\.js(\\.map)?$/;\n\nfunction wrapWriteFile(\n baseWriteFile: TTypescript.WriteFileCallback,\n jsExtensionOverride: string | undefined\n): TTypescript.WriteFileCallback {\n if (!jsExtensionOverride) {\n return baseWriteFile;\n }\n\n const replacementExtension: string = `${jsExtensionOverride}$1`;\n return (\n fileName: string,\n data: string,\n writeBOM: boolean,\n onError?: ((message: string) => void) | undefined,\n sourceFiles?: readonly TTypescript.SourceFile[] | undefined\n ) => {\n return baseWriteFile(\n fileName.replace(JS_EXTENSION_REGEX, replacementExtension),\n data,\n writeBOM,\n onError,\n sourceFiles\n );\n };\n}\n"]}
|
|
@@ -1,35 +1,8 @@
|
|
|
1
1
|
import type * as TTypescript from 'typescript';
|
|
2
|
-
/**
|
|
3
|
-
* https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/types.ts#L3969-L4010
|
|
4
|
-
*/
|
|
5
|
-
export interface IEmitResolver {
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/types.ts#L5969-L5988
|
|
9
|
-
*/
|
|
10
|
-
export interface IEmitHost {
|
|
11
|
-
writeFile: TTypescript.WriteFileCallback;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/types.ts#L3338-L3341
|
|
15
|
-
*/
|
|
16
|
-
export interface IEmitTransformers {
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/utilities.ts#L3799-L3803
|
|
20
|
-
*/
|
|
21
|
-
export interface IResolveModuleNameResolutionHost {
|
|
22
|
-
getCanonicalFileName(p: string): string;
|
|
23
|
-
getCommonSourceDirectory(): string;
|
|
24
|
-
getCurrentDirectory(): string;
|
|
25
|
-
}
|
|
26
2
|
export interface IExtendedSolutionBuilder extends TTypescript.SolutionBuilder<TTypescript.EmitAndSemanticDiagnosticsBuilderProgram> {
|
|
27
3
|
getBuildOrder(): readonly string[];
|
|
28
4
|
invalidateProject(configFilePath: string, mode: 0 | 1 | 2): void;
|
|
29
5
|
}
|
|
30
|
-
/**
|
|
31
|
-
* @beta
|
|
32
|
-
*/
|
|
33
6
|
export interface IExtendedTypeScript {
|
|
34
7
|
/**
|
|
35
8
|
* https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/performance.ts#L3
|
|
@@ -60,10 +33,6 @@ export interface IExtendedTypeScript {
|
|
|
60
33
|
*/
|
|
61
34
|
getCount(measureName: string): number;
|
|
62
35
|
};
|
|
63
|
-
/**
|
|
64
|
-
* https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/utilities.ts#L4720-L4734
|
|
65
|
-
*/
|
|
66
|
-
readJson(filePath: string): object;
|
|
67
36
|
/**
|
|
68
37
|
* https://github.com/microsoft/TypeScript/blob/782c09d783e006a697b4ba6d1e7ec2f718ce8393/src/compiler/utilities.ts#L6540
|
|
69
38
|
*/
|
|
@@ -71,22 +40,6 @@ export interface IExtendedTypeScript {
|
|
|
71
40
|
readonly files: ReadonlyArray<string>;
|
|
72
41
|
readonly directories: ReadonlyArray<string>;
|
|
73
42
|
}, realpath: (path: string) => string, directoryExists: (path: string) => boolean): string[];
|
|
74
|
-
/**
|
|
75
|
-
* https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/emitter.ts#L261-L614
|
|
76
|
-
*/
|
|
77
|
-
emitFiles(resolver: IEmitResolver, host: IEmitHost, targetSourceFile: TTypescript.SourceFile | undefined, emitTransformers: IEmitTransformers, emitOnlyDtsFiles?: boolean, onlyBuildInfo?: boolean, forceDtsEmit?: boolean): TTypescript.EmitResult;
|
|
78
|
-
/**
|
|
79
|
-
* https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/transformer.ts#L30-L35
|
|
80
|
-
*/
|
|
81
|
-
getTransformers(compilerOptions: TTypescript.CompilerOptions, customTransformers?: TTypescript.CustomTransformers, emitOnlyDtsFiles?: boolean): IEmitTransformers;
|
|
82
|
-
/**
|
|
83
|
-
* https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/utilities.ts#L6100-L6108
|
|
84
|
-
*/
|
|
85
|
-
removeFileExtension(path: string): string;
|
|
86
|
-
/**
|
|
87
|
-
* https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/utilities.ts#L3826-L3833
|
|
88
|
-
*/
|
|
89
|
-
getExternalModuleNameFromPath(host: IResolveModuleNameResolutionHost, fileName: string, referencePath?: string): string;
|
|
90
43
|
Diagnostics: {
|
|
91
44
|
Found_1_error_Watching_for_file_changes: TTypescript.DiagnosticMessage;
|
|
92
45
|
Found_0_errors_Watching_for_file_changes: TTypescript.DiagnosticMessage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeScriptInternals.d.ts","sourceRoot":"","sources":["../../src/internalTypings/TypeScriptInternals.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,WAAW,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"TypeScriptInternals.d.ts","sourceRoot":"","sources":["../../src/internalTypings/TypeScriptInternals.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,WAAW,MAAM,YAAY,CAAC;AAE/C,MAAM,WAAW,wBACf,SAAQ,WAAW,CAAC,eAAe,CAAC,WAAW,CAAC,wCAAwC,CAAC;IACzF,aAAa,IAAI,SAAS,MAAM,EAAE,CAAC;IACnC,iBAAiB,CAAC,cAAc,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;CAClE;AAED,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,WAAW,EAAE;QACX;;WAEG;QACH,OAAO,IAAI,IAAI,CAAC;QAEhB;;WAEG;QACH,MAAM,IAAI,IAAI,CAAC;QAEf;;WAEG;QACH,IAAI,CAAC,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;QAErC;;WAEG;QACH,OAAO,CAAC,WAAW,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAEjF;;WAEG;QACH,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC;QAEzC;;WAEG;QACH,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC;KACvC,CAAC;IAEF;;OAEG;IACH,UAAU,CACR,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,SAAS,EAC7C,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,SAAS,EAC3C,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,SAAS,EAC3C,yBAAyB,EAAE,OAAO,EAClC,gBAAgB,EAAE,MAAM,EACxB,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,oBAAoB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK;QACtC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;QACtC,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;KAC7C,EACD,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,EAClC,eAAe,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,GACzC,MAAM,EAAE,CAAC;IAEZ,WAAW,EAAE;QAGX,uCAAuC,EAAE,WAAW,CAAC,iBAAiB,CAAC;QAIvE,wCAAwC,EAAE,WAAW,CAAC,iBAAiB,CAAC;QAIxE,+EAA+E,EAAE,WAAW,CAAC,iBAAiB,CAAC;QAI/G,6FAA6F,EAAE,WAAW,CAAC,iBAAiB,CAAC;KAC9H,CAAC;CACH;AAED,oBAAY,kBAAkB,GAAG,OAAO,WAAW,GAAG,mBAAmB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeScriptInternals.js","sourceRoot":"","sources":["../../src/internalTypings/TypeScriptInternals.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type * as TTypescript from 'typescript';\n\
|
|
1
|
+
{"version":3,"file":"TypeScriptInternals.js","sourceRoot":"","sources":["../../src/internalTypings/TypeScriptInternals.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type * as TTypescript from 'typescript';\n\nexport interface IExtendedSolutionBuilder\n extends TTypescript.SolutionBuilder<TTypescript.EmitAndSemanticDiagnosticsBuilderProgram> {\n getBuildOrder(): readonly string[];\n invalidateProject(configFilePath: string, mode: 0 | 1 | 2): void;\n}\n\nexport interface IExtendedTypeScript {\n /**\n * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/performance.ts#L3\n */\n performance: {\n /**\n * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/performance.ts#L119-L121\n */\n disable(): void;\n\n /**\n * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/performance.ts#L110-L116\n */\n enable(): void;\n\n /**\n * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/performance.ts#L55-L61\n */\n mark(performanceMaker: string): void;\n\n /**\n * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/performance.ts#L72-L78\n */\n measure(measureName: string, startMarkName?: string, endMarkName?: string): void;\n\n /**\n * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/performance.ts#L94-L96\n */\n getDuration(measureName: string): number;\n\n /**\n * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/performance.ts#L85-L87\n */\n getCount(measureName: string): number;\n };\n\n /**\n * https://github.com/microsoft/TypeScript/blob/782c09d783e006a697b4ba6d1e7ec2f718ce8393/src/compiler/utilities.ts#L6540\n */\n matchFiles(\n path: string,\n extensions: ReadonlyArray<string> | undefined,\n excludes: ReadonlyArray<string> | undefined,\n includes: ReadonlyArray<string> | undefined,\n useCaseSensitiveFileNames: boolean,\n currentDirectory: string,\n depth: number | undefined,\n getFileSystemEntries: (path: string) => {\n readonly files: ReadonlyArray<string>;\n readonly directories: ReadonlyArray<string>;\n },\n realpath: (path: string) => string,\n directoryExists: (path: string) => boolean\n ): string[];\n\n Diagnostics: {\n // https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/diagnosticMessages.json#L4252-L4255\n // eslint-disable-next-line @typescript-eslint/naming-convention\n Found_1_error_Watching_for_file_changes: TTypescript.DiagnosticMessage;\n\n // https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/diagnosticMessages.json#L4256-L4259\n // eslint-disable-next-line @typescript-eslint/naming-convention\n Found_0_errors_Watching_for_file_changes: TTypescript.DiagnosticMessage;\n\n // https://github.com/microsoft/TypeScript/blob/2428ade1a91248e847f3e1561e31a9426650efee/src/compiler/diagnosticMessages.json#L2252\n // eslint-disable-next-line @typescript-eslint/naming-convention\n Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor: TTypescript.DiagnosticMessage;\n\n // https://github.com/microsoft/TypeScript/blob/2428ade1a91248e847f3e1561e31a9426650efee/src/compiler/diagnosticMessages.json#L4920\n // eslint-disable-next-line @typescript-eslint/naming-convention\n Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1: TTypescript.DiagnosticMessage;\n };\n}\n\nexport type ExtendedTypeScript = typeof TTypescript & IExtendedTypeScript;\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rushstack/heft-typescript-plugin",
|
|
3
|
-
"version": "0.1.0-rc.
|
|
3
|
+
"version": "0.1.0-rc.5",
|
|
4
4
|
"description": "Heft plugin for TypeScript",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -12,23 +12,23 @@
|
|
|
12
12
|
"types": "dist/heft-typescript-plugin.d.ts",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"@rushstack/heft": "0.50.0
|
|
15
|
+
"@rushstack/heft": "0.50.0"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@rushstack/node-core-library": "3.53.3",
|
|
19
|
-
"@rushstack/heft-config-file": "0.11.4",
|
|
20
18
|
"@types/tapable": "1.0.6",
|
|
21
19
|
"semver": "~7.3.0",
|
|
22
|
-
"tapable": "1.1.3"
|
|
20
|
+
"tapable": "1.1.3",
|
|
21
|
+
"@rushstack/node-core-library": "3.56.0",
|
|
22
|
+
"@rushstack/heft-config-file": "0.11.10"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@rushstack/
|
|
26
|
-
"@rushstack/heft": "
|
|
27
|
-
"@
|
|
28
|
-
"@rushstack/heft-node-rig": "1.11.0",
|
|
29
|
-
"@types/node": "12.20.24",
|
|
25
|
+
"@rushstack/heft-legacy": "npm:@rushstack/heft@0.50.0",
|
|
26
|
+
"@rushstack/heft-node-rig": "1.12.6",
|
|
27
|
+
"@types/node": "14.18.36",
|
|
30
28
|
"@types/semver": "7.3.5",
|
|
31
|
-
"typescript": "~4.8.4"
|
|
29
|
+
"typescript": "~4.8.4",
|
|
30
|
+
"@rushstack/eslint-config": "3.2.0",
|
|
31
|
+
"@rushstack/heft": "0.51.0-rc.5"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
34
|
"build": "node ./node_modules/@rushstack/heft-legacy/bin/heft --unmanaged build --clean",
|
package/lib/EmitFilesPatch.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type * as TTypescript from 'typescript';
|
|
2
|
-
import { ExtendedTypeScript } from './internalTypings/TypeScriptInternals';
|
|
3
|
-
export interface ICachedEmitModuleKind {
|
|
4
|
-
moduleKind: TTypescript.ModuleKind;
|
|
5
|
-
outFolderPath: string;
|
|
6
|
-
/**
|
|
7
|
-
* File extension to use instead of '.js' for emitted ECMAScript files.
|
|
8
|
-
* For example, '.cjs' to indicate commonjs content, or '.mjs' to indicate ECMAScript modules.
|
|
9
|
-
*/
|
|
10
|
-
jsExtensionOverride: string | undefined;
|
|
11
|
-
/**
|
|
12
|
-
* Set to true if this is the emit kind that is specified in the tsconfig.json.
|
|
13
|
-
* Declarations are only emitted for the primary module kind.
|
|
14
|
-
*/
|
|
15
|
-
isPrimary: boolean;
|
|
16
|
-
}
|
|
17
|
-
export declare class EmitFilesPatch {
|
|
18
|
-
private static _patchedTs;
|
|
19
|
-
private static _baseEmitFiles;
|
|
20
|
-
static install(ts: ExtendedTypeScript, baseCompilerOptions: TTypescript.CompilerOptions, moduleKindsToEmit: ICachedEmitModuleKind[], changedFiles?: Set<TTypescript.SourceFile>): void;
|
|
21
|
-
static get isInstalled(): boolean;
|
|
22
|
-
/**
|
|
23
|
-
* Wraps the writeFile callback on the IEmitHost to override the .js extension, if applicable
|
|
24
|
-
*/
|
|
25
|
-
static wrapWriteFile(baseWriteFile: TTypescript.WriteFileCallback, jsExtensionOverride: string | undefined): TTypescript.WriteFileCallback;
|
|
26
|
-
static uninstall(ts: ExtendedTypeScript): void;
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=EmitFilesPatch.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EmitFilesPatch.d.ts","sourceRoot":"","sources":["../src/EmitFilesPatch.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,WAAW,MAAM,YAAY,CAAC;AAC/C,OAAO,EACL,kBAAkB,EAInB,MAAM,uCAAuC,CAAC;AAE/C,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,WAAW,CAAC,UAAU,CAAC;IAEnC,aAAa,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,mBAAmB,EAAE,MAAM,GAAG,SAAS,CAAC;IAExC;;;OAGG;IACH,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAC,UAAU,CAA6C;IAEtE,OAAO,CAAC,MAAM,CAAC,cAAc,CAA8B;WAE7C,OAAO,CACnB,EAAE,EAAE,kBAAkB,EACtB,mBAAmB,EAAE,WAAW,CAAC,eAAe,EAChD,iBAAiB,EAAE,qBAAqB,EAAE,EAC1C,YAAY,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,UAAU,CAAC,GACzC,IAAI;IAsHP,WAAkB,WAAW,IAAI,OAAO,CAEvC;IAED;;OAEG;WACW,aAAa,CACzB,aAAa,EAAE,WAAW,CAAC,iBAAiB,EAC5C,mBAAmB,EAAE,MAAM,GAAG,SAAS,GACtC,WAAW,CAAC,iBAAiB;WAuBlB,SAAS,CAAC,EAAE,EAAE,kBAAkB,GAAG,IAAI;CAatD"}
|
package/lib/EmitFilesPatch.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
|
-
// See LICENSE in the project root for license information.
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.EmitFilesPatch = void 0;
|
|
6
|
-
const node_core_library_1 = require("@rushstack/node-core-library");
|
|
7
|
-
class EmitFilesPatch {
|
|
8
|
-
static install(ts, baseCompilerOptions, moduleKindsToEmit, changedFiles) {
|
|
9
|
-
if (EmitFilesPatch._patchedTs === ts) {
|
|
10
|
-
// We already patched this instance of TS
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
if (EmitFilesPatch._patchedTs !== undefined) {
|
|
14
|
-
throw new node_core_library_1.InternalError('EmitFilesPatch.install() cannot be called without first uninstalling the existing patch');
|
|
15
|
-
}
|
|
16
|
-
EmitFilesPatch._patchedTs = ts;
|
|
17
|
-
EmitFilesPatch._baseEmitFiles = ts.emitFiles;
|
|
18
|
-
let foundPrimary = false;
|
|
19
|
-
let defaultModuleKind;
|
|
20
|
-
for (const moduleKindToEmit of moduleKindsToEmit) {
|
|
21
|
-
if (moduleKindToEmit.isPrimary) {
|
|
22
|
-
if (foundPrimary) {
|
|
23
|
-
throw new Error('Multiple primary module emit kinds encountered.');
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
foundPrimary = true;
|
|
27
|
-
}
|
|
28
|
-
defaultModuleKind = moduleKindToEmit.moduleKind;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
const patchedEmitFiles = (resolver, host, targetSourceFile, emitTransformers, emitOnlyDtsFiles, onlyBuildInfo, forceDtsEmit) => {
|
|
32
|
-
if (onlyBuildInfo || emitOnlyDtsFiles) {
|
|
33
|
-
// There should only be one tsBuildInfo and one set of declaration files
|
|
34
|
-
return EmitFilesPatch._baseEmitFiles(resolver, host, targetSourceFile, emitTransformers, emitOnlyDtsFiles, onlyBuildInfo, forceDtsEmit);
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
if (targetSourceFile && changedFiles) {
|
|
38
|
-
changedFiles.add(targetSourceFile);
|
|
39
|
-
}
|
|
40
|
-
let defaultModuleKindResult;
|
|
41
|
-
const diagnostics = [];
|
|
42
|
-
let emitSkipped = false;
|
|
43
|
-
for (const moduleKindToEmit of moduleKindsToEmit) {
|
|
44
|
-
const compilerOptions = moduleKindToEmit.isPrimary
|
|
45
|
-
? Object.assign({}, baseCompilerOptions) : Object.assign(Object.assign({}, baseCompilerOptions), { module: moduleKindToEmit.moduleKind, outDir: moduleKindToEmit.outFolderPath,
|
|
46
|
-
// Don't emit declarations for secondary module kinds
|
|
47
|
-
declaration: false, declarationMap: false });
|
|
48
|
-
if (!compilerOptions.outDir) {
|
|
49
|
-
throw new node_core_library_1.InternalError('Expected compilerOptions.outDir to be assigned');
|
|
50
|
-
}
|
|
51
|
-
const flavorResult = EmitFilesPatch._baseEmitFiles(resolver, Object.assign(Object.assign({}, host), { writeFile: EmitFilesPatch.wrapWriteFile(host.writeFile, moduleKindToEmit.jsExtensionOverride), getCompilerOptions: () => compilerOptions }), targetSourceFile, ts.getTransformers(compilerOptions, undefined, emitOnlyDtsFiles), emitOnlyDtsFiles, onlyBuildInfo, forceDtsEmit);
|
|
52
|
-
emitSkipped = emitSkipped || flavorResult.emitSkipped;
|
|
53
|
-
for (const diagnostic of flavorResult.diagnostics) {
|
|
54
|
-
diagnostics.push(diagnostic);
|
|
55
|
-
}
|
|
56
|
-
if (moduleKindToEmit.moduleKind === defaultModuleKind) {
|
|
57
|
-
defaultModuleKindResult = flavorResult;
|
|
58
|
-
}
|
|
59
|
-
// Should results be aggregated, in case for whatever reason the diagnostics are not the same?
|
|
60
|
-
}
|
|
61
|
-
const mergedDiagnostics = ts.sortAndDeduplicateDiagnostics(diagnostics);
|
|
62
|
-
return Object.assign(Object.assign({}, defaultModuleKindResult), { diagnostics: mergedDiagnostics, emitSkipped });
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
// Override the underlying file emitter to run itself once for each flavor
|
|
66
|
-
// This is a rather inelegant way to convince the TypeScript compiler not to duplicate parse/link/check
|
|
67
|
-
ts.emitFiles = patchedEmitFiles;
|
|
68
|
-
}
|
|
69
|
-
static get isInstalled() {
|
|
70
|
-
return this._patchedTs !== undefined;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Wraps the writeFile callback on the IEmitHost to override the .js extension, if applicable
|
|
74
|
-
*/
|
|
75
|
-
static wrapWriteFile(baseWriteFile, jsExtensionOverride) {
|
|
76
|
-
if (!jsExtensionOverride) {
|
|
77
|
-
return baseWriteFile;
|
|
78
|
-
}
|
|
79
|
-
const replacementExtension = `${jsExtensionOverride}$1`;
|
|
80
|
-
return (fileName, data, writeBOM, onError, sourceFiles) => {
|
|
81
|
-
return baseWriteFile(fileName.replace(/\.js(\.map)?$/g, replacementExtension), data, writeBOM, onError, sourceFiles);
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
static uninstall(ts) {
|
|
85
|
-
if (EmitFilesPatch._patchedTs === undefined) {
|
|
86
|
-
throw new node_core_library_1.InternalError('EmitFilesPatch.uninstall() cannot be called if no patch was installed');
|
|
87
|
-
}
|
|
88
|
-
if (ts !== EmitFilesPatch._patchedTs) {
|
|
89
|
-
throw new node_core_library_1.InternalError('EmitFilesPatch.uninstall() called for the wrong object');
|
|
90
|
-
}
|
|
91
|
-
ts.emitFiles = EmitFilesPatch._baseEmitFiles;
|
|
92
|
-
EmitFilesPatch._patchedTs = undefined;
|
|
93
|
-
EmitFilesPatch._baseEmitFiles = undefined;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
exports.EmitFilesPatch = EmitFilesPatch;
|
|
97
|
-
EmitFilesPatch._patchedTs = undefined;
|
|
98
|
-
EmitFilesPatch._baseEmitFiles = undefined; // eslint-disable-line
|
|
99
|
-
//# sourceMappingURL=EmitFilesPatch.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EmitFilesPatch.js","sourceRoot":"","sources":["../src/EmitFilesPatch.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,oEAA6D;AA2B7D,MAAa,cAAc;IAKlB,MAAM,CAAC,OAAO,CACnB,EAAsB,EACtB,mBAAgD,EAChD,iBAA0C,EAC1C,YAA0C;QAE1C,IAAI,cAAc,CAAC,UAAU,KAAK,EAAE,EAAE;YACpC,yCAAyC;YACzC,OAAO;SACR;QAED,IAAI,cAAc,CAAC,UAAU,KAAK,SAAS,EAAE;YAC3C,MAAM,IAAI,iCAAa,CACrB,yFAAyF,CAC1F,CAAC;SACH;QAED,cAAc,CAAC,UAAU,GAAG,EAAE,CAAC;QAC/B,cAAc,CAAC,cAAc,GAAG,EAAE,CAAC,SAAS,CAAC;QAE7C,IAAI,YAAY,GAAY,KAAK,CAAC;QAClC,IAAI,iBAAyC,CAAC;QAE9C,KAAK,MAAM,gBAAgB,IAAI,iBAAiB,E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,oBAAoB,CAAC,EACxD,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,WAAW,CACZ,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC;IAEM,MAAM,CAAC,SAAS,CAAC,EAAsB;QAC5C,IAAI,cAAc,CAAC,UAAU,KAAK,SAAS,EAAE;YAC3C,MAAM,IAAI,iCAAa,CAAC,uEAAuE,CAAC,CAAC;SAClG;QACD,IAAI,EAAE,KAAK,cAAc,CAAC,UAAU,EAAE;YACpC,MAAM,IAAI,iCAAa,CAAC,wDAAwD,CAAC,CAAC;SACnF;QAED,EAAE,CAAC,SAAS,GAAG,cAAc,CAAC,cAAc,CAAC;QAE7C,cAAc,CAAC,UAAU,GAAG,SAAS,CAAC;QACtC,cAAc,CAAC,cAAc,GAAG,SAAS,CAAC;IAC5C,CAAC;;AA7KH,wCA8KC;AA7KgB,yBAAU,GAAmC,SAAS,CAAC;AAEvD,6BAAc,GAAoB,SAAS,CAAC,CAAC,sBAAsB","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { InternalError } from '@rushstack/node-core-library';\nimport type * as TTypescript from 'typescript';\nimport {\n ExtendedTypeScript,\n IEmitResolver,\n IEmitHost,\n IEmitTransformers\n} from './internalTypings/TypeScriptInternals';\n\nexport interface ICachedEmitModuleKind {\n moduleKind: TTypescript.ModuleKind;\n\n outFolderPath: string;\n\n /**\n * File extension to use instead of '.js' for emitted ECMAScript files.\n * For example, '.cjs' to indicate commonjs content, or '.mjs' to indicate ECMAScript modules.\n */\n jsExtensionOverride: string | undefined;\n\n /**\n * Set to true if this is the emit kind that is specified in the tsconfig.json.\n * Declarations are only emitted for the primary module kind.\n */\n isPrimary: boolean;\n}\n\nexport class EmitFilesPatch {\n private static _patchedTs: ExtendedTypeScript | undefined = undefined;\n\n private static _baseEmitFiles: any | undefined = undefined; // eslint-disable-line\n\n public static install(\n ts: ExtendedTypeScript,\n baseCompilerOptions: TTypescript.CompilerOptions,\n moduleKindsToEmit: ICachedEmitModuleKind[],\n changedFiles?: Set<TTypescript.SourceFile>\n ): void {\n if (EmitFilesPatch._patchedTs === ts) {\n // We already patched this instance of TS\n return;\n }\n\n if (EmitFilesPatch._patchedTs !== undefined) {\n throw new InternalError(\n 'EmitFilesPatch.install() cannot be called without first uninstalling the existing patch'\n );\n }\n\n EmitFilesPatch._patchedTs = ts;\n EmitFilesPatch._baseEmitFiles = ts.emitFiles;\n\n let foundPrimary: boolean = false;\n let defaultModuleKind: TTypescript.ModuleKind;\n\n for (const moduleKindToEmit of moduleKindsToEmit) {\n if (moduleKindToEmit.isPrimary) {\n if (foundPrimary) {\n throw new Error('Multiple primary module emit kinds encountered.');\n } else {\n foundPrimary = true;\n }\n\n defaultModuleKind = moduleKindToEmit.moduleKind;\n }\n }\n\n const patchedEmitFiles = (\n resolver: IEmitResolver,\n host: IEmitHost,\n targetSourceFile: TTypescript.SourceFile | undefined,\n emitTransformers: IEmitTransformers,\n emitOnlyDtsFiles?: boolean,\n onlyBuildInfo?: boolean,\n forceDtsEmit?: boolean\n ): TTypescript.EmitResult => {\n if (onlyBuildInfo || emitOnlyDtsFiles) {\n // There should only be one tsBuildInfo and one set of declaration files\n return EmitFilesPatch._baseEmitFiles(\n resolver,\n host,\n targetSourceFile,\n emitTransformers,\n emitOnlyDtsFiles,\n onlyBuildInfo,\n forceDtsEmit\n );\n } else {\n if (targetSourceFile && changedFiles) {\n changedFiles.add(targetSourceFile);\n }\n\n let defaultModuleKindResult: TTypescript.EmitResult;\n const diagnostics: TTypescript.Diagnostic[] = [];\n let emitSkipped: boolean = false;\n for (const moduleKindToEmit of moduleKindsToEmit) {\n const compilerOptions: TTypescript.CompilerOptions = moduleKindToEmit.isPrimary\n ? {\n ...baseCompilerOptions\n }\n : {\n ...baseCompilerOptions,\n module: moduleKindToEmit.moduleKind,\n outDir: moduleKindToEmit.outFolderPath,\n\n // Don't emit declarations for secondary module kinds\n declaration: false,\n declarationMap: false\n };\n\n if (!compilerOptions.outDir) {\n throw new InternalError('Expected compilerOptions.outDir to be assigned');\n }\n\n const flavorResult: TTypescript.EmitResult = EmitFilesPatch._baseEmitFiles(\n resolver,\n {\n ...host,\n writeFile: EmitFilesPatch.wrapWriteFile(host.writeFile, moduleKindToEmit.jsExtensionOverride),\n getCompilerOptions: () => compilerOptions\n },\n targetSourceFile,\n ts.getTransformers(compilerOptions, undefined, emitOnlyDtsFiles),\n emitOnlyDtsFiles,\n onlyBuildInfo,\n forceDtsEmit\n );\n\n emitSkipped = emitSkipped || flavorResult.emitSkipped;\n for (const diagnostic of flavorResult.diagnostics) {\n diagnostics.push(diagnostic);\n }\n\n if (moduleKindToEmit.moduleKind === defaultModuleKind) {\n defaultModuleKindResult = flavorResult;\n }\n // Should results be aggregated, in case for whatever reason the diagnostics are not the same?\n }\n\n const mergedDiagnostics: readonly TTypescript.Diagnostic[] =\n ts.sortAndDeduplicateDiagnostics(diagnostics);\n\n return {\n ...defaultModuleKindResult!,\n diagnostics: mergedDiagnostics,\n emitSkipped\n };\n }\n };\n\n // Override the underlying file emitter to run itself once for each flavor\n // This is a rather inelegant way to convince the TypeScript compiler not to duplicate parse/link/check\n ts.emitFiles = patchedEmitFiles;\n }\n\n public static get isInstalled(): boolean {\n return this._patchedTs !== undefined;\n }\n\n /**\n * Wraps the writeFile callback on the IEmitHost to override the .js extension, if applicable\n */\n public static wrapWriteFile(\n baseWriteFile: TTypescript.WriteFileCallback,\n jsExtensionOverride: string | undefined\n ): TTypescript.WriteFileCallback {\n if (!jsExtensionOverride) {\n return baseWriteFile;\n }\n\n const replacementExtension: string = `${jsExtensionOverride}$1`;\n return (\n fileName: string,\n data: string,\n writeBOM: boolean,\n onError?: ((message: string) => void) | undefined,\n sourceFiles?: readonly TTypescript.SourceFile[] | undefined\n ) => {\n return baseWriteFile(\n fileName.replace(/\\.js(\\.map)?$/g, replacementExtension),\n data,\n writeBOM,\n onError,\n sourceFiles\n );\n };\n }\n\n public static uninstall(ts: ExtendedTypeScript): void {\n if (EmitFilesPatch._patchedTs === undefined) {\n throw new InternalError('EmitFilesPatch.uninstall() cannot be called if no patch was installed');\n }\n if (ts !== EmitFilesPatch._patchedTs) {\n throw new InternalError('EmitFilesPatch.uninstall() called for the wrong object');\n }\n\n ts.emitFiles = EmitFilesPatch._baseEmitFiles;\n\n EmitFilesPatch._patchedTs = undefined;\n EmitFilesPatch._baseEmitFiles = undefined;\n }\n}\n"]}
|