@rushstack/heft-typescript-plugin 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.json CHANGED
@@ -1,6 +1,41 @@
1
1
  {
2
2
  "name": "@rushstack/heft-typescript-plugin",
3
3
  "entries": [
4
+ {
5
+ "version": "0.8.0",
6
+ "tag": "@rushstack/heft-typescript-plugin_v0.8.0",
7
+ "date": "Wed, 12 Mar 2025 22:41:36 GMT",
8
+ "comments": {
9
+ "minor": [
10
+ {
11
+ "comment": "Expose some internal APIs to be used by `@rushstack/heft-isolated-typescript-transpile-plugin`."
12
+ }
13
+ ],
14
+ "dependency": [
15
+ {
16
+ "comment": "Updating dependency \"@rushstack/heft\" to `0.71.0`"
17
+ },
18
+ {
19
+ "comment": "Updating dependency \"@rushstack/heft\" from `0.70.1` to `0.71.0`"
20
+ }
21
+ ]
22
+ }
23
+ },
24
+ {
25
+ "version": "0.7.1",
26
+ "tag": "@rushstack/heft-typescript-plugin_v0.7.1",
27
+ "date": "Wed, 12 Mar 2025 00:11:31 GMT",
28
+ "comments": {
29
+ "dependency": [
30
+ {
31
+ "comment": "Updating dependency \"@rushstack/heft\" to `0.70.1`"
32
+ },
33
+ {
34
+ "comment": "Updating dependency \"@rushstack/heft\" from `0.70.0` to `0.70.1`"
35
+ }
36
+ ]
37
+ }
38
+ },
4
39
  {
5
40
  "version": "0.7.0",
6
41
  "tag": "@rushstack/heft-typescript-plugin_v0.7.0",
package/CHANGELOG.md CHANGED
@@ -1,6 +1,18 @@
1
1
  # Change Log - @rushstack/heft-typescript-plugin
2
2
 
3
- This log was last generated on Tue, 11 Mar 2025 02:12:33 GMT and should not be manually modified.
3
+ This log was last generated on Wed, 12 Mar 2025 22:41:36 GMT and should not be manually modified.
4
+
5
+ ## 0.8.0
6
+ Wed, 12 Mar 2025 22:41:36 GMT
7
+
8
+ ### Minor changes
9
+
10
+ - Expose some internal APIs to be used by `@rushstack/heft-isolated-typescript-transpile-plugin`.
11
+
12
+ ## 0.7.1
13
+ Wed, 12 Mar 2025 00:11:31 GMT
14
+
15
+ _Version update only_
4
16
 
5
17
  ## 0.7.0
6
18
  Tue, 11 Mar 2025 02:12:33 GMT
@@ -6,15 +6,48 @@
6
6
 
7
7
  import type { HeftConfiguration } from '@rushstack/heft';
8
8
  import type { ITerminal } from '@rushstack/terminal';
9
+ import semver from 'semver';
9
10
  import { SyncHook } from 'tapable';
10
- import type * as TTypescript from 'typescript';
11
+ import type * as _TTypeScript from 'typescript';
12
+
13
+ declare type ExtendedTypeScript = typeof _TTypeScript & IExtendedTypeScript;
14
+
15
+ /**
16
+ * @internal
17
+ */
18
+ export declare function _getTsconfigFilePath(heftConfiguration: HeftConfiguration, tsconfigRelativePath: string | undefined): string;
19
+
20
+ /**
21
+ * @internal
22
+ */
23
+ export declare interface _IBaseTypeScriptTool<TSystem extends _TTypeScript.System = _TTypeScript.System> {
24
+ typeScriptToolPath: string;
25
+ ts: ExtendedTypeScript;
26
+ system: TSystem;
27
+ }
11
28
 
12
29
  /**
13
30
  * @beta
14
31
  */
15
32
  export declare interface IChangedFilesHookOptions {
16
- program: TTypescript.Program;
17
- changedFiles?: ReadonlySet<TTypescript.SourceFile>;
33
+ program: _TTypeScript.Program;
34
+ changedFiles?: ReadonlySet<_TTypeScript.SourceFile>;
35
+ }
36
+
37
+ /**
38
+ * @internal
39
+ */
40
+ export declare interface _ICompilerCapabilities {
41
+ /**
42
+ * Support for incremental compilation via `ts.createIncrementalProgram()`.
43
+ * Introduced with TypeScript 3.6.
44
+ */
45
+ incrementalProgram: boolean;
46
+ /**
47
+ * Support for composite projects via `ts.createSolutionBuilder()`.
48
+ * Introduced with TypeScript 3.0.
49
+ */
50
+ solutionBuilder: boolean;
18
51
  }
19
52
 
20
53
  /**
@@ -26,6 +59,90 @@ export declare interface IEmitModuleKind {
26
59
  jsExtensionOverride?: string;
27
60
  }
28
61
 
62
+ /**
63
+ * @internal
64
+ */
65
+ declare interface IExtendedTypeScript {
66
+ /**
67
+ * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/performance.ts#L3
68
+ */
69
+ performance: {
70
+ /**
71
+ * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/performance.ts#L119-L121
72
+ */
73
+ disable(): void;
74
+ /**
75
+ * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/performance.ts#L110-L116
76
+ */
77
+ enable(): void;
78
+ /**
79
+ * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/performance.ts#L55-L61
80
+ */
81
+ mark(performanceMaker: string): void;
82
+ /**
83
+ * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/performance.ts#L72-L78
84
+ */
85
+ measure(measureName: string, startMarkName?: string, endMarkName?: string): void;
86
+ /**
87
+ * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/performance.ts#L94-L96
88
+ */
89
+ getDuration(measureName: string): number;
90
+ /**
91
+ * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/performance.ts#L85-L87
92
+ */
93
+ getCount(measureName: string): number;
94
+ };
95
+ transpileOptionValueCompilerOptions: {
96
+ name: keyof _TTypeScript.CompilerOptions;
97
+ transpileOptionValue: any;
98
+ }[];
99
+ getNewLineCharacter(compilerOptions: _TTypeScript.CompilerOptions): string;
100
+ createCompilerHost(options: _TTypeScript.CompilerOptions, setParentNodes?: boolean, system?: _TTypeScript.System): _TTypeScript.CompilerHost;
101
+ createCompilerHostWorker(options: _TTypeScript.CompilerOptions, setParentNodes?: boolean, system?: _TTypeScript.System): _TTypeScript.CompilerHost;
102
+ /**
103
+ * https://github.com/microsoft/TypeScript/blob/782c09d783e006a697b4ba6d1e7ec2f718ce8393/src/compiler/utilities.ts#L6540
104
+ */
105
+ matchFiles(path: string, extensions: ReadonlyArray<string> | undefined, excludes: ReadonlyArray<string> | undefined, includes: ReadonlyArray<string> | undefined, useCaseSensitiveFileNames: boolean, currentDirectory: string, depth: number | undefined, getFileSystemEntries: (path: string) => {
106
+ readonly files: ReadonlyArray<string>;
107
+ readonly directories: ReadonlyArray<string>;
108
+ }, realpath: (path: string) => string, directoryExists: (path: string) => boolean): string[];
109
+ Diagnostics: {
110
+ Found_1_error_Watching_for_file_changes: _TTypeScript.DiagnosticMessage;
111
+ Found_0_errors_Watching_for_file_changes: _TTypeScript.DiagnosticMessage;
112
+ Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor: _TTypeScript.DiagnosticMessage;
113
+ Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1: _TTypeScript.DiagnosticMessage;
114
+ };
115
+ }
116
+
117
+ /**
118
+ * @internal
119
+ */
120
+ export declare interface _ILoadedTypeScriptTool {
121
+ tool: _IBaseTypeScriptTool;
122
+ typescriptVersion: string;
123
+ typescriptParsedVersion: semver.SemVer;
124
+ capabilities: _ICompilerCapabilities;
125
+ }
126
+
127
+ /**
128
+ * @internal
129
+ */
130
+ export declare interface _ILoadTsconfigOptions {
131
+ tool: _IBaseTypeScriptTool;
132
+ tsconfigPath: string;
133
+ tsCacheFilePath?: string;
134
+ }
135
+
136
+ /**
137
+ * @internal
138
+ */
139
+ export declare interface _ILoadTypeScriptToolOptions {
140
+ terminal: ITerminal;
141
+ heftConfiguration: HeftConfiguration;
142
+ onlyResolveSymlinksInNodeModules?: boolean;
143
+ buildProjectReferences?: boolean;
144
+ }
145
+
29
146
  /**
30
147
  * @beta
31
148
  */
@@ -100,11 +217,23 @@ export declare interface ITypeScriptPluginAccessor {
100
217
  */
101
218
  export declare function loadPartialTsconfigFileAsync(heftConfiguration: HeftConfiguration, terminal: ITerminal, typeScriptConfigurationJson: ITypeScriptConfigurationJson | undefined): Promise<IPartialTsconfig | undefined>;
102
219
 
220
+ /**
221
+ * @internal
222
+ */
223
+ export declare function _loadTsconfig(options: _ILoadTsconfigOptions): _TTypeScript.ParsedCommandLine;
224
+
103
225
  /**
104
226
  * @beta
105
227
  */
106
228
  export declare function loadTypeScriptConfigurationFileAsync(heftConfiguration: HeftConfiguration, terminal: ITerminal): Promise<ITypeScriptConfigurationJson | undefined>;
107
229
 
230
+ /**
231
+ * @internal
232
+ */
233
+ export declare function _loadTypeScriptToolAsync(options: _ILoadTypeScriptToolOptions): Promise<_ILoadedTypeScriptTool>;
234
+
235
+ export { _TTypeScript }
236
+
108
237
  /**
109
238
  * The name of the plugin, as specified in heft-plugin.json
110
239
  *
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.51.1"
8
+ "packageVersion": "7.52.1"
9
9
  }
10
10
  ]
11
11
  }
@@ -1,7 +1,7 @@
1
1
  import { Worker } from 'worker_threads';
2
2
  import type * as TTypescript from 'typescript';
3
- import type { IScopedLogger } from '@rushstack/heft';
4
- import type { ExtendedTypeScript, IExtendedSolutionBuilder } from './internalTypings/TypeScriptInternals';
3
+ import type { HeftConfiguration, IScopedLogger } from '@rushstack/heft';
4
+ import type { ExtendedTypeScript, IExtendedSolutionBuilder, ITypeScriptNodeSystem } from './internalTypings/TypeScriptInternals';
5
5
  import type { ITypeScriptConfigurationJson } from './TypeScriptPlugin';
6
6
  import type { PerformanceMeasurer } from './Performance';
7
7
  export interface ITypeScriptBuilderConfiguration extends ITypeScriptConfigurationJson {
@@ -16,7 +16,7 @@ export interface ITypeScriptBuilderConfiguration extends ITypeScriptConfiguratio
16
16
  /**
17
17
  * The path to the TypeScript tool.
18
18
  */
19
- typeScriptToolPath: string;
19
+ heftConfiguration: HeftConfiguration;
20
20
  /**
21
21
  * The path to the tsconfig file being built.
22
22
  */
@@ -38,9 +38,15 @@ interface ITranspileSignal {
38
38
  resolve: (result: TTypescript.EmitResult) => void;
39
39
  reject: (error: Error) => void;
40
40
  }
41
- interface ITypeScriptTool {
41
+ /**
42
+ * @internal
43
+ */
44
+ export interface IBaseTypeScriptTool<TSystem extends TTypescript.System = TTypescript.System> {
45
+ typeScriptToolPath: string;
42
46
  ts: ExtendedTypeScript;
43
- system: TTypescript.System;
47
+ system: TSystem;
48
+ }
49
+ interface ITypeScriptTool extends IBaseTypeScriptTool<ITypeScriptNodeSystem> {
44
50
  measureSync: PerformanceMeasurer;
45
51
  sourceFileCache: Map<string, TTypescript.SourceFile>;
46
52
  watchProgram: TWatchProgram | undefined;
@@ -57,9 +63,6 @@ export declare class TypeScriptBuilder {
57
63
  private readonly _configuration;
58
64
  private readonly _typescriptLogger;
59
65
  private readonly _typescriptTerminal;
60
- private _typescriptVersion;
61
- private _typescriptParsedVersion;
62
- private _capabilities;
63
66
  private _useSolutionBuilder;
64
67
  private _moduleKindsToEmit;
65
68
  private readonly _suppressedDiagnosticCodes;
@@ -79,7 +82,6 @@ export declare class TypeScriptBuilder {
79
82
  private _getAdjustedDiagnosticCategory;
80
83
  private _validateTsconfig;
81
84
  private _addModuleKindToEmit;
82
- private _loadTsconfig;
83
85
  private _getCreateBuilderProgram;
84
86
  private _buildSolutionBuilderHost;
85
87
  private _buildIncrementalCompilerHost;
@@ -1 +1 @@
1
- {"version":3,"file":"TypeScriptBuilder.d.ts","sourceRoot":"","sources":["../src/TypeScriptBuilder.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGxC,OAAO,KAAK,KAAK,WAAW,MAAM,YAAY,CAAC;AAS/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,KAAK,EAEV,kBAAkB,EAClB,wBAAwB,EAEzB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AACvE,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AmB,CAAW;IAEtC,OAAO,CAAC,kBAAkB,CAA2B;IACrD,OAAO,CAAC,QAAQ,CAAC,0BAA0B,CAA0B;IAErE,OAAO,CAAC,iBAAiB,CAAqB;IAE9C,OAAO,CAAC,KAAK,CAA0C;IAEvD,OAAO,CAAC,cAAc,CAAa;IAEnC,OAAO,KAAK,gBAAgB,GAuB3B;gBAEkB,aAAa,EAAE,+BAA+B;IAMpD,WAAW,CAAC,gBAAgB,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IA4IzD,cAAc,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IA6DpD,cAAc,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAmIpD,sBAAsB,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAuDzE,OAAO,CAAC,eAAe;IAwCvB,OAAO,CAAC,mBAAmB;IAqB3B,OAAO,CAAC,mBAAmB;IAc3B,OAAO,CAAC,uBAAuB;IA0C/B,OAAO,CAAC,8BAA8B;IAuBtC,OAAO,CAAC,iBAAiB;IAyHzB,OAAO,CAAC,oBAAoB;IA8D5B,OAAO,CAAC,wBAAwB;IAmGhC,OAAO,CAAC,yBAAyB;IA+BjC,OAAO,CAAC,6BAA6B;IAuBrC,OAAO,CAAC,uBAAuB;IAwB/B,OAAO,CAAC,6BAA6B;IA6CrC,OAAO,CAAC,8BAA8B;IActC,OAAO,CAAC,gBAAgB;IAyBxB,OAAO,CAAC,uBAAuB;IAiF/B,OAAO,CAAC,cAAc;CAYvB"}
@@ -39,13 +39,10 @@ exports.TypeScriptBuilder = void 0;
39
39
  const crypto = __importStar(require("crypto"));
40
40
  const path = __importStar(require("path"));
41
41
  const worker_threads_1 = require("worker_threads");
42
- const semver = __importStar(require("semver"));
43
42
  const node_core_library_1 = require("@rushstack/node-core-library");
44
43
  const configureProgramForMultiEmit_1 = require("./configureProgramForMultiEmit");
45
- const OLDEST_SUPPORTED_TS_MAJOR_VERSION = 2;
46
- const OLDEST_SUPPORTED_TS_MINOR_VERSION = 9;
47
- const NEWEST_SUPPORTED_TS_MAJOR_VERSION = 5;
48
- const NEWEST_SUPPORTED_TS_MINOR_VERSION = 8;
44
+ const tsconfigLoader_1 = require("./tsconfigLoader");
45
+ const loadTypeScriptTool_1 = require("./loadTypeScriptTool");
49
46
  class TypeScriptBuilder {
50
47
  get _tsCacheFilePath() {
51
48
  if (!this.__tsCacheFilePath) {
@@ -77,49 +74,13 @@ class TypeScriptBuilder {
77
74
  async invokeAsync(onChangeDetected) {
78
75
  var _a, _b;
79
76
  if (!this._tool) {
80
- // Determine the compiler version
81
- const compilerPackageJsonFilename = path.join(this._configuration.typeScriptToolPath, 'package.json');
82
- const packageJson = await node_core_library_1.JsonFile.loadAsync(compilerPackageJsonFilename);
83
- this._typescriptVersion = packageJson.version;
84
- const parsedVersion = semver.parse(this._typescriptVersion);
85
- if (!parsedVersion) {
86
- throw new Error(`Unable to parse version "${this._typescriptVersion}" for TypeScript compiler package in: ` +
87
- compilerPackageJsonFilename);
88
- }
89
- this._typescriptParsedVersion = parsedVersion;
90
- // Detect what features this compiler supports. Note that manually comparing major/minor numbers
91
- // loosens the matching to accept prereleases such as "3.6.0-dev.20190530"
92
- this._capabilities = {
93
- incrementalProgram: false,
94
- solutionBuilder: this._typescriptParsedVersion.major >= 3
95
- };
96
- if (this._typescriptParsedVersion.major > 3 ||
97
- (this._typescriptParsedVersion.major === 3 && this._typescriptParsedVersion.minor >= 6)) {
98
- this._capabilities.incrementalProgram = true;
99
- }
77
+ const { tool: { ts, system: baseSystem, typeScriptToolPath } } = await (0, loadTypeScriptTool_1.loadTypeScriptToolAsync)({
78
+ terminal: this._typescriptTerminal,
79
+ heftConfiguration: this._configuration.heftConfiguration,
80
+ buildProjectReferences: this._configuration.buildProjectReferences,
81
+ onlyResolveSymlinksInNodeModules: this._configuration.onlyResolveSymlinksInNodeModules
82
+ });
100
83
  this._useSolutionBuilder = !!this._configuration.buildProjectReferences;
101
- if (this._useSolutionBuilder && !this._capabilities.solutionBuilder) {
102
- throw new Error(`Building project references requires TypeScript@>=3.0, but the current version is ${this._typescriptVersion}`);
103
- }
104
- // Report a warning if the TypeScript version is too old/new. The current oldest supported version is
105
- // TypeScript 2.9. Prior to that the "ts.getConfigFileParsingDiagnostics()" API is missing; more fixups
106
- // would be required to deal with that. We won't do that work unless someone requests it.
107
- if (this._typescriptParsedVersion.major < OLDEST_SUPPORTED_TS_MAJOR_VERSION ||
108
- (this._typescriptParsedVersion.major === OLDEST_SUPPORTED_TS_MAJOR_VERSION &&
109
- this._typescriptParsedVersion.minor < OLDEST_SUPPORTED_TS_MINOR_VERSION)) {
110
- // We don't use writeWarningLine() here because, if the person wants to take their chances with
111
- // a seemingly unsupported compiler, their build should be allowed to succeed.
112
- this._typescriptTerminal.writeLine(`The TypeScript compiler version ${this._typescriptVersion} is very old` +
113
- ` and has not been tested with Heft; it may not work correctly.`);
114
- }
115
- else if (this._typescriptParsedVersion.major > NEWEST_SUPPORTED_TS_MAJOR_VERSION ||
116
- (this._typescriptParsedVersion.major === NEWEST_SUPPORTED_TS_MAJOR_VERSION &&
117
- this._typescriptParsedVersion.minor > NEWEST_SUPPORTED_TS_MINOR_VERSION)) {
118
- this._typescriptTerminal.writeLine(`The TypeScript compiler version ${this._typescriptVersion} is newer` +
119
- ' than the latest version that was tested with Heft ' +
120
- `(${NEWEST_SUPPORTED_TS_MAJOR_VERSION}.${NEWEST_SUPPORTED_TS_MINOR_VERSION}); it may not work correctly.`);
121
- }
122
- const ts = require(this._configuration.typeScriptToolPath);
123
84
  ts.performance.enable();
124
85
  const suppressedCodes = [
125
86
  (_a = ts.Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor) === null || _a === void 0 ? void 0 : _a.code,
@@ -158,17 +119,12 @@ class TypeScriptBuilder {
158
119
  }
159
120
  return timeout;
160
121
  };
161
- let realpath = ts.sys.realpath;
162
- if (this._configuration.onlyResolveSymlinksInNodeModules) {
163
- const resolver = new node_core_library_1.RealNodeModulePathResolver();
164
- realpath = resolver.realNodeModulePath;
165
- }
166
122
  const getCurrentDirectory = () => this._configuration.buildFolderPath;
167
123
  // Need to also update watchFile and watchDirectory
168
- const system = Object.assign(Object.assign({}, ts.sys), { realpath,
169
- getCurrentDirectory,
124
+ const system = Object.assign(Object.assign({}, baseSystem), { getCurrentDirectory,
170
125
  clearTimeout,
171
126
  setTimeout });
127
+ const { realpath } = system;
172
128
  if (realpath && system.getAccessibleFileSystemEntries) {
173
129
  const { getAccessibleFileSystemEntries } = system;
174
130
  system.readDirectory = (folderPath, extensions, exclude, include, depth) => {
@@ -176,6 +132,7 @@ class TypeScriptBuilder {
176
132
  };
177
133
  }
178
134
  this._tool = {
135
+ typeScriptToolPath,
179
136
  ts,
180
137
  system,
181
138
  measureSync: measureTsPerformance,
@@ -212,7 +169,11 @@ class TypeScriptBuilder {
212
169
  if (!tool.solutionBuilder && !tool.watchProgram) {
213
170
  //#region CONFIGURE
214
171
  const { duration: configureDurationMs, tsconfig } = measureTsPerformance('Configure', () => {
215
- const _tsconfig = this._loadTsconfig(tool);
172
+ const _tsconfig = (0, tsconfigLoader_1.loadTsconfig)({
173
+ tool,
174
+ tsconfigPath: this._configuration.tsconfigPath,
175
+ tsCacheFilePath: this._tsCacheFilePath
176
+ });
216
177
  this._validateTsconfig(ts, _tsconfig);
217
178
  return {
218
179
  tsconfig: _tsconfig
@@ -255,7 +216,11 @@ class TypeScriptBuilder {
255
216
  const { ts, measureSync: measureTsPerformance, pendingTranspilePromises } = tool;
256
217
  //#region CONFIGURE
257
218
  const { duration: configureDurationMs, tsconfig, compilerHost } = measureTsPerformance('Configure', () => {
258
- const _tsconfig = this._loadTsconfig(tool);
219
+ const _tsconfig = (0, tsconfigLoader_1.loadTsconfig)({
220
+ tool,
221
+ tsconfigPath: this._configuration.tsconfigPath,
222
+ tsCacheFilePath: this._tsCacheFilePath
223
+ });
259
224
  this._validateTsconfig(ts, _tsconfig);
260
225
  const _compilerHost = this._buildIncrementalCompilerHost(tool, _tsconfig);
261
226
  return {
@@ -345,7 +310,11 @@ class TypeScriptBuilder {
345
310
  if (!tool.solutionBuilder) {
346
311
  //#region CONFIGURE
347
312
  const { duration: configureDurationMs, solutionBuilderHost } = measureSync('Configure', () => {
348
- const _tsconfig = this._loadTsconfig(tool);
313
+ const _tsconfig = (0, tsconfigLoader_1.loadTsconfig)({
314
+ tool,
315
+ tsconfigPath: this._configuration.tsconfigPath,
316
+ tsCacheFilePath: this._tsCacheFilePath
317
+ });
349
318
  this._validateTsconfig(ts, _tsconfig);
350
319
  const _solutionBuilderHost = this._buildSolutionBuilderHost(tool);
351
320
  return {
@@ -595,23 +564,6 @@ class TypeScriptBuilder {
595
564
  });
596
565
  return `${outFolderName}:${jsExtensionOverride || '.js'}`;
597
566
  }
598
- _loadTsconfig(tool) {
599
- const { ts, system } = tool;
600
- const parsedConfigFile = ts.readConfigFile(this._configuration.tsconfigPath, system.readFile);
601
- const currentFolder = path.dirname(this._configuration.tsconfigPath);
602
- const tsconfig = ts.parseJsonConfigFileContent(parsedConfigFile.config, {
603
- fileExists: system.fileExists,
604
- readFile: system.readFile,
605
- readDirectory: system.readDirectory,
606
- realpath: system.realpath,
607
- useCaseSensitiveFileNames: true
608
- }, currentFolder,
609
- /*existingOptions:*/ undefined, this._configuration.tsconfigPath);
610
- if (tsconfig.options.incremental) {
611
- tsconfig.options.tsBuildInfoFile = this._tsCacheFilePath;
612
- }
613
- return tsconfig;
614
- }
615
567
  _getCreateBuilderProgram(ts) {
616
568
  const { _configuration: { emitChangedFilesCallback } } = this;
617
569
  const createMultiEmitBuilderProgram = (fileNames, compilerOptions, host, oldProgram, configFileParsingDiagnostics, projectReferences) => {
@@ -733,11 +685,11 @@ class TypeScriptBuilder {
733
685
  }
734
686
  }
735
687
  _queueTranspileInWorker(tool, compilerOptions, filesToTranspile) {
736
- const { pendingTranspilePromises, pendingTranspileSignals } = tool;
688
+ const { typeScriptToolPath, pendingTranspilePromises, pendingTranspileSignals } = tool;
737
689
  let maybeWorker = tool.worker;
738
690
  if (!maybeWorker) {
739
691
  const workerData = {
740
- typeScriptToolPath: this._configuration.typeScriptToolPath
692
+ typeScriptToolPath
741
693
  };
742
694
  tool.worker = maybeWorker = new worker_threads_1.Worker(require.resolve('./TranspilerWorker.js'), {
743
695
  workerData: workerData