@rushstack/heft-typescript-plugin 0.1.0-dev.1 → 0.1.0-rc.1

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.
@@ -106,6 +106,6 @@ export declare function loadTypeScriptConfigurationFileAsync(heftConfiguration:
106
106
  *
107
107
  * @public
108
108
  */
109
- export declare const TypeScriptPluginName: 'TypeScriptPlugin';
109
+ export declare const TypeScriptPluginName: 'typescript-plugin';
110
110
 
111
111
  export { }
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.29.0"
8
+ "packageVersion": "7.32.0"
9
9
  }
10
10
  ]
11
11
  }
package/heft-plugin.json CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  "taskPlugins": [
5
5
  {
6
- "pluginName": "TypeScriptPlugin",
6
+ "pluginName": "typescript-plugin",
7
7
  "entryPoint": "./lib/TypeScriptPlugin"
8
8
  }
9
9
  ]
@@ -1,5 +1,5 @@
1
1
  import type * as TTypescript from 'typescript';
2
- import type { IScopedLogger } from '@rushstack/heft';
2
+ import type { IChangedFileState, IScopedLogger } from '@rushstack/heft';
3
3
  import type { ExtendedTypeScript } from './internalTypings/TypeScriptInternals';
4
4
  import type { ITypeScriptConfigurationJson } from './TypeScriptPlugin';
5
5
  import type { PerformanceMeasurer, PerformanceMeasurerAsync } from './Performance';
@@ -34,6 +34,14 @@ export interface ITypeScriptBuilderConfiguration extends ITypeScriptConfiguratio
34
34
  */
35
35
  emitChangedFilesCallback: (program: TTypescript.Program, changedFiles?: Set<TTypescript.SourceFile>) => void;
36
36
  }
37
+ interface ITypeScriptTool {
38
+ ts: ExtendedTypeScript;
39
+ measureSync: PerformanceMeasurer;
40
+ measureAsync: PerformanceMeasurerAsync;
41
+ sourceFileCache: Map<string, TTypescript.SourceFile>;
42
+ oldBuilderProgram: TTypescript.EmitAndSemanticDiagnosticsBuilderProgram | undefined;
43
+ oldProgram: TTypescript.Program | undefined;
44
+ }
37
45
  export declare class TypeScriptBuilder {
38
46
  private readonly _configuration;
39
47
  private readonly _typescriptLogger;
@@ -46,11 +54,12 @@ export declare class TypeScriptBuilder {
46
54
  private __tsCacheFilePath;
47
55
  private _tsReadJsonCache;
48
56
  private _cachedFileSystem;
57
+ private _tool;
49
58
  private get _tsCacheFilePath();
50
59
  constructor(configuration: ITypeScriptBuilderConfiguration);
51
- invokeAsync(): Promise<void>;
52
- _runBuildAsync(ts: ExtendedTypeScript, measureTsPerformance: PerformanceMeasurer, measureTsPerformanceAsync: PerformanceMeasurerAsync): Promise<void>;
53
- _runSolutionBuild(ts: ExtendedTypeScript, measureTsPerformance: PerformanceMeasurer): void;
60
+ invokeAsync(changedFiles?: ReadonlyMap<string, IChangedFileState> | undefined): Promise<void>;
61
+ _runBuildAsync(tool: ITypeScriptTool): Promise<void>;
62
+ _runSolutionBuild(tool: ITypeScriptTool): void;
54
63
  private _logDiagnostics;
55
64
  private _logEmitPerformance;
56
65
  private _logReadPerformance;
@@ -66,4 +75,5 @@ export declare class TypeScriptBuilder {
66
75
  private _overrideTypeScriptReadJson;
67
76
  private _parseModuleKind;
68
77
  }
78
+ export {};
69
79
  //# sourceMappingURL=TypeScriptBuilder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TypeScriptBuilder.d.ts","sourceRoot":"","sources":["../src/TypeScriptBuilder.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,KAAK,WAAW,MAAM,YAAY,CAAC;AAW/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAGhF,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,KAAK,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAEnF,MAAM,WAAW,+BAAgC,SAAQ,4BAA4B;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CAAC,iBAAiB;IAyHzB,OAAO,CAAC,oBAAoB;IA8D5B,OAAO,CAAC,aAAa;IA6CrB,OAAO,CAAC,yBAAyB;IAqBjC,OAAO,CAAC,6BAA6B;IAiDrC,OAAO,CAAC,2BAA2B;IAiGnC,OAAO,CAAC,2BAA2B;IAgCnC,OAAO,CAAC,gBAAgB;CAwBzB"}
@@ -40,11 +40,13 @@ const EMPTY_JSON = {};
40
40
  const OLDEST_SUPPORTED_TS_MAJOR_VERSION = 2;
41
41
  const OLDEST_SUPPORTED_TS_MINOR_VERSION = 9;
42
42
  const NEWEST_SUPPORTED_TS_MAJOR_VERSION = 4;
43
- const NEWEST_SUPPORTED_TS_MINOR_VERSION = 7;
43
+ const NEWEST_SUPPORTED_TS_MINOR_VERSION = 8;
44
44
  class TypeScriptBuilder {
45
45
  constructor(configuration) {
46
+ this.__tsCacheFilePath = undefined;
46
47
  this._tsReadJsonCache = new Map();
47
48
  this._cachedFileSystem = new TypeScriptCachedFileSystem_1.TypeScriptCachedFileSystem();
49
+ this._tool = undefined;
48
50
  this._configuration = configuration;
49
51
  this._typescriptLogger = configuration.scopedLogger;
50
52
  this._typescriptTerminal = configuration.scopedLogger.terminal;
@@ -68,79 +70,99 @@ class TypeScriptBuilder {
68
70
  }
69
71
  return this.__tsCacheFilePath;
70
72
  }
71
- async invokeAsync() {
72
- // Determine the compiler version
73
- const compilerPackageJsonFilename = path.join(this._configuration.typeScriptToolPath, 'package.json');
74
- const packageJson = await node_core_library_1.JsonFile.loadAsync(compilerPackageJsonFilename);
75
- this._typescriptVersion = packageJson.version;
76
- const parsedVersion = semver.parse(this._typescriptVersion);
77
- if (!parsedVersion) {
78
- throw new Error(`Unable to parse version "${this._typescriptVersion}" for TypeScript compiler package in: ` +
79
- compilerPackageJsonFilename);
80
- }
81
- this._typescriptParsedVersion = parsedVersion;
82
- // Detect what features this compiler supports. Note that manually comparing major/minor numbers
83
- // loosens the matching to accept prereleases such as "3.6.0-dev.20190530"
84
- this._capabilities = {
85
- incrementalProgram: false,
86
- solutionBuilder: this._typescriptParsedVersion.major >= 3
87
- };
88
- if (this._typescriptParsedVersion.major > 3 ||
89
- (this._typescriptParsedVersion.major === 3 && this._typescriptParsedVersion.minor >= 6)) {
90
- this._capabilities.incrementalProgram = true;
91
- }
92
- this._useSolutionBuilder = !!this._configuration.buildProjectReferences;
93
- if (this._useSolutionBuilder && !this._capabilities.solutionBuilder) {
94
- throw new Error(`Building project references requires TypeScript@>=3.0, but the current version is ${this._typescriptVersion}`);
95
- }
96
- // Report a warning if the TypeScript version is too old/new. The current oldest supported version is
97
- // TypeScript 2.9. Prior to that the "ts.getConfigFileParsingDiagnostics()" API is missing; more fixups
98
- // would be required to deal with that. We won't do that work unless someone requests it.
99
- if (this._typescriptParsedVersion.major < OLDEST_SUPPORTED_TS_MAJOR_VERSION ||
100
- (this._typescriptParsedVersion.major === OLDEST_SUPPORTED_TS_MAJOR_VERSION &&
101
- this._typescriptParsedVersion.minor < OLDEST_SUPPORTED_TS_MINOR_VERSION)) {
102
- // We don't use writeWarningLine() here because, if the person wants to take their chances with
103
- // a seemingly unsupported compiler, their build should be allowed to succeed.
104
- this._typescriptTerminal.writeLine(`The TypeScript compiler version ${this._typescriptVersion} is very old` +
105
- ` and has not been tested with Heft; it may not work correctly.`);
73
+ async invokeAsync(changedFiles) {
74
+ if (!this._tool) {
75
+ // Determine the compiler version
76
+ const compilerPackageJsonFilename = path.join(this._configuration.typeScriptToolPath, 'package.json');
77
+ const packageJson = await node_core_library_1.JsonFile.loadAsync(compilerPackageJsonFilename);
78
+ this._typescriptVersion = packageJson.version;
79
+ const parsedVersion = semver.parse(this._typescriptVersion);
80
+ if (!parsedVersion) {
81
+ throw new Error(`Unable to parse version "${this._typescriptVersion}" for TypeScript compiler package in: ` +
82
+ compilerPackageJsonFilename);
83
+ }
84
+ this._typescriptParsedVersion = parsedVersion;
85
+ // Detect what features this compiler supports. Note that manually comparing major/minor numbers
86
+ // loosens the matching to accept prereleases such as "3.6.0-dev.20190530"
87
+ this._capabilities = {
88
+ incrementalProgram: false,
89
+ solutionBuilder: this._typescriptParsedVersion.major >= 3
90
+ };
91
+ if (this._typescriptParsedVersion.major > 3 ||
92
+ (this._typescriptParsedVersion.major === 3 && this._typescriptParsedVersion.minor >= 6)) {
93
+ this._capabilities.incrementalProgram = true;
94
+ }
95
+ this._useSolutionBuilder = !!this._configuration.buildProjectReferences;
96
+ if (this._useSolutionBuilder && !this._capabilities.solutionBuilder) {
97
+ throw new Error(`Building project references requires TypeScript@>=3.0, but the current version is ${this._typescriptVersion}`);
98
+ }
99
+ // Report a warning if the TypeScript version is too old/new. The current oldest supported version is
100
+ // TypeScript 2.9. Prior to that the "ts.getConfigFileParsingDiagnostics()" API is missing; more fixups
101
+ // would be required to deal with that. We won't do that work unless someone requests it.
102
+ if (this._typescriptParsedVersion.major < OLDEST_SUPPORTED_TS_MAJOR_VERSION ||
103
+ (this._typescriptParsedVersion.major === OLDEST_SUPPORTED_TS_MAJOR_VERSION &&
104
+ this._typescriptParsedVersion.minor < OLDEST_SUPPORTED_TS_MINOR_VERSION)) {
105
+ // We don't use writeWarningLine() here because, if the person wants to take their chances with
106
+ // a seemingly unsupported compiler, their build should be allowed to succeed.
107
+ this._typescriptTerminal.writeLine(`The TypeScript compiler version ${this._typescriptVersion} is very old` +
108
+ ` and has not been tested with Heft; it may not work correctly.`);
109
+ }
110
+ else if (this._typescriptParsedVersion.major > NEWEST_SUPPORTED_TS_MAJOR_VERSION ||
111
+ (this._typescriptParsedVersion.major === NEWEST_SUPPORTED_TS_MAJOR_VERSION &&
112
+ this._typescriptParsedVersion.minor > NEWEST_SUPPORTED_TS_MINOR_VERSION)) {
113
+ this._typescriptTerminal.writeLine(`The TypeScript compiler version ${this._typescriptVersion} is newer` +
114
+ ' than the latest version that was tested with Heft ' +
115
+ `(${NEWEST_SUPPORTED_TS_MAJOR_VERSION}.${NEWEST_SUPPORTED_TS_MINOR_VERSION}); it may not work correctly.`);
116
+ }
117
+ const ts = require(this._configuration.typeScriptToolPath);
118
+ const measureTsPerformance = (measurementName, fn) => {
119
+ const beforeName = `before${measurementName}`;
120
+ ts.performance.mark(beforeName);
121
+ const result = fn();
122
+ const afterName = `after${measurementName}`;
123
+ ts.performance.mark(afterName);
124
+ ts.performance.measure(measurementName, beforeName, afterName);
125
+ return Object.assign(Object.assign({}, result), { duration: ts.performance.getDuration(measurementName), count: ts.performance.getCount(beforeName) });
126
+ };
127
+ const measureTsPerformanceAsync = async (measurementName, fn) => {
128
+ const beforeName = `before${measurementName}`;
129
+ ts.performance.mark(beforeName);
130
+ const resultPromise = fn();
131
+ const result = await resultPromise;
132
+ const afterName = `after${measurementName}`;
133
+ ts.performance.mark(afterName);
134
+ ts.performance.measure(measurementName, beforeName, afterName);
135
+ return Object.assign(Object.assign({}, result), { duration: ts.performance.getDuration(measurementName) });
136
+ };
137
+ this._typescriptTerminal.writeLine(`Using TypeScript version ${ts.version}`);
138
+ this._tool = {
139
+ ts,
140
+ measureSync: measureTsPerformance,
141
+ measureAsync: measureTsPerformanceAsync,
142
+ sourceFileCache: new Map(),
143
+ oldBuilderProgram: undefined,
144
+ oldProgram: undefined
145
+ };
106
146
  }
107
- else if (this._typescriptParsedVersion.major > NEWEST_SUPPORTED_TS_MAJOR_VERSION ||
108
- (this._typescriptParsedVersion.major === NEWEST_SUPPORTED_TS_MAJOR_VERSION &&
109
- this._typescriptParsedVersion.minor > NEWEST_SUPPORTED_TS_MINOR_VERSION)) {
110
- this._typescriptTerminal.writeLine(`The TypeScript compiler version ${this._typescriptVersion} is newer` +
111
- ' than the latest version that was tested with Heft ' +
112
- `(${NEWEST_SUPPORTED_TS_MAJOR_VERSION}.${NEWEST_SUPPORTED_TS_MINOR_VERSION}); it may not work correctly.`);
147
+ const { performance } = this._tool.ts;
148
+ // Reset the performance counters to 0 to avoid contamination from previous runs
149
+ performance.disable();
150
+ performance.enable();
151
+ if (changedFiles) {
152
+ const { sourceFileCache } = this._tool;
153
+ for (const file of changedFiles.keys()) {
154
+ // There might need to be a transform to the format of `file` here.
155
+ sourceFileCache.delete(file);
156
+ }
113
157
  }
114
- const ts = require(this._configuration.typeScriptToolPath);
115
- ts.performance.enable();
116
- const measureTsPerformance = (measurementName, fn) => {
117
- const beforeName = `before${measurementName}`;
118
- ts.performance.mark(beforeName);
119
- const result = fn();
120
- const afterName = `after${measurementName}`;
121
- ts.performance.mark(afterName);
122
- ts.performance.measure(measurementName, beforeName, afterName);
123
- return Object.assign(Object.assign({}, result), { duration: ts.performance.getDuration(measurementName), count: ts.performance.getCount(beforeName) });
124
- };
125
- const measureTsPerformanceAsync = async (measurementName, fn) => {
126
- const beforeName = `before${measurementName}`;
127
- ts.performance.mark(beforeName);
128
- const resultPromise = fn();
129
- const result = await resultPromise;
130
- const afterName = `after${measurementName}`;
131
- ts.performance.mark(afterName);
132
- ts.performance.measure(measurementName, beforeName, afterName);
133
- return Object.assign(Object.assign({}, result), { duration: ts.performance.getDuration(measurementName) });
134
- };
135
- this._typescriptTerminal.writeLine(`Using TypeScript version ${ts.version}`);
136
158
  // if (this._configuration.watchMode) {
137
159
  // await this._runWatch(ts, measureTsPerformance);
138
160
  // } else if (this._useSolutionBuilder) {
139
161
  if (this._useSolutionBuilder) {
140
- this._runSolutionBuild(ts, measureTsPerformance);
162
+ this._runSolutionBuild(this._tool);
141
163
  }
142
164
  else {
143
- await this._runBuildAsync(ts, measureTsPerformance, measureTsPerformanceAsync);
165
+ await this._runBuildAsync(this._tool);
144
166
  }
145
167
  }
146
168
  // public async _runWatch(ts: ExtendedTypeScript, measureTsPerformance: PerformanceMeasurer): Promise<void> {
@@ -168,13 +190,14 @@ class TypeScriptBuilder {
168
190
  // /* never terminate */
169
191
  // });
170
192
  // }
171
- async _runBuildAsync(ts, measureTsPerformance, measureTsPerformanceAsync) {
193
+ async _runBuildAsync(tool) {
194
+ const { ts, measureSync: measureTsPerformance, measureAsync: measureTsPerformanceAsync } = tool;
172
195
  //#region CONFIGURE
173
196
  const { duration: configureDurationMs, tsconfig, compilerHost } = measureTsPerformance('Configure', () => {
174
197
  this._overrideTypeScriptReadJson(ts);
175
198
  const _tsconfig = this._loadTsconfig(ts);
176
199
  this._validateTsconfig(ts, _tsconfig);
177
- const _compilerHost = this._buildIncrementalCompilerHost(ts, _tsconfig);
200
+ const _compilerHost = this._buildIncrementalCompilerHost(tool, _tsconfig);
178
201
  return {
179
202
  tsconfig: _tsconfig,
180
203
  compilerHost: _compilerHost
@@ -187,13 +210,11 @@ class TypeScriptBuilder {
187
210
  let builderProgram = undefined;
188
211
  let tsProgram;
189
212
  if (tsconfig.options.incremental) {
190
- builderProgram = ts.createIncrementalProgram({
191
- rootNames: tsconfig.fileNames,
192
- options: tsconfig.options,
193
- projectReferences: tsconfig.projectReferences,
194
- host: compilerHost,
195
- configFileParsingDiagnostics: ts.getConfigFileParsingDiagnostics(tsconfig)
196
- });
213
+ if (!tool.oldBuilderProgram) {
214
+ tool.oldBuilderProgram = ts.readBuilderProgram(tsconfig.options, compilerHost);
215
+ }
216
+ builderProgram = ts.createEmitAndSemanticDiagnosticsBuilderProgram(tsconfig.fileNames, tsconfig.options, compilerHost, tool.oldBuilderProgram, ts.getConfigFileParsingDiagnostics(tsconfig), tsconfig.projectReferences);
217
+ tool.oldBuilderProgram = builderProgram;
197
218
  tsProgram = builderProgram.getProgram();
198
219
  }
199
220
  else {
@@ -202,8 +223,10 @@ class TypeScriptBuilder {
202
223
  options: tsconfig.options,
203
224
  projectReferences: tsconfig.projectReferences,
204
225
  host: compilerHost,
226
+ oldProgram: tool.oldProgram,
205
227
  configFileParsingDiagnostics: ts.getConfigFileParsingDiagnostics(tsconfig)
206
228
  });
229
+ tool.oldProgram = tsProgram;
207
230
  }
208
231
  // Prefer the builder program, since it is what gives us incremental builds
209
232
  const genericProgram = builderProgram || tsProgram;
@@ -238,46 +261,54 @@ class TypeScriptBuilder {
238
261
  const { duration: writeDuration } = await writePromise;
239
262
  this._typescriptTerminal.writeVerboseLine(`I/O Write: ${writeDuration}ms (${emitResult.filesToWrite.length} files)`);
240
263
  this._logDiagnostics(ts, rawDiagnostics);
264
+ // Reset performance counters in case any are used in the callback
265
+ ts.performance.disable();
266
+ ts.performance.enable();
241
267
  this._configuration.emitChangedFilesCallback(tsProgram, emitResult.changedSourceFiles);
242
268
  }
243
- _runSolutionBuild(ts, measureTsPerformance) {
269
+ _runSolutionBuild(tool) {
244
270
  this._typescriptTerminal.writeVerboseLine(`Using solution mode`);
245
- //#region CONFIGURE
246
- const { duration: configureDurationMs, rawDiagnostics, solutionBuilderHost } = measureTsPerformance('Configure', () => {
247
- this._overrideTypeScriptReadJson(ts);
248
- const _tsconfig = this._loadTsconfig(ts);
249
- this._validateTsconfig(ts, _tsconfig);
250
- const _rawDiagnostics = [];
251
- const reportDiagnostic = (diagnostic) => {
252
- _rawDiagnostics.push(diagnostic);
253
- };
254
- // TypeScript doesn't have a
255
- EmitFilesPatch_1.EmitFilesPatch.install(ts, _tsconfig, this._moduleKindsToEmit);
256
- const _solutionBuilderHost = this._buildSolutionBuilderHost(ts, reportDiagnostic);
257
- _solutionBuilderHost.afterProgramEmitAndDiagnostics = (program) => {
258
- const tsProgram = program.getProgram();
259
- if (tsProgram) {
260
- this._configuration.emitChangedFilesCallback(tsProgram);
261
- }
262
- };
263
- return {
264
- rawDiagnostics: _rawDiagnostics,
265
- solutionBuilderHost: _solutionBuilderHost
266
- };
267
- });
268
- this._typescriptTerminal.writeVerboseLine(`Configure: ${configureDurationMs}ms`);
269
- //#endregion
270
- const solutionBuilder = ts.createSolutionBuilder(solutionBuilderHost, [this._configuration.tsconfigPath], {});
271
- //#region EMIT
272
- // Ignoring the exit status because we only care about presence of diagnostics
273
- solutionBuilder.build();
274
- //#endregion
275
- this._logReadPerformance(ts);
276
- this._logEmitPerformance(ts);
277
- // Use the native metric since we aren't overwriting the writer
278
- this._typescriptTerminal.writeVerboseLine(`I/O Write: ${ts.performance.getDuration('I/O Write')}ms (${ts.performance.getCount('beforeIOWrite')} files)`);
279
- this._logDiagnostics(ts, rawDiagnostics);
280
- EmitFilesPatch_1.EmitFilesPatch.uninstall(ts);
271
+ const { ts, measureSync } = tool;
272
+ try {
273
+ //#region CONFIGURE
274
+ const { duration: configureDurationMs, rawDiagnostics, solutionBuilderHost } = measureSync('Configure', () => {
275
+ this._overrideTypeScriptReadJson(ts);
276
+ const _tsconfig = this._loadTsconfig(ts);
277
+ this._validateTsconfig(ts, _tsconfig);
278
+ const _rawDiagnostics = [];
279
+ const reportDiagnostic = (diagnostic) => {
280
+ _rawDiagnostics.push(diagnostic);
281
+ };
282
+ // TypeScript doesn't have a way to find out when a given program starts emitting in solution mode
283
+ EmitFilesPatch_1.EmitFilesPatch.install(ts, _tsconfig, this._moduleKindsToEmit);
284
+ const _solutionBuilderHost = this._buildSolutionBuilderHost(ts, reportDiagnostic);
285
+ _solutionBuilderHost.afterProgramEmitAndDiagnostics = (program) => {
286
+ const tsProgram = program.getProgram();
287
+ if (tsProgram) {
288
+ this._configuration.emitChangedFilesCallback(tsProgram);
289
+ }
290
+ };
291
+ return {
292
+ rawDiagnostics: _rawDiagnostics,
293
+ solutionBuilderHost: _solutionBuilderHost
294
+ };
295
+ });
296
+ this._typescriptTerminal.writeVerboseLine(`Configure: ${configureDurationMs}ms`);
297
+ //#endregion
298
+ const solutionBuilder = ts.createSolutionBuilder(solutionBuilderHost, [this._configuration.tsconfigPath], {});
299
+ //#region EMIT
300
+ // Ignoring the exit status because we only care about presence of diagnostics
301
+ solutionBuilder.build();
302
+ //#endregion
303
+ this._logReadPerformance(ts);
304
+ this._logEmitPerformance(ts);
305
+ // Use the native metric since we aren't overwriting the writer
306
+ this._typescriptTerminal.writeVerboseLine(`I/O Write: ${ts.performance.getDuration('I/O Write')}ms (${ts.performance.getCount('beforeIOWrite')} files)`);
307
+ this._logDiagnostics(ts, rawDiagnostics);
308
+ }
309
+ finally {
310
+ EmitFilesPatch_1.EmitFilesPatch.uninstall(ts);
311
+ }
281
312
  }
282
313
  _logDiagnostics(ts, rawDiagnostics) {
283
314
  const diagnostics = ts.sortAndDeduplicateDiagnostics(rawDiagnostics);
@@ -373,10 +404,14 @@ class TypeScriptBuilder {
373
404
  const writeFileCallback = (filePath, data) => {
374
405
  filesToWrite.push({ filePath, data });
375
406
  };
376
- const result = genericProgram.emit(undefined, // Target source file
377
- writeFileCallback);
378
- EmitFilesPatch_1.EmitFilesPatch.uninstall(ts);
379
- return Object.assign(Object.assign({}, result), { changedSourceFiles: changedFiles, filesToWrite });
407
+ try {
408
+ const result = genericProgram.emit(undefined, // Target source file
409
+ writeFileCallback);
410
+ return Object.assign(Object.assign({}, result), { changedSourceFiles: changedFiles, filesToWrite });
411
+ }
412
+ finally {
413
+ EmitFilesPatch_1.EmitFilesPatch.uninstall(ts);
414
+ }
380
415
  }
381
416
  _validateTsconfig(ts, tsconfig) {
382
417
  if ((tsconfig.options.module && !tsconfig.options.outDir) ||
@@ -531,13 +566,35 @@ class TypeScriptBuilder {
531
566
  const compilerHost = ts.createSolutionBuilderHost(this._getCachingTypeScriptSystem(ts), ts.createEmitAndSemanticDiagnosticsBuilderProgram, reportDiagnostic, reportSolutionBuilderStatus, reportEmitErrorSummary);
532
567
  return compilerHost;
533
568
  }
534
- _buildIncrementalCompilerHost(ts, tsconfig) {
569
+ _buildIncrementalCompilerHost(tool, tsconfig) {
570
+ const { ts, sourceFileCache } = tool;
571
+ let compilerHost;
535
572
  if (tsconfig.options.incremental) {
536
- return ts.createIncrementalCompilerHost(tsconfig.options, this._getCachingTypeScriptSystem(ts));
573
+ compilerHost = ts.createIncrementalCompilerHost(tsconfig.options, this._getCachingTypeScriptSystem(ts));
537
574
  }
538
575
  else {
539
- return ts.createCompilerHost(tsconfig.options);
576
+ compilerHost = ts.createCompilerHost(tsconfig.options);
540
577
  }
578
+ const { getSourceFile: innerGetSourceFile } = compilerHost;
579
+ // Enable source file persistence
580
+ const getSourceFile = (fileName, languageVersionOrOptions, onError, shouldCreateNewSourceFile) => {
581
+ if (!shouldCreateNewSourceFile) {
582
+ const cachedSourceFile = sourceFileCache.get(fileName);
583
+ if (cachedSourceFile) {
584
+ return cachedSourceFile;
585
+ }
586
+ }
587
+ const result = innerGetSourceFile(fileName, languageVersionOrOptions, onError, shouldCreateNewSourceFile);
588
+ if (result) {
589
+ sourceFileCache.set(fileName, result);
590
+ }
591
+ else {
592
+ sourceFileCache.delete(fileName);
593
+ }
594
+ return result;
595
+ };
596
+ compilerHost.getSourceFile = getSourceFile;
597
+ return compilerHost;
541
598
  }
542
599
  _getCachingTypeScriptSystem(ts) {
543
600
  const sys = Object.assign(Object.assign({}, ts.sys), { deleteFile: this._cachedFileSystem.deleteFile.bind(this._cachedFileSystem),
@@ -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,oEASsC;AAItC,qDAA8E;AAC9E,wFAAqF;AAgDrF,4BAA4B;AAC5B,kHAAkH;AAClH,4BAA4B;AAC5B,oGAAoG;AAEpG,MAAM,UAAU,GAAW,EAAE,CAAC;AAiC9B,MAAM,iCAAiC,GAAW,CAAC,CAAC;AACpD,MAAM,iCAAiC,GAAW,CAAC,CAAC;AAEpD,MAAM,iCAAiC,GAAW,CAAC,CAAC;AACpD,MAAM,iCAAiC,GAAW,CAAC,CAAC;AAEpD,MAAa,iBAAiB;IA0C5B,YAAmB,aAA8C;QA5BzD,qBAAgB,GAAwB,IAAI,GAAG,EAAkB,CAAC;QAClE,sBAAiB,GAA+B,IAAI,uDAA0B,EAAE,CAAC;QA4BvF,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;QACpC,IAAI,CAAC,iBAAiB,GAAG,aAAa,CAAC,YAAY,CAAC;QACpD,IAAI,CAAC,mBAAmB,GAAG,aAAa,CAAC,YAAY,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BACb,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;AA95BD,8CA85BC","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 FileSystemStats,\n type ITerminal,\n JsonFile,\n IPackageJson,\n FileSystem,\n Path,\n Async,\n FileError\n} from '@rushstack/node-core-library';\nimport type { IScopedLogger } from '@rushstack/heft';\n\nimport type { ExtendedTypeScript } 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>;\n// type TWatchCompilerHost =\n// TTypescript.WatchCompilerHostOfFilesAndCompilerOptions<TTypescript.EmitAndSemanticDiagnosticsBuilderProgram>;\n// type TWatchSolutionHost =\n// TTypescript.SolutionBuilderWithWatchHost<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\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 = 7;\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;\n private _tsReadJsonCache: Map<string, object> = new Map<string, object>();\n private _cachedFileSystem: TypeScriptCachedFileSystem = new TypeScriptCachedFileSystem();\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(): Promise<void> {\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 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 // if (this._configuration.watchMode) {\n // await this._runWatch(ts, measureTsPerformance);\n // } else if (this._useSolutionBuilder) {\n if (this._useSolutionBuilder) {\n this._runSolutionBuild(ts, measureTsPerformance);\n } else {\n await this._runBuildAsync(ts, measureTsPerformance, measureTsPerformanceAsync);\n }\n }\n\n // public async _runWatch(ts: ExtendedTypeScript, measureTsPerformance: PerformanceMeasurer): Promise<void> {\n // //#region CONFIGURE\n // const { duration: configureDurationMs, tsconfig } = measureTsPerformance('Configure', () => {\n // const _tsconfig: TTypescript.ParsedCommandLine = this._loadTsconfig(ts);\n // this._validateTsconfig(ts, _tsconfig);\n // EmitFilesPatch.install(ts, _tsconfig, this._moduleKindsToEmit);\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(ts);\n // const watchBuilder: TTypescript.SolutionBuilder<TTypescript.EmitAndSemanticDiagnosticsBuilderProgram> =\n // ts.createSolutionBuilderWithWatch(solutionHost, [this._configuration.tsconfigPath], {});\n\n // watchBuilder.build();\n // } else {\n // const compilerHost: TWatchCompilerHost = this._buildWatchCompilerHost(ts, tsconfig);\n // ts.createWatchProgram(compilerHost);\n // }\n\n // return new Promise(() => {\n // /* never terminate */\n // });\n // }\n\n public async _runBuildAsync(\n ts: ExtendedTypeScript,\n measureTsPerformance: PerformanceMeasurer,\n measureTsPerformanceAsync: PerformanceMeasurerAsync\n ): Promise<void> {\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(ts, _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 tsProgram: TTypescript.Program;\n\n if (tsconfig.options.incremental) {\n builderProgram = ts.createIncrementalProgram({\n rootNames: tsconfig.fileNames,\n options: tsconfig.options,\n projectReferences: tsconfig.projectReferences,\n host: compilerHost,\n configFileParsingDiagnostics: ts.getConfigFileParsingDiagnostics(tsconfig)\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 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, tsconfig, 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 this._configuration.emitChangedFilesCallback(tsProgram, emitResult.changedSourceFiles);\n }\n\n public _runSolutionBuild(ts: ExtendedTypeScript, measureTsPerformance: PerformanceMeasurer): void {\n this._typescriptTerminal.writeVerboseLine(`Using solution mode`);\n\n //#region CONFIGURE\n const {\n duration: configureDurationMs,\n rawDiagnostics,\n solutionBuilderHost\n } = measureTsPerformance('Configure', () => {\n this._overrideTypeScriptReadJson(ts);\n const _tsconfig: TTypescript.ParsedCommandLine = this._loadTsconfig(ts);\n this._validateTsconfig(ts, _tsconfig);\n\n const _rawDiagnostics: TTypescript.Diagnostic[] = [];\n const reportDiagnostic: TTypescript.DiagnosticReporter = (diagnostic: TTypescript.Diagnostic) => {\n _rawDiagnostics.push(diagnostic);\n };\n\n // TypeScript doesn't have a\n EmitFilesPatch.install(ts, _tsconfig, this._moduleKindsToEmit);\n\n const _solutionBuilderHost: TSolutionHost = this._buildSolutionBuilderHost(ts, reportDiagnostic);\n\n _solutionBuilderHost.afterProgramEmitAndDiagnostics = (\n program: TTypescript.EmitAndSemanticDiagnosticsBuilderProgram\n ) => {\n const tsProgram: TTypescript.Program | undefined = program.getProgram();\n if (tsProgram) {\n this._configuration.emitChangedFilesCallback(tsProgram);\n }\n };\n\n return {\n rawDiagnostics: _rawDiagnostics,\n solutionBuilderHost: _solutionBuilderHost\n };\n });\n this._typescriptTerminal.writeVerboseLine(`Configure: ${configureDurationMs}ms`);\n //#endregion\n\n const solutionBuilder: TTypescript.SolutionBuilder<TTypescript.EmitAndSemanticDiagnosticsBuilderProgram> =\n ts.createSolutionBuilder(solutionBuilderHost, [this._configuration.tsconfigPath], {});\n\n //#region EMIT\n // Ignoring the exit status because we only care about presence of diagnostics\n solutionBuilder.build();\n //#endregion\n\n this._logReadPerformance(ts);\n this._logEmitPerformance(ts);\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 this._logDiagnostics(ts, rawDiagnostics);\n\n EmitFilesPatch.uninstall(ts);\n }\n\n private _logDiagnostics(ts: ExtendedTypeScript, rawDiagnostics: readonly TTypescript.Diagnostic[]): void {\n const diagnostics: readonly TTypescript.Diagnostic[] = ts.sortAndDeduplicateDiagnostics(rawDiagnostics);\n\n let typeScriptErrorCount: number = 0;\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 if (diagnosticCategory === ts.DiagnosticCategory.Error) {\n typeScriptErrorCount++;\n }\n\n this._printDiagnosticMessage(ts, diagnostic, diagnosticCategory);\n }\n }\n\n if (typeScriptErrorCount > 0) {\n throw new Error(`Encountered TypeScript error${typeScriptErrorCount > 1 ? 's' : ''}`);\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 tsconfig: TTypescript.ParsedCommandLine,\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, tsconfig, this._moduleKindsToEmit, changedFiles);\n\n const writeFileCallback: TTypescript.WriteFileCallback = (filePath: string, data: string) => {\n filesToWrite.push({ filePath, data });\n };\n\n const result: TTypescript.EmitResult = genericProgram.emit(\n undefined, // Target source file\n writeFileCallback\n );\n\n EmitFilesPatch.uninstall(ts);\n\n return {\n ...result,\n changedSourceFiles: changedFiles,\n filesToWrite\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 _buildSolutionBuilderHost(\n ts: ExtendedTypeScript,\n reportDiagnostic: TTypescript.DiagnosticReporter\n ): TSolutionHost {\n const reportSolutionBuilderStatus: TTypescript.DiagnosticReporter = reportDiagnostic;\n const reportEmitErrorSummary: TTypescript.ReportEmitErrorSummary = (errorCount: number): void => {\n // Do nothing\n };\n\n const compilerHost: TTypescript.SolutionBuilderHost<TTypescript.EmitAndSemanticDiagnosticsBuilderProgram> =\n ts.createSolutionBuilderHost(\n this._getCachingTypeScriptSystem(ts),\n ts.createEmitAndSemanticDiagnosticsBuilderProgram,\n reportDiagnostic,\n reportSolutionBuilderStatus,\n reportEmitErrorSummary\n );\n\n return compilerHost;\n }\n\n private _buildIncrementalCompilerHost(\n ts: ExtendedTypeScript,\n tsconfig: TTypescript.ParsedCommandLine\n ): TTypescript.CompilerHost {\n if (tsconfig.options.incremental) {\n return ts.createIncrementalCompilerHost(tsconfig.options, this._getCachingTypeScriptSystem(ts));\n } else {\n return ts.createCompilerHost(tsconfig.options);\n }\n }\n\n private _getCachingTypeScriptSystem(ts: ExtendedTypeScript): TTypescript.System {\n const sys: TTypescript.System = {\n ...ts.sys,\n deleteFile: this._cachedFileSystem.deleteFile.bind(this._cachedFileSystem),\n /** Check if the path exists and is a directory */\n directoryExists: (directoryPath: string) => {\n try {\n const stats: FileSystemStats = this._cachedFileSystem.getStatistics(directoryPath);\n return stats.isDirectory() || stats.isSymbolicLink();\n } catch (error) {\n if (FileSystem.isNotExistError(error as Error)) {\n return false;\n } else {\n throw error;\n }\n }\n },\n /** Check if the path exists and is a file */\n fileExists: (filePath: string) => {\n try {\n const stats: FileSystemStats = this._cachedFileSystem.getStatistics(filePath);\n return stats.isFile();\n } catch (error) {\n if (FileSystem.isNotExistError(error as Error)) {\n return false;\n } else {\n throw error;\n }\n }\n },\n /* Use the Heft config's build folder because it has corrected casing */\n getCurrentDirectory: () => this._configuration.buildFolderPath,\n getDirectories: (folderPath: string) => {\n return this._cachedFileSystem.readFolderFilesAndDirectories(folderPath).directories;\n },\n realpath: this._cachedFileSystem.getRealPath.bind(this._cachedFileSystem)\n };\n\n return sys;\n }\n\n // private _buildWatchCompilerHost(\n // ts: ExtendedTypeScript,\n // tsconfig: TTypescript.ParsedCommandLine\n // ): TWatchCompilerHost {\n // const reportDiagnostic: TTypescript.DiagnosticReporter = (diagnostic: TTypescript.Diagnostic): void => {\n // this._printDiagnosticMessage(ts, diagnostic);\n // };\n // const reportWatchStatus: TTypescript.DiagnosticReporter = (diagnostic: TTypescript.Diagnostic) => {\n // this._printDiagnosticMessage(ts, diagnostic);\n\n // // In watch mode, notify EmitCompletedCallbackManager every time we finish recompiling.\n // if (\n // diagnostic.code === ts.Diagnostics.Found_0_errors_Watching_for_file_changes.code ||\n // diagnostic.code === ts.Diagnostics.Found_1_error_Watching_for_file_changes.code\n // ) {\n // this._emitCompletedCallbackManager.callback();\n // }\n // };\n\n // return ts.createWatchCompilerHost(\n // tsconfig.fileNames,\n // tsconfig.options,\n // this._getCachingTypeScriptSystem(ts),\n // ts.createEmitAndSemanticDiagnosticsBuilderProgram,\n // reportDiagnostic,\n // reportWatchStatus,\n // tsconfig.projectReferences\n // );\n // }\n\n // private _buildWatchSolutionBuilderHost(ts: ExtendedTypeScript): TWatchSolutionHost {\n // const reportDiagnostic: TTypescript.DiagnosticReporter = (diagnostic: TTypescript.Diagnostic): void => {\n // this._printDiagnosticMessage(ts, diagnostic);\n // };\n // const reportSolutionBuilderStatus: TTypescript.DiagnosticReporter = reportDiagnostic;\n // const reportWatchStatus: TTypescript.DiagnosticReporter = (diagnostic: TTypescript.Diagnostic) => {\n // this._printDiagnosticMessage(ts, diagnostic);\n\n // // In watch mode, notify EmitCompletedCallbackManager every time we finish recompiling.\n // if (\n // diagnostic.code === ts.Diagnostics.Found_0_errors_Watching_for_file_changes.code ||\n // diagnostic.code === ts.Diagnostics.Found_1_error_Watching_for_file_changes.code\n // ) {\n // this._emitCompletedCallbackManager.callback();\n // }\n // };\n\n // return ts.createSolutionBuilderWithWatchHost(\n // this._getCachingTypeScriptSystem(ts),\n // ts.createEmitAndSemanticDiagnosticsBuilderProgram,\n // reportDiagnostic,\n // reportSolutionBuilderStatus,\n // reportWatchStatus\n // );\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,oEASsC;AAItC,qDAA8E;AAC9E,wFAAqF;AAgDrF,4BAA4B;AAC5B,kHAAkH;AAClH,4BAA4B;AAC5B,oGAAoG;AAEpG,MAAM,UAAU,GAAW,EAAE,CAAC;AAiC9B,MAAM,iCAAiC,GAAW,CAAC,CAAC;AACpD,MAAM,iCAAiC,GAAW,CAAC,CAAC;AAEpD,MAAM,iCAAiC,GAAW,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K,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;AA9+BD,8CA8+BC","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 FileSystemStats,\n type ITerminal,\n JsonFile,\n IPackageJson,\n FileSystem,\n Path,\n Async,\n FileError\n} from '@rushstack/node-core-library';\nimport type { IChangedFileState, IScopedLogger } from '@rushstack/heft';\n\nimport type { ExtendedTypeScript } 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>;\n// type TWatchCompilerHost =\n// TTypescript.WatchCompilerHostOfFilesAndCompilerOptions<TTypescript.EmitAndSemanticDiagnosticsBuilderProgram>;\n// type TWatchSolutionHost =\n// TTypescript.SolutionBuilderWithWatchHost<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\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 oldBuilderProgram: TTypescript.EmitAndSemanticDiagnosticsBuilderProgram | undefined;\n oldProgram: TTypescript.Program | undefined;\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(changedFiles?: ReadonlyMap<string, IChangedFileState> | undefined): 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 this._tool = {\n ts,\n\n measureSync: measureTsPerformance,\n measureAsync: measureTsPerformanceAsync,\n\n sourceFileCache: new Map(),\n\n oldBuilderProgram: undefined,\n oldProgram: undefined\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 (changedFiles) {\n const { sourceFileCache } = this._tool;\n for (const file of changedFiles.keys()) {\n // There might need to be a transform to the format of `file` here.\n sourceFileCache.delete(file);\n }\n }\n\n // if (this._configuration.watchMode) {\n // await this._runWatch(ts, measureTsPerformance);\n // } else if (this._useSolutionBuilder) {\n if (this._useSolutionBuilder) {\n this._runSolutionBuild(this._tool);\n } else {\n await this._runBuildAsync(this._tool);\n }\n }\n\n // public async _runWatch(ts: ExtendedTypeScript, measureTsPerformance: PerformanceMeasurer): Promise<void> {\n // //#region CONFIGURE\n // const { duration: configureDurationMs, tsconfig } = measureTsPerformance('Configure', () => {\n // const _tsconfig: TTypescript.ParsedCommandLine = this._loadTsconfig(ts);\n // this._validateTsconfig(ts, _tsconfig);\n // EmitFilesPatch.install(ts, _tsconfig, this._moduleKindsToEmit);\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(ts);\n // const watchBuilder: TTypescript.SolutionBuilder<TTypescript.EmitAndSemanticDiagnosticsBuilderProgram> =\n // ts.createSolutionBuilderWithWatch(solutionHost, [this._configuration.tsconfigPath], {});\n\n // watchBuilder.build();\n // } else {\n // const compilerHost: TWatchCompilerHost = this._buildWatchCompilerHost(ts, tsconfig);\n // ts.createWatchProgram(compilerHost);\n // }\n\n // return new Promise(() => {\n // /* never terminate */\n // });\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 if (!tool.oldBuilderProgram) {\n tool.oldBuilderProgram = ts.readBuilderProgram(tsconfig.options, compilerHost);\n }\n\n builderProgram = ts.createEmitAndSemanticDiagnosticsBuilderProgram(\n tsconfig.fileNames,\n tsconfig.options,\n compilerHost,\n tool.oldBuilderProgram,\n ts.getConfigFileParsingDiagnostics(tsconfig),\n tsconfig.projectReferences\n );\n tool.oldBuilderProgram = builderProgram;\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: tool.oldProgram,\n configFileParsingDiagnostics: ts.getConfigFileParsingDiagnostics(tsconfig)\n });\n tool.oldProgram = tsProgram;\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, tsconfig, 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 } = tool;\n\n try {\n //#region CONFIGURE\n const {\n duration: configureDurationMs,\n rawDiagnostics,\n solutionBuilderHost\n } = measureSync('Configure', () => {\n this._overrideTypeScriptReadJson(ts);\n const _tsconfig: TTypescript.ParsedCommandLine = this._loadTsconfig(ts);\n this._validateTsconfig(ts, _tsconfig);\n\n const _rawDiagnostics: TTypescript.Diagnostic[] = [];\n const reportDiagnostic: TTypescript.DiagnosticReporter = (diagnostic: TTypescript.Diagnostic) => {\n _rawDiagnostics.push(diagnostic);\n };\n\n // TypeScript doesn't have a way to find out when a given program starts emitting in solution mode\n EmitFilesPatch.install(ts, _tsconfig, this._moduleKindsToEmit);\n\n const _solutionBuilderHost: TSolutionHost = this._buildSolutionBuilderHost(ts, reportDiagnostic);\n\n _solutionBuilderHost.afterProgramEmitAndDiagnostics = (\n program: TTypescript.EmitAndSemanticDiagnosticsBuilderProgram\n ) => {\n const tsProgram: TTypescript.Program | undefined = program.getProgram();\n if (tsProgram) {\n this._configuration.emitChangedFilesCallback(tsProgram);\n }\n };\n\n return {\n rawDiagnostics: _rawDiagnostics,\n solutionBuilderHost: _solutionBuilderHost\n };\n });\n this._typescriptTerminal.writeVerboseLine(`Configure: ${configureDurationMs}ms`);\n //#endregion\n\n const solutionBuilder: TTypescript.SolutionBuilder<TTypescript.EmitAndSemanticDiagnosticsBuilderProgram> =\n ts.createSolutionBuilder(solutionBuilderHost, [this._configuration.tsconfigPath], {});\n\n //#region EMIT\n // Ignoring the exit status because we only care about presence of diagnostics\n solutionBuilder.build();\n //#endregion\n\n this._logReadPerformance(ts);\n this._logEmitPerformance(ts);\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 this._logDiagnostics(ts, rawDiagnostics);\n } finally {\n EmitFilesPatch.uninstall(ts);\n }\n }\n\n private _logDiagnostics(ts: ExtendedTypeScript, rawDiagnostics: readonly TTypescript.Diagnostic[]): void {\n const diagnostics: readonly TTypescript.Diagnostic[] = ts.sortAndDeduplicateDiagnostics(rawDiagnostics);\n\n let typeScriptErrorCount: number = 0;\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 if (diagnosticCategory === ts.DiagnosticCategory.Error) {\n typeScriptErrorCount++;\n }\n\n this._printDiagnosticMessage(ts, diagnostic, diagnosticCategory);\n }\n }\n\n if (typeScriptErrorCount > 0) {\n throw new Error(`Encountered TypeScript error${typeScriptErrorCount > 1 ? 's' : ''}`);\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 tsconfig: TTypescript.ParsedCommandLine,\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, tsconfig, 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 _buildSolutionBuilderHost(\n ts: ExtendedTypeScript,\n reportDiagnostic: TTypescript.DiagnosticReporter\n ): TSolutionHost {\n const reportSolutionBuilderStatus: TTypescript.DiagnosticReporter = reportDiagnostic;\n const reportEmitErrorSummary: TTypescript.ReportEmitErrorSummary = (errorCount: number): void => {\n // Do nothing\n };\n\n const compilerHost: TTypescript.SolutionBuilderHost<TTypescript.EmitAndSemanticDiagnosticsBuilderProgram> =\n ts.createSolutionBuilderHost(\n this._getCachingTypeScriptSystem(ts),\n ts.createEmitAndSemanticDiagnosticsBuilderProgram,\n reportDiagnostic,\n reportSolutionBuilderStatus,\n reportEmitErrorSummary\n );\n\n return compilerHost;\n }\n\n private _buildIncrementalCompilerHost(\n tool: ITypeScriptTool,\n tsconfig: TTypescript.ParsedCommandLine\n ): TTypescript.CompilerHost {\n const { ts, sourceFileCache } = tool;\n\n let compilerHost: TTypescript.CompilerHost | undefined;\n\n if (tsconfig.options.incremental) {\n compilerHost = ts.createIncrementalCompilerHost(tsconfig.options, this._getCachingTypeScriptSystem(ts));\n } else {\n compilerHost = ts.createCompilerHost(tsconfig.options);\n }\n\n const { getSourceFile: innerGetSourceFile } = compilerHost;\n\n // Enable source file persistence\n const getSourceFile: typeof innerGetSourceFile = (\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 compilerHost.getSourceFile = getSourceFile;\n\n return compilerHost;\n }\n\n private _getCachingTypeScriptSystem(ts: ExtendedTypeScript): TTypescript.System {\n const sys: TTypescript.System = {\n ...ts.sys,\n deleteFile: this._cachedFileSystem.deleteFile.bind(this._cachedFileSystem),\n /** Check if the path exists and is a directory */\n directoryExists: (directoryPath: string) => {\n try {\n const stats: FileSystemStats = this._cachedFileSystem.getStatistics(directoryPath);\n return stats.isDirectory() || stats.isSymbolicLink();\n } catch (error) {\n if (FileSystem.isNotExistError(error as Error)) {\n return false;\n } else {\n throw error;\n }\n }\n },\n /** Check if the path exists and is a file */\n fileExists: (filePath: string) => {\n try {\n const stats: FileSystemStats = this._cachedFileSystem.getStatistics(filePath);\n return stats.isFile();\n } catch (error) {\n if (FileSystem.isNotExistError(error as Error)) {\n return false;\n } else {\n throw error;\n }\n }\n },\n /* Use the Heft config's build folder because it has corrected casing */\n getCurrentDirectory: () => this._configuration.buildFolderPath,\n getDirectories: (folderPath: string) => {\n return this._cachedFileSystem.readFolderFilesAndDirectories(folderPath).directories;\n },\n realpath: this._cachedFileSystem.getRealPath.bind(this._cachedFileSystem)\n };\n\n return sys;\n }\n\n // private _buildWatchCompilerHost(\n // ts: ExtendedTypeScript,\n // tsconfig: TTypescript.ParsedCommandLine\n // ): TWatchCompilerHost {\n // const reportDiagnostic: TTypescript.DiagnosticReporter = (diagnostic: TTypescript.Diagnostic): void => {\n // this._printDiagnosticMessage(ts, diagnostic);\n // };\n // const reportWatchStatus: TTypescript.DiagnosticReporter = (diagnostic: TTypescript.Diagnostic) => {\n // this._printDiagnosticMessage(ts, diagnostic);\n\n // // In watch mode, notify EmitCompletedCallbackManager every time we finish recompiling.\n // if (\n // diagnostic.code === ts.Diagnostics.Found_0_errors_Watching_for_file_changes.code ||\n // diagnostic.code === ts.Diagnostics.Found_1_error_Watching_for_file_changes.code\n // ) {\n // this._emitCompletedCallbackManager.callback();\n // }\n // };\n\n // return ts.createWatchCompilerHost(\n // tsconfig.fileNames,\n // tsconfig.options,\n // this._getCachingTypeScriptSystem(ts),\n // ts.createEmitAndSemanticDiagnosticsBuilderProgram,\n // reportDiagnostic,\n // reportWatchStatus,\n // tsconfig.projectReferences\n // );\n // }\n\n // private _buildWatchSolutionBuilderHost(ts: ExtendedTypeScript): TWatchSolutionHost {\n // const reportDiagnostic: TTypescript.DiagnosticReporter = (diagnostic: TTypescript.Diagnostic): void => {\n // this._printDiagnosticMessage(ts, diagnostic);\n // };\n // const reportSolutionBuilderStatus: TTypescript.DiagnosticReporter = reportDiagnostic;\n // const reportWatchStatus: TTypescript.DiagnosticReporter = (diagnostic: TTypescript.Diagnostic) => {\n // this._printDiagnosticMessage(ts, diagnostic);\n\n // // In watch mode, notify EmitCompletedCallbackManager every time we finish recompiling.\n // if (\n // diagnostic.code === ts.Diagnostics.Found_0_errors_Watching_for_file_changes.code ||\n // diagnostic.code === ts.Diagnostics.Found_1_error_Watching_for_file_changes.code\n // ) {\n // this._emitCompletedCallbackManager.callback();\n // }\n // };\n\n // return ts.createSolutionBuilderWithWatchHost(\n // this._getCachingTypeScriptSystem(ts),\n // ts.createEmitAndSemanticDiagnosticsBuilderProgram,\n // reportDiagnostic,\n // reportSolutionBuilderStatus,\n // reportWatchStatus\n // );\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"]}
@@ -7,7 +7,7 @@ import type { HeftConfiguration, IHeftTaskSession, IHeftTaskPlugin } from '@rush
7
7
  *
8
8
  * @public
9
9
  */
10
- export declare const PLUGIN_NAME: 'TypeScriptPlugin';
10
+ export declare const PLUGIN_NAME: 'typescript-plugin';
11
11
  /**
12
12
  * @beta
13
13
  */
@@ -94,9 +94,8 @@ export declare function loadPartialTsconfigFileAsync(heftConfiguration: HeftConf
94
94
  export default class TypeScriptPlugin implements IHeftTaskPlugin {
95
95
  accessor: ITypeScriptPluginAccessor;
96
96
  apply(taskSession: IHeftTaskSession, heftConfiguration: HeftConfiguration): void;
97
- private _updateClean;
98
97
  private _updateStaticAssetsToCopy;
99
- private _runTypeScriptAsync;
98
+ private _getTypeScriptBuilderAsync;
100
99
  private _getTsconfigOutDirAsync;
101
100
  }
102
101
  //# sourceMappingURL=TypeScriptPlugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TypeScriptPlugin.d.ts","sourceRoot":"","sources":["../src/TypeScriptPlugin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,WAAW,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAoB,KAAK,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEhF,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EAGhB,MAAM,iBAAiB,CAAC;AAIzB;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,kBAAuC,CAAC;AAElE;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,UAAU,GAAG,KAAK,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;IACxE,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC7C,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C;;;OAGG;IACH,2BAA2B,CAAC,EAAE,eAAe,EAAE,GAAG,SAAS,CAAC;IAE5D;;OAEG;IACH,2BAA2B,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAElD;;OAEG;IACH,2BAA2B,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAElD;;;OAGG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IAOjC,OAAO,CAAC,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AC;CACnD;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC;IAC7B,YAAY,CAAC,EAAE,WAAW,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;CACpD;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,kBAAkB,EAAE,QAAQ,CAAC,wBAAwB,CAAC,CAAC;CACjE;AAQD;;GAEG;AACH,wBAAsB,oCAAoC,CACxD,iBAAiB,EAAE,iBAAiB,EACpC,QAAQ,EAAE,SAAS,GAClB,OAAO,CAAC,4BAA4B,GAAG,SAAS,CAAC,CAiCnD;AAcD;;GAEG;AACH,wBAAsB,4BAA4B,CAChD,iBAAiB,EAAE,iBAAiB,EACpC,QAAQ,EAAE,SAAS,EACnB,2BAA2B,EAAE,4BAA4B,GAAG,SAAS,GACpE,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CA+CvC;AAED,MAAM,CAAC,OAAO,OAAO,gBAAiB,YAAW,eAAe;IACvD,QAAQ,EAAE,yBAAyB,CAExC;IAEK,KAAK,CAAC,WAAW,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,iBAAiB,GAAG,IAAI;YAsCzE,yBAAyB;YAyCzB,0BAA0B;YA4D1B,uBAAuB;CAYtC"}
@@ -12,7 +12,7 @@ const TypeScriptBuilder_1 = require("./TypeScriptBuilder");
12
12
  *
13
13
  * @public
14
14
  */
15
- exports.PLUGIN_NAME = 'TypeScriptPlugin';
15
+ exports.PLUGIN_NAME = 'typescript-plugin';
16
16
  let _typeScriptConfigurationFileLoader;
17
17
  const _typeScriptConfigurationFilePromiseCache = new Map();
18
18
  /**
@@ -99,33 +99,32 @@ class TypeScriptPlugin {
99
99
  };
100
100
  }
101
101
  apply(taskSession, heftConfiguration) {
102
- taskSession.hooks.clean.tapPromise(exports.PLUGIN_NAME, async (cleanOptions) => {
103
- await this._updateClean(taskSession, heftConfiguration, cleanOptions);
104
- });
105
102
  taskSession.hooks.run.tapPromise(exports.PLUGIN_NAME, async (runOptions) => {
106
- await this._runTypeScriptAsync(taskSession, heftConfiguration);
103
+ const builder = await this._getTypeScriptBuilderAsync(taskSession, heftConfiguration);
104
+ if (builder) {
105
+ await builder.invokeAsync();
106
+ }
107
107
  // TODO: We should consider maybe only doing one copy of static assets and pointing
108
108
  // all source files to this set of static assets. This would allow us to avoid
109
109
  // having to copy the static assets multiple times, increasing build times and
110
110
  // package size.
111
111
  await this._updateStaticAssetsToCopy(taskSession, heftConfiguration, runOptions);
112
112
  });
113
- }
114
- async _updateClean(taskSession, heftConfiguration, cleanOptions) {
115
- const configurationFile = await loadTypeScriptConfigurationFileAsync(heftConfiguration, taskSession.logger.terminal);
116
- // For now, delete the entire output folder and additional module kind output folders. In the future,
117
- // we may want to clean specific files that we know are produced by the TypeScript compiler.
118
- const tsconfigOutDir = await this._getTsconfigOutDirAsync(taskSession, heftConfiguration, configurationFile);
119
- if (tsconfigOutDir) {
120
- cleanOptions.addDeleteOperations({ sourcePath: tsconfigOutDir });
121
- }
122
- if (configurationFile === null || configurationFile === void 0 ? void 0 : configurationFile.additionalModuleKindsToEmit) {
123
- for (const additionalModuleKindToEmit of configurationFile.additionalModuleKindsToEmit) {
124
- cleanOptions.addDeleteOperations({
125
- sourcePath: `${heftConfiguration.buildFolderPath}/${additionalModuleKindToEmit.outFolderName}`
126
- });
113
+ let incrementalBuilder;
114
+ taskSession.hooks.runIncremental.tapPromise(exports.PLUGIN_NAME, async (runIncrementalOptions) => {
115
+ if (incrementalBuilder === undefined) {
116
+ // eslint-disable-next-line require-atomic-updates
117
+ incrementalBuilder = await this._getTypeScriptBuilderAsync(taskSession, heftConfiguration);
127
118
  }
128
- }
119
+ if (incrementalBuilder) {
120
+ await incrementalBuilder.invokeAsync(runIncrementalOptions.changedFiles);
121
+ }
122
+ // TODO: We should consider maybe only doing one copy of static assets and pointing
123
+ // all source files to this set of static assets. This would allow us to avoid
124
+ // having to copy the static assets multiple times, increasing build times and
125
+ // package size.
126
+ await this._updateStaticAssetsToCopy(taskSession, heftConfiguration, runIncrementalOptions);
127
+ });
129
128
  }
130
129
  async _updateStaticAssetsToCopy(taskSession, heftConfiguration, runOptions) {
131
130
  var _a, _b, _c, _d, _e, _f;
@@ -148,19 +147,23 @@ class TypeScriptPlugin {
148
147
  sourcePath: 'src', destinationFolders: Array.from(destinationFolderPaths), flatten: false, hardlink: false }));
149
148
  }
150
149
  }
151
- async _runTypeScriptAsync(taskSession, heftConfiguration) {
150
+ async _getTypeScriptBuilderAsync(taskSession, heftConfiguration) {
152
151
  const terminal = taskSession.logger.terminal;
153
- const typeScriptToolPath = await heftConfiguration.rigPackageResolver.resolvePackageAsync('typescript', terminal);
154
152
  const typeScriptConfigurationJson = await loadTypeScriptConfigurationFileAsync(heftConfiguration, terminal);
155
153
  const partialTsconfigFile = await loadPartialTsconfigFileAsync(heftConfiguration, terminal, typeScriptConfigurationJson);
156
154
  if (!partialTsconfigFile) {
157
155
  // There is no tsconfig file, we can exit early
158
- return;
156
+ // This check may need watch mode to break on tsconfig addition/deletion
157
+ return false;
159
158
  }
159
+ const typeScriptToolPath = await heftConfiguration.rigPackageResolver.resolvePackageAsync('typescript', terminal);
160
160
  // Build out the configuration
161
161
  const typeScriptBuilderConfiguration = {
162
162
  buildFolderPath: heftConfiguration.buildFolderPath,
163
- buildMetadataFolderPath: taskSession.cacheFolderPath,
163
+ // Use tempFolderPath instead of cacheFolderPath. Running a clean will delete build outputs
164
+ // which the metadata file will imply are unchanged, causing typescript to avoid building
165
+ // these files. Since cleaning will delete files in the temp folder path, place it there.
166
+ buildMetadataFolderPath: taskSession.tempFolderPath,
164
167
  typeScriptToolPath: typeScriptToolPath,
165
168
  buildProjectReferences: typeScriptConfigurationJson === null || typeScriptConfigurationJson === void 0 ? void 0 : typeScriptConfigurationJson.buildProjectReferences,
166
169
  tsconfigPath: getTsconfigFilePath(heftConfiguration, typeScriptConfigurationJson),
@@ -179,7 +182,7 @@ class TypeScriptPlugin {
179
182
  };
180
183
  // Run the builder
181
184
  const typeScriptBuilder = new TypeScriptBuilder_1.TypeScriptBuilder(typeScriptBuilderConfiguration);
182
- await typeScriptBuilder.invokeAsync();
185
+ return typeScriptBuilder;
183
186
  }
184
187
  async _getTsconfigOutDirAsync(taskSession, heftConfiguration, typeScriptConfiguration) {
185
188
  var _a;
@@ -1 +1 @@
1
- {"version":3,"file":"TypeScriptPlugin.js","sourceRoot":"","sources":["../src/TypeScriptPlugin.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,qCAAmC;AACnC,oEAAgF;AAChF,kEAAuG;AASvG,2DAAyF;AAEzF;;;;GAIG;AACU,QAAA,WAAW,GAAuB,kBAAkB,CAAC;AA+FlE,IAAI,kCAA+F,CAAC;AACpG,MAAM,wCAAwC,GAG1C,IAAI,GAAG,EAAE,CAAC;AAEd;;GAEG;AACI,KAAK,UAAU,oCAAoC,CACxD,iBAAoC,EACpC,QAAmB;IAEnB,MAAM,eAAe,GAAW,iBAAiB,CAAC,eAAe,CAAC;IAElE,wBAAwB;IACxB,IAAI,kCAAkC,GACpC,wCAAwC,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAEhE,IAAI,CAAC,kCAAkC,EAAE;QACvC,oDAAoD;QACpD,IAAI,CAAC,kCAAkC,EAAE;YACvC,MAAM,UAAU,GAAW,GAAG,SAAS,iCAAiC,CAAC;YACzE,kCAAkC,GAAG,IAAI,oCAAiB,CAA+B;gBACvF,uBAAuB,EAAE,wBAAwB;gBACjD,cAAc,EAAE,UAAU;gBAC1B,mBAAmB,EAAE;oBACnB,kBAAkB,EAAE;wBAClB,8DAA8D;wBAC9D,eAAe,EAAE,kCAAe,CAAC,KAAK;qBACvC;iBACF;aACF,CAAC,CAAC;SACJ;QAED,kCAAkC;YAChC,kCAAkC,CAAC,uCAAuC,CACxE,QAAQ,EACR,eAAe,EACf,iBAAiB,CAAC,SAAS,CAC5B,CAAC;QACJ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QAAQ,EAC3B,uBAAuB,CACxB,CAAC;QACF,OAAO,MAAA,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAE,eAAe,0CAAE,MAAM,CAAC;IACtD,CAAC;CACF;AA7JD,mCA6JC","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';\nimport { SyncHook } from 'tapable';\nimport { FileSystem, Path, type ITerminal } from '@rushstack/node-core-library';\nimport { ConfigurationFile, InheritanceType, PathResolutionMethod } from '@rushstack/heft-config-file';\nimport type {\n HeftConfiguration,\n IHeftTaskSession,\n IHeftTaskPlugin,\n IHeftTaskRunHookOptions,\n IHeftTaskCleanHookOptions\n} from '@rushstack/heft';\n\nimport { TypeScriptBuilder, ITypeScriptBuilderConfiguration } from './TypeScriptBuilder';\n\n/**\n * The name of the plugin, as specified in heft-plugin.json\n *\n * @public\n */\nexport const PLUGIN_NAME: 'TypeScriptPlugin' = 'TypeScriptPlugin';\n\n/**\n * @beta\n */\nexport interface IEmitModuleKind {\n moduleKind: 'commonjs' | 'amd' | 'umd' | 'system' | 'es2015' | 'esnext';\n outFolderName: string;\n jsExtensionOverride?: string;\n}\n\n/**\n * @beta\n */\nexport interface IStaticAssetsCopyConfiguration {\n fileExtensions: string[];\n excludeGlobs: string[];\n includeGlobs: string[];\n}\n\n/**\n * @beta\n */\nexport interface ITypeScriptConfigurationJson {\n /**\n * If provided, emit these module kinds in addition to the modules specified in the tsconfig.\n * Note that this option only applies to the main tsconfig.json configuration.\n */\n additionalModuleKindsToEmit?: IEmitModuleKind[] | undefined;\n\n /**\n * If 'true', emit CommonJS output into the TSConfig outDir with the file extension '.cjs'\n */\n emitCjsExtensionForCommonJS?: boolean | undefined;\n\n /**\n * If 'true', emit ESModule output into the TSConfig outDir with the file extension '.mjs'\n */\n emitMjsExtensionForESModule?: boolean | undefined;\n\n /**\n * If true, enable behavior analogous to the \"tsc --build\" command. Will build projects referenced by the main project in dependency order.\n * Note that this will effectively enable \\\"noEmitOnError\\\".\n */\n buildProjectReferences?: boolean;\n\n /*\n * Specifies the tsconfig.json file that will be used for compilation. Equivalent to the \"project\" argument for the 'tsc' and 'tslint' command line tools.\n *\n * The default value is \"./tsconfig.json\"\n */\n project?: string;\n\n /**\n * Configures additional file types that should be copied into the TypeScript compiler's emit folders, for example\n * so that these files can be resolved by import statements.\n */\n staticAssetsToCopy?: IStaticAssetsCopyConfiguration;\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/**\n * @beta\n */\nexport interface IPartialTsconfigCompilerOptions {\n outDir?: string;\n}\n\n/**\n * @beta\n */\nexport interface IPartialTsconfig {\n compilerOptions?: IPartialTsconfigCompilerOptions;\n}\n\n/**\n * @beta\n */\nexport interface IChangedFilesHookOptions {\n program: TTypescript.Program;\n changedFiles?: ReadonlySet<TTypescript.SourceFile>;\n}\n\n/**\n * @beta\n */\nexport interface ITypeScriptPluginAccessor {\n readonly onChangedFilesHook: SyncHook<IChangedFilesHookOptions>;\n}\n\nlet _typeScriptConfigurationFileLoader: ConfigurationFile<ITypeScriptConfigurationJson> | undefined;\nconst _typeScriptConfigurationFilePromiseCache: Map<\n string,\n Promise<ITypeScriptConfigurationJson | undefined>\n> = new Map();\n\n/**\n * @beta\n */\nexport async function loadTypeScriptConfigurationFileAsync(\n heftConfiguration: HeftConfiguration,\n terminal: ITerminal\n): Promise<ITypeScriptConfigurationJson | undefined> {\n const buildFolderPath: string = heftConfiguration.buildFolderPath;\n\n // Check the cache first\n let typescriptConfigurationFilePromise: Promise<ITypeScriptConfigurationJson | undefined> | undefined =\n _typeScriptConfigurationFilePromiseCache.get(buildFolderPath);\n\n if (!typescriptConfigurationFilePromise) {\n // Ensure that the file loader has been initialized.\n if (!_typeScriptConfigurationFileLoader) {\n const schemaPath: string = `${__dirname}/schemas/typescript.schema.json`;\n _typeScriptConfigurationFileLoader = new ConfigurationFile<ITypeScriptConfigurationJson>({\n projectRelativeFilePath: 'config/typescript.json',\n jsonSchemaPath: schemaPath,\n propertyInheritance: {\n staticAssetsToCopy: {\n // When merging objects, arrays will be automatically appended\n inheritanceType: InheritanceType.merge\n }\n }\n });\n }\n\n typescriptConfigurationFilePromise =\n _typeScriptConfigurationFileLoader.tryLoadConfigurationFileForProjectAsync(\n terminal,\n buildFolderPath,\n heftConfiguration.rigConfig\n );\n _typeScriptConfigurationFilePromiseCache.set(buildFolderPath, typescriptConfigurationFilePromise);\n }\n\n return await typescriptConfigurationFilePromise;\n}\n\nlet _partialTsconfigFileLoader: ConfigurationFile<IPartialTsconfig> | undefined;\nconst _partialTsconfigFilePromiseCache: Map<string, Promise<IPartialTsconfig | undefined>> = new Map();\n\nfunction getTsconfigFilePath(\n heftConfiguration: HeftConfiguration,\n typeScriptConfigurationJson?: ITypeScriptConfigurationJson\n): string {\n return Path.convertToSlashes(\n `${heftConfiguration.buildFolderPath}/${typeScriptConfigurationJson?.project || './tsconfig.json'}`\n );\n}\n\n/**\n * @beta\n */\nexport async function loadPartialTsconfigFileAsync(\n heftConfiguration: HeftConfiguration,\n terminal: ITerminal,\n typeScriptConfigurationJson: ITypeScriptConfigurationJson | undefined\n): Promise<IPartialTsconfig | undefined> {\n const buildFolderPath: string = heftConfiguration.buildFolderPath;\n\n // Check the cache first\n let partialTsconfigFilePromise: Promise<IPartialTsconfig | undefined> | undefined =\n _partialTsconfigFilePromiseCache.get(buildFolderPath);\n\n if (!partialTsconfigFilePromise) {\n // We don't want to load the tsconfig.json file through the rig, but we do want to take\n // advantage of the extends functionality that ConfigurationFile provides. So we'll\n // check to see if the file exists and exit early if not.\n\n const tsconfigFilePath: string = getTsconfigFilePath(heftConfiguration, typeScriptConfigurationJson);\n terminal.writeVerboseLine(`Looking for tsconfig at ${tsconfigFilePath}`);\n const tsconfigExists: boolean = await FileSystem.existsAsync(tsconfigFilePath);\n if (!tsconfigExists) {\n partialTsconfigFilePromise = Promise.resolve(undefined);\n } else {\n // Ensure that the file loader has been initialized.\n if (!_partialTsconfigFileLoader) {\n const schemaPath: string = `${__dirname}/schemas/anything.schema.json`;\n _partialTsconfigFileLoader = new ConfigurationFile<IPartialTsconfig>({\n projectRelativeFilePath: 'tsconfig.json',\n jsonSchemaPath: schemaPath,\n propertyInheritance: {\n compilerOptions: {\n inheritanceType: InheritanceType.merge\n }\n },\n jsonPathMetadata: {\n '$.compilerOptions.outDir': {\n pathResolutionMethod: PathResolutionMethod.resolvePathRelativeToConfigurationFile\n }\n }\n });\n }\n\n partialTsconfigFilePromise = _partialTsconfigFileLoader.loadConfigurationFileForProjectAsync(\n terminal,\n buildFolderPath,\n heftConfiguration.rigConfig\n );\n }\n _partialTsconfigFilePromiseCache.set(buildFolderPath, partialTsconfigFilePromise);\n }\n\n return await partialTsconfigFilePromise;\n}\n\nexport default class TypeScriptPlugin implements IHeftTaskPlugin {\n public accessor: ITypeScriptPluginAccessor = {\n onChangedFilesHook: new SyncHook<IChangedFilesHookOptions>(['changedFilesHookOptions'])\n };\n\n public apply(taskSession: IHeftTaskSession, heftConfiguration: HeftConfiguration): void {\n taskSession.hooks.clean.tapPromise(PLUGIN_NAME, async (cleanOptions: IHeftTaskCleanHookOptions) => {\n await this._updateClean(taskSession, heftConfiguration, cleanOptions);\n });\n\n taskSession.hooks.run.tapPromise(PLUGIN_NAME, async (runOptions: IHeftTaskRunHookOptions) => {\n await this._runTypeScriptAsync(taskSession, heftConfiguration);\n // TODO: We should consider maybe only doing one copy of static assets and pointing\n // all source files to this set of static assets. This would allow us to avoid\n // having to copy the static assets multiple times, increasing build times and\n // package size.\n await this._updateStaticAssetsToCopy(taskSession, heftConfiguration, runOptions);\n });\n }\n\n private async _updateClean(\n taskSession: IHeftTaskSession,\n heftConfiguration: HeftConfiguration,\n cleanOptions: IHeftTaskCleanHookOptions\n ): Promise<void> {\n const configurationFile: ITypeScriptConfigurationJson | undefined =\n await loadTypeScriptConfigurationFileAsync(heftConfiguration, taskSession.logger.terminal);\n\n // For now, delete the entire output folder and additional module kind output folders. In the future,\n // we may want to clean specific files that we know are produced by the TypeScript compiler.\n const tsconfigOutDir: string | undefined = await this._getTsconfigOutDirAsync(\n taskSession,\n heftConfiguration,\n configurationFile\n );\n if (tsconfigOutDir) {\n cleanOptions.addDeleteOperations({ sourcePath: tsconfigOutDir });\n }\n\n if (configurationFile?.additionalModuleKindsToEmit) {\n for (const additionalModuleKindToEmit of configurationFile.additionalModuleKindsToEmit) {\n cleanOptions.addDeleteOperations({\n sourcePath: `${heftConfiguration.buildFolderPath}/${additionalModuleKindToEmit.outFolderName}`\n });\n }\n }\n }\n\n private async _updateStaticAssetsToCopy(\n taskSession: IHeftTaskSession,\n heftConfiguration: HeftConfiguration,\n runOptions: IHeftTaskRunHookOptions\n ): Promise<void> {\n const typeScriptConfiguration: ITypeScriptConfigurationJson | undefined =\n await loadTypeScriptConfigurationFileAsync(heftConfiguration, taskSession.logger.terminal);\n\n // We only care about the copy if static assets were specified.\n if (\n typeScriptConfiguration?.staticAssetsToCopy?.fileExtensions?.length ||\n typeScriptConfiguration?.staticAssetsToCopy?.includeGlobs?.length ||\n typeScriptConfiguration?.staticAssetsToCopy?.excludeGlobs?.length\n ) {\n const destinationFolderPaths: Set<string> = new Set<string>();\n\n // Add the output folder and all additional module kind output folders as destinations\n const tsconfigOutDir: string | undefined = await this._getTsconfigOutDirAsync(\n taskSession,\n heftConfiguration,\n typeScriptConfiguration\n );\n if (tsconfigOutDir) {\n destinationFolderPaths.add(tsconfigOutDir);\n }\n for (const emitModule of typeScriptConfiguration?.additionalModuleKindsToEmit || []) {\n destinationFolderPaths.add(`${heftConfiguration.buildFolderPath}/${emitModule.outFolderName}`);\n }\n\n runOptions.addCopyOperations({\n ...typeScriptConfiguration?.staticAssetsToCopy,\n\n // For now - these may need to be revised later\n sourcePath: 'src',\n destinationFolders: Array.from(destinationFolderPaths),\n flatten: false,\n hardlink: false\n });\n }\n }\n\n private async _runTypeScriptAsync(\n taskSession: IHeftTaskSession,\n heftConfiguration: HeftConfiguration\n ): Promise<void> {\n const terminal: ITerminal = taskSession.logger.terminal;\n\n const typeScriptToolPath: string = await heftConfiguration.rigPackageResolver.resolvePackageAsync(\n 'typescript',\n terminal\n );\n\n const typeScriptConfigurationJson: ITypeScriptConfigurationJson | undefined =\n await loadTypeScriptConfigurationFileAsync(heftConfiguration, terminal);\n\n const partialTsconfigFile: IPartialTsconfig | undefined = await loadPartialTsconfigFileAsync(\n heftConfiguration,\n terminal,\n typeScriptConfigurationJson\n );\n\n if (!partialTsconfigFile) {\n // There is no tsconfig file, we can exit early\n return;\n }\n\n // Build out the configuration\n const typeScriptBuilderConfiguration: ITypeScriptBuilderConfiguration = {\n buildFolderPath: heftConfiguration.buildFolderPath,\n buildMetadataFolderPath: taskSession.cacheFolderPath,\n typeScriptToolPath: typeScriptToolPath,\n\n buildProjectReferences: typeScriptConfigurationJson?.buildProjectReferences,\n\n tsconfigPath: getTsconfigFilePath(heftConfiguration, typeScriptConfigurationJson),\n additionalModuleKindsToEmit: typeScriptConfigurationJson?.additionalModuleKindsToEmit,\n emitCjsExtensionForCommonJS: !!typeScriptConfigurationJson?.emitCjsExtensionForCommonJS,\n emitMjsExtensionForESModule: !!typeScriptConfigurationJson?.emitMjsExtensionForESModule,\n // watchMode: watchMode,\n maxWriteParallelism: typeScriptConfigurationJson?.maxWriteParallelism || 50,\n scopedLogger: taskSession.logger,\n emitChangedFilesCallback: (\n program: TTypescript.Program,\n changedFiles?: Set<TTypescript.SourceFile>\n ) => {\n // Provide the typescript program dependent plugins\n if (this.accessor.onChangedFilesHook.isUsed()) {\n this.accessor.onChangedFilesHook.call({ program, changedFiles });\n }\n }\n };\n\n // Run the builder\n const typeScriptBuilder: TypeScriptBuilder = new TypeScriptBuilder(typeScriptBuilderConfiguration);\n await typeScriptBuilder.invokeAsync();\n }\n\n private async _getTsconfigOutDirAsync(\n taskSession: IHeftTaskSession,\n heftConfiguration: HeftConfiguration,\n typeScriptConfiguration: ITypeScriptConfigurationJson | undefined\n ): Promise<string | undefined> {\n const partialTsconfigFile: IPartialTsconfig | undefined = await loadPartialTsconfigFileAsync(\n heftConfiguration,\n taskSession.logger.terminal,\n typeScriptConfiguration\n );\n return partialTsconfigFile?.compilerOptions?.outDir;\n }\n}\n"]}
1
+ {"version":3,"file":"TypeScriptPlugin.js","sourceRoot":"","sources":["../src/TypeScriptPlugin.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,qCAAmC;AACnC,oEAAgF;AAChF,kEAAuG;AASvG,2DAAyF;AAEzF;;;;GAIG;AACU,QAAA,WAAW,GAAwB,mBAAmB,CAAC;AA+FpE,IAAI,kCAA+F,CAAC;AACpG,MAAM,wCAAwC,GAG1C,IAAI,GAAG,EAAE,CAAC;AAEd;;GAEG;AACI,KAAK,UAAU,oCAAoC,CACxD,iBAAoC,EACpC,QAAmB;IAEnB,MAAM,eAAe,GAAW,iBAAiB,CAAC,eAAe,CAAC;IAElE,wBAAwB;IACxB,IAAI,kCAAkC,GACpC,wCAAwC,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAEhE,IAAI,CAAC,kCAAkC,EAAE;QACvC,oDAAoD;QACpD,IAAI,CAAC,kCAAkC,EAAE;YACvC,MAAM,UAAU,GAAW,GAAG,SAAS,iCAAiC,CAAC;YACzE,kCAAkC,GAAG,IAAI,oCAAiB,CAA+B;gBACvF,uBAAuB,EAAE,wBAAwB;gBACjD,cAAc,EAAE,UAAU;gBAC1B,mBAAmB,EAAE;oBACnB,kBAAkB,EAAE;wBAClB,8DAA8D;wBAC9D,eAAe,EAAE,kCAAe,CAAC,KAAK;qBACvC;iBACF;aACF,CAAC,CAAC;SACJ;QAED,kCAAkC;YAChC,kCAAkC,CAAC,uCAAuC,CACxE,QAAQ,EACR,eAAe,EACf,iBAAiB,CAAC,SAAS,CAC5B,CAAC;QACJ,wCAAwC,CAAC,GAAG,CAAC,eAAe,E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C;YACjF,2BAA2B,EAAE,2BAA2B,aAA3B,2BAA2B,uBAA3B,2BAA2B,CAAE,2BAA2B;YACrF,2BAA2B,EAAE,CAAC,CAAC,CAAA,2BAA2B,aAA3B,2BAA2B,uBAA3B,2BAA2B,CAAE,2BAA2B,CAAA;YACvF,2BAA2B,EAAE,CAAC,CAAC,CAAA,2BAA2B,aAA3B,2BAA2B,uBAA3B,2BAA2B,CAAE,2BAA2B,CAAA;YACvF,wBAAwB;YACxB,mBAAmB,EAAE,CAAA,2BAA2B,aAA3B,2BAA2B,uBAA3B,2BAA2B,CAAE,mBAAmB,KAAI,EAAE;YAC3E,YAAY,EAAE,WAAW,CAAC,MAAM;YAChC,wBAAwB,EAAE,CACxB,OAA4B,EAC5B,YAA0C,EAC1C,EAAE;gBACF,mDAAmD;gBACnD,IAAI,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,MAAM,EAAE,EAAE;oBAC7C,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC,CAAC;iBAClE;YACH,CAAC;SACF,CAAC;QAEF,kBAAkB;QAClB,MAAM,iBAAiB,GAAsB,IAAI,qCAAiB,CAAC,8BAA8B,CAAC,CAAC;QACnG,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAEO,KAAK,CAAC,uBAAuB,CACnC,WAA6B,EAC7B,iBAAoC,EACpC,uBAAiE;;QAEjE,MAAM,mBAAmB,GAAiC,MAAM,4BAA4B,CAC1F,iBAAiB,EACjB,WAAW,CAAC,MAAM,CAAC,QAAQ,EAC3B,uBAAuB,CACxB,CAAC;QACF,OAAO,MAAA,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAE,eAAe,0CAAE,MAAM,CAAC;IACtD,CAAC;CACF;AA5JD,mCA4JC","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';\nimport { SyncHook } from 'tapable';\nimport { FileSystem, Path, type ITerminal } from '@rushstack/node-core-library';\nimport { ConfigurationFile, InheritanceType, PathResolutionMethod } from '@rushstack/heft-config-file';\nimport type {\n HeftConfiguration,\n IHeftTaskSession,\n IHeftTaskPlugin,\n IHeftTaskRunHookOptions,\n IHeftTaskRunIncrementalHookOptions\n} from '@rushstack/heft';\n\nimport { TypeScriptBuilder, ITypeScriptBuilderConfiguration } from './TypeScriptBuilder';\n\n/**\n * The name of the plugin, as specified in heft-plugin.json\n *\n * @public\n */\nexport const PLUGIN_NAME: 'typescript-plugin' = 'typescript-plugin';\n\n/**\n * @beta\n */\nexport interface IEmitModuleKind {\n moduleKind: 'commonjs' | 'amd' | 'umd' | 'system' | 'es2015' | 'esnext';\n outFolderName: string;\n jsExtensionOverride?: string;\n}\n\n/**\n * @beta\n */\nexport interface IStaticAssetsCopyConfiguration {\n fileExtensions: string[];\n excludeGlobs: string[];\n includeGlobs: string[];\n}\n\n/**\n * @beta\n */\nexport interface ITypeScriptConfigurationJson {\n /**\n * If provided, emit these module kinds in addition to the modules specified in the tsconfig.\n * Note that this option only applies to the main tsconfig.json configuration.\n */\n additionalModuleKindsToEmit?: IEmitModuleKind[] | undefined;\n\n /**\n * If 'true', emit CommonJS output into the TSConfig outDir with the file extension '.cjs'\n */\n emitCjsExtensionForCommonJS?: boolean | undefined;\n\n /**\n * If 'true', emit ESModule output into the TSConfig outDir with the file extension '.mjs'\n */\n emitMjsExtensionForESModule?: boolean | undefined;\n\n /**\n * If true, enable behavior analogous to the \"tsc --build\" command. Will build projects referenced by the main project in dependency order.\n * Note that this will effectively enable \\\"noEmitOnError\\\".\n */\n buildProjectReferences?: boolean;\n\n /*\n * Specifies the tsconfig.json file that will be used for compilation. Equivalent to the \"project\" argument for the 'tsc' and 'tslint' command line tools.\n *\n * The default value is \"./tsconfig.json\"\n */\n project?: string;\n\n /**\n * Configures additional file types that should be copied into the TypeScript compiler's emit folders, for example\n * so that these files can be resolved by import statements.\n */\n staticAssetsToCopy?: IStaticAssetsCopyConfiguration;\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/**\n * @beta\n */\nexport interface IPartialTsconfigCompilerOptions {\n outDir?: string;\n}\n\n/**\n * @beta\n */\nexport interface IPartialTsconfig {\n compilerOptions?: IPartialTsconfigCompilerOptions;\n}\n\n/**\n * @beta\n */\nexport interface IChangedFilesHookOptions {\n program: TTypescript.Program;\n changedFiles?: ReadonlySet<TTypescript.SourceFile>;\n}\n\n/**\n * @beta\n */\nexport interface ITypeScriptPluginAccessor {\n readonly onChangedFilesHook: SyncHook<IChangedFilesHookOptions>;\n}\n\nlet _typeScriptConfigurationFileLoader: ConfigurationFile<ITypeScriptConfigurationJson> | undefined;\nconst _typeScriptConfigurationFilePromiseCache: Map<\n string,\n Promise<ITypeScriptConfigurationJson | undefined>\n> = new Map();\n\n/**\n * @beta\n */\nexport async function loadTypeScriptConfigurationFileAsync(\n heftConfiguration: HeftConfiguration,\n terminal: ITerminal\n): Promise<ITypeScriptConfigurationJson | undefined> {\n const buildFolderPath: string = heftConfiguration.buildFolderPath;\n\n // Check the cache first\n let typescriptConfigurationFilePromise: Promise<ITypeScriptConfigurationJson | undefined> | undefined =\n _typeScriptConfigurationFilePromiseCache.get(buildFolderPath);\n\n if (!typescriptConfigurationFilePromise) {\n // Ensure that the file loader has been initialized.\n if (!_typeScriptConfigurationFileLoader) {\n const schemaPath: string = `${__dirname}/schemas/typescript.schema.json`;\n _typeScriptConfigurationFileLoader = new ConfigurationFile<ITypeScriptConfigurationJson>({\n projectRelativeFilePath: 'config/typescript.json',\n jsonSchemaPath: schemaPath,\n propertyInheritance: {\n staticAssetsToCopy: {\n // When merging objects, arrays will be automatically appended\n inheritanceType: InheritanceType.merge\n }\n }\n });\n }\n\n typescriptConfigurationFilePromise =\n _typeScriptConfigurationFileLoader.tryLoadConfigurationFileForProjectAsync(\n terminal,\n buildFolderPath,\n heftConfiguration.rigConfig\n );\n _typeScriptConfigurationFilePromiseCache.set(buildFolderPath, typescriptConfigurationFilePromise);\n }\n\n return await typescriptConfigurationFilePromise;\n}\n\nlet _partialTsconfigFileLoader: ConfigurationFile<IPartialTsconfig> | undefined;\nconst _partialTsconfigFilePromiseCache: Map<string, Promise<IPartialTsconfig | undefined>> = new Map();\n\nfunction getTsconfigFilePath(\n heftConfiguration: HeftConfiguration,\n typeScriptConfigurationJson?: ITypeScriptConfigurationJson\n): string {\n return Path.convertToSlashes(\n `${heftConfiguration.buildFolderPath}/${typeScriptConfigurationJson?.project || './tsconfig.json'}`\n );\n}\n\n/**\n * @beta\n */\nexport async function loadPartialTsconfigFileAsync(\n heftConfiguration: HeftConfiguration,\n terminal: ITerminal,\n typeScriptConfigurationJson: ITypeScriptConfigurationJson | undefined\n): Promise<IPartialTsconfig | undefined> {\n const buildFolderPath: string = heftConfiguration.buildFolderPath;\n\n // Check the cache first\n let partialTsconfigFilePromise: Promise<IPartialTsconfig | undefined> | undefined =\n _partialTsconfigFilePromiseCache.get(buildFolderPath);\n\n if (!partialTsconfigFilePromise) {\n // We don't want to load the tsconfig.json file through the rig, but we do want to take\n // advantage of the extends functionality that ConfigurationFile provides. So we'll\n // check to see if the file exists and exit early if not.\n\n const tsconfigFilePath: string = getTsconfigFilePath(heftConfiguration, typeScriptConfigurationJson);\n terminal.writeVerboseLine(`Looking for tsconfig at ${tsconfigFilePath}`);\n const tsconfigExists: boolean = await FileSystem.existsAsync(tsconfigFilePath);\n if (!tsconfigExists) {\n partialTsconfigFilePromise = Promise.resolve(undefined);\n } else {\n // Ensure that the file loader has been initialized.\n if (!_partialTsconfigFileLoader) {\n const schemaPath: string = `${__dirname}/schemas/anything.schema.json`;\n _partialTsconfigFileLoader = new ConfigurationFile<IPartialTsconfig>({\n projectRelativeFilePath: 'tsconfig.json',\n jsonSchemaPath: schemaPath,\n propertyInheritance: {\n compilerOptions: {\n inheritanceType: InheritanceType.merge\n }\n },\n jsonPathMetadata: {\n '$.compilerOptions.outDir': {\n pathResolutionMethod: PathResolutionMethod.resolvePathRelativeToConfigurationFile\n }\n }\n });\n }\n\n partialTsconfigFilePromise = _partialTsconfigFileLoader.loadConfigurationFileForProjectAsync(\n terminal,\n buildFolderPath,\n heftConfiguration.rigConfig\n );\n }\n _partialTsconfigFilePromiseCache.set(buildFolderPath, partialTsconfigFilePromise);\n }\n\n return await partialTsconfigFilePromise;\n}\n\nexport default class TypeScriptPlugin implements IHeftTaskPlugin {\n public accessor: ITypeScriptPluginAccessor = {\n onChangedFilesHook: new SyncHook<IChangedFilesHookOptions>(['changedFilesHookOptions'])\n };\n\n public apply(taskSession: IHeftTaskSession, heftConfiguration: HeftConfiguration): void {\n taskSession.hooks.run.tapPromise(PLUGIN_NAME, async (runOptions: IHeftTaskRunHookOptions) => {\n const builder: TypeScriptBuilder | false = await this._getTypeScriptBuilderAsync(\n taskSession,\n heftConfiguration\n );\n if (builder) {\n await builder.invokeAsync();\n }\n // TODO: We should consider maybe only doing one copy of static assets and pointing\n // all source files to this set of static assets. This would allow us to avoid\n // having to copy the static assets multiple times, increasing build times and\n // package size.\n await this._updateStaticAssetsToCopy(taskSession, heftConfiguration, runOptions);\n });\n\n let incrementalBuilder: TypeScriptBuilder | undefined | false;\n taskSession.hooks.runIncremental.tapPromise(\n PLUGIN_NAME,\n async (runIncrementalOptions: IHeftTaskRunIncrementalHookOptions) => {\n if (incrementalBuilder === undefined) {\n // eslint-disable-next-line require-atomic-updates\n incrementalBuilder = await this._getTypeScriptBuilderAsync(taskSession, heftConfiguration);\n }\n\n if (incrementalBuilder) {\n await incrementalBuilder.invokeAsync(runIncrementalOptions.changedFiles);\n }\n\n // TODO: We should consider maybe only doing one copy of static assets and pointing\n // all source files to this set of static assets. This would allow us to avoid\n // having to copy the static assets multiple times, increasing build times and\n // package size.\n await this._updateStaticAssetsToCopy(taskSession, heftConfiguration, runIncrementalOptions);\n }\n );\n }\n\n private async _updateStaticAssetsToCopy(\n taskSession: IHeftTaskSession,\n heftConfiguration: HeftConfiguration,\n runOptions: IHeftTaskRunHookOptions\n ): Promise<void> {\n const typeScriptConfiguration: ITypeScriptConfigurationJson | undefined =\n await loadTypeScriptConfigurationFileAsync(heftConfiguration, taskSession.logger.terminal);\n\n // We only care about the copy if static assets were specified.\n if (\n typeScriptConfiguration?.staticAssetsToCopy?.fileExtensions?.length ||\n typeScriptConfiguration?.staticAssetsToCopy?.includeGlobs?.length ||\n typeScriptConfiguration?.staticAssetsToCopy?.excludeGlobs?.length\n ) {\n const destinationFolderPaths: Set<string> = new Set<string>();\n\n // Add the output folder and all additional module kind output folders as destinations\n const tsconfigOutDir: string | undefined = await this._getTsconfigOutDirAsync(\n taskSession,\n heftConfiguration,\n typeScriptConfiguration\n );\n if (tsconfigOutDir) {\n destinationFolderPaths.add(tsconfigOutDir);\n }\n for (const emitModule of typeScriptConfiguration?.additionalModuleKindsToEmit || []) {\n destinationFolderPaths.add(`${heftConfiguration.buildFolderPath}/${emitModule.outFolderName}`);\n }\n\n runOptions.addCopyOperations({\n ...typeScriptConfiguration?.staticAssetsToCopy,\n\n // For now - these may need to be revised later\n sourcePath: 'src',\n destinationFolders: Array.from(destinationFolderPaths),\n flatten: false,\n hardlink: false\n });\n }\n }\n\n private async _getTypeScriptBuilderAsync(\n taskSession: IHeftTaskSession,\n heftConfiguration: HeftConfiguration\n ): Promise<TypeScriptBuilder | false> {\n const terminal: ITerminal = taskSession.logger.terminal;\n\n const typeScriptConfigurationJson: ITypeScriptConfigurationJson | undefined =\n await loadTypeScriptConfigurationFileAsync(heftConfiguration, terminal);\n\n const partialTsconfigFile: IPartialTsconfig | undefined = await loadPartialTsconfigFileAsync(\n heftConfiguration,\n terminal,\n typeScriptConfigurationJson\n );\n\n if (!partialTsconfigFile) {\n // There is no tsconfig file, we can exit early\n // This check may need watch mode to break on tsconfig addition/deletion\n return false;\n }\n\n const typeScriptToolPath: string = await heftConfiguration.rigPackageResolver.resolvePackageAsync(\n 'typescript',\n terminal\n );\n\n // Build out the configuration\n const typeScriptBuilderConfiguration: ITypeScriptBuilderConfiguration = {\n buildFolderPath: heftConfiguration.buildFolderPath,\n // Use tempFolderPath instead of cacheFolderPath. Running a clean will delete build outputs\n // which the metadata file will imply are unchanged, causing typescript to avoid building\n // these files. Since cleaning will delete files in the temp folder path, place it there.\n buildMetadataFolderPath: taskSession.tempFolderPath,\n typeScriptToolPath: typeScriptToolPath,\n\n buildProjectReferences: typeScriptConfigurationJson?.buildProjectReferences,\n\n tsconfigPath: getTsconfigFilePath(heftConfiguration, typeScriptConfigurationJson),\n additionalModuleKindsToEmit: typeScriptConfigurationJson?.additionalModuleKindsToEmit,\n emitCjsExtensionForCommonJS: !!typeScriptConfigurationJson?.emitCjsExtensionForCommonJS,\n emitMjsExtensionForESModule: !!typeScriptConfigurationJson?.emitMjsExtensionForESModule,\n // watchMode: watchMode,\n maxWriteParallelism: typeScriptConfigurationJson?.maxWriteParallelism || 50,\n scopedLogger: taskSession.logger,\n emitChangedFilesCallback: (\n program: TTypescript.Program,\n changedFiles?: Set<TTypescript.SourceFile>\n ) => {\n // Provide the typescript program dependent plugins\n if (this.accessor.onChangedFilesHook.isUsed()) {\n this.accessor.onChangedFilesHook.call({ program, changedFiles });\n }\n }\n };\n\n // Run the builder\n const typeScriptBuilder: TypeScriptBuilder = new TypeScriptBuilder(typeScriptBuilderConfiguration);\n return typeScriptBuilder;\n }\n\n private async _getTsconfigOutDirAsync(\n taskSession: IHeftTaskSession,\n heftConfiguration: HeftConfiguration,\n typeScriptConfiguration: ITypeScriptConfigurationJson | undefined\n ): Promise<string | undefined> {\n const partialTsconfigFile: IPartialTsconfig | undefined = await loadPartialTsconfigFileAsync(\n heftConfiguration,\n taskSession.logger.terminal,\n typeScriptConfiguration\n );\n return partialTsconfigFile?.compilerOptions?.outDir;\n }\n}\n"]}
@@ -31,6 +31,10 @@ export interface IExtendedTypeScript {
31
31
  * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/performance.ts#L3
32
32
  */
33
33
  performance: {
34
+ /**
35
+ * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/performance.ts#L119-L121
36
+ */
37
+ disable(): void;
34
38
  /**
35
39
  * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/performance.ts#L110-L116
36
40
  */
@@ -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;AAG/C;;GAEG;AACH,MAAM,WAAW,aAAa;CAAG;AAEjC;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,WAAW,CAAC,iBAAiB,CAAC;CAC1C;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;CAAG;AAErC;;GAEG;AACH,MAAM,WAAW,gCAAgC;IAC/C,oBAAoB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxC,wBAAwB,IAAI,MAAM,CAAC;IACnC,mBAAmB,IAAI,MAAM,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,WAAW,EAAE;QACX;;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;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,OAAO,GACzB,iBAAiB,CAAC;IAErB;;OAEG;IACH,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAE1C;;OAEG;IACH,6BAA6B,CAC3B,IAAI,EAAE,gCAAgC,EACtC,QAAQ,EAAE,MAAM,EAChB,aAAa,CAAC,EAAE,MAAM,GACrB,MAAM,CAAC;IAEV,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\n// The specifics of these types aren't important\n/**\n * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/types.ts#L3969-L4010\n */\nexport interface IEmitResolver {}\n\n/**\n * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/types.ts#L5969-L5988\n */\nexport interface IEmitHost {\n writeFile: TTypescript.WriteFileCallback;\n}\n\n/**\n * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/types.ts#L3338-L3341\n */\nexport interface IEmitTransformers {}\n\n/**\n * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/utilities.ts#L3799-L3803\n */\nexport interface IResolveModuleNameResolutionHost {\n getCanonicalFileName(p: string): string;\n getCommonSourceDirectory(): string;\n getCurrentDirectory(): string;\n}\n\n/**\n * @beta\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#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/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/utilities.ts#L4720-L4734\n */\n readJson(filePath: string): object;\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 /**\n * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/emitter.ts#L261-L614\n */\n emitFiles(\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\n /**\n * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/transformer.ts#L30-L35\n */\n getTransformers(\n compilerOptions: TTypescript.CompilerOptions,\n customTransformers?: TTypescript.CustomTransformers,\n emitOnlyDtsFiles?: boolean\n ): IEmitTransformers;\n\n /**\n * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/utilities.ts#L6100-L6108\n */\n removeFileExtension(path: string): string;\n\n /**\n * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/utilities.ts#L3826-L3833\n */\n getExternalModuleNameFromPath(\n host: IResolveModuleNameResolutionHost,\n fileName: string,\n referencePath?: string\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"]}
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\n// The specifics of these types aren't important\n/**\n * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/types.ts#L3969-L4010\n */\nexport interface IEmitResolver {}\n\n/**\n * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/types.ts#L5969-L5988\n */\nexport interface IEmitHost {\n writeFile: TTypescript.WriteFileCallback;\n}\n\n/**\n * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/types.ts#L3338-L3341\n */\nexport interface IEmitTransformers {}\n\n/**\n * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/utilities.ts#L3799-L3803\n */\nexport interface IResolveModuleNameResolutionHost {\n getCanonicalFileName(p: string): string;\n getCommonSourceDirectory(): string;\n getCurrentDirectory(): string;\n}\n\n/**\n * @beta\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 * 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/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/utilities.ts#L4720-L4734\n */\n readJson(filePath: string): object;\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 /**\n * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/emitter.ts#L261-L614\n */\n emitFiles(\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\n /**\n * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/transformer.ts#L30-L35\n */\n getTransformers(\n compilerOptions: TTypescript.CompilerOptions,\n customTransformers?: TTypescript.CustomTransformers,\n emitOnlyDtsFiles?: boolean\n ): IEmitTransformers;\n\n /**\n * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/utilities.ts#L6100-L6108\n */\n removeFileExtension(path: string): string;\n\n /**\n * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/utilities.ts#L3826-L3833\n */\n getExternalModuleNameFromPath(\n host: IResolveModuleNameResolutionHost,\n fileName: string,\n referencePath?: string\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-dev.1",
3
+ "version": "0.1.0-rc.1",
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.48.0-dev.0"
15
+ "@rushstack/heft": "^0.49.0-rc.1"
16
16
  },
17
17
  "dependencies": {
18
- "@rushstack/node-core-library": "3.52.0",
19
- "@rushstack/heft-config-file": "0.10.0",
18
+ "@rushstack/node-core-library": "3.53.2",
19
+ "@rushstack/heft-config-file": "0.11.3",
20
20
  "@types/tapable": "1.0.6",
21
21
  "semver": "~7.3.0",
22
22
  "tapable": "1.1.3"
23
23
  },
24
24
  "devDependencies": {
25
- "@rushstack/eslint-config": "3.0.1",
26
- "@rushstack/heft": "0.48.0-dev.1",
27
- "@rushstack/heft-legacy": "npm:@rushstack/heft@0.47.0",
28
- "@rushstack/heft-node-rig": "1.10.0",
25
+ "@rushstack/eslint-config": "3.1.1",
26
+ "@rushstack/heft": "0.49.0-rc.1",
27
+ "@rushstack/heft-legacy": "npm:@rushstack/heft@0.48.0",
28
+ "@rushstack/heft-node-rig": "1.11.0",
29
29
  "@types/node": "12.20.24",
30
30
  "@types/semver": "7.3.5",
31
- "typescript": "~4.7.4"
31
+ "typescript": "~4.8.4"
32
32
  },
33
33
  "scripts": {
34
34
  "build": "node ./node_modules/@rushstack/heft-legacy/bin/heft --unmanaged build --clean",