@rushstack/heft-typescript-plugin 0.1.0-rc.4 → 0.2.0-rc.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/heft-typescript-plugin.d.ts +4 -0
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/Performance.d.ts +2 -2
- package/lib/Performance.d.ts.map +1 -1
- package/lib/TranspilerWorker.d.ts +2 -0
- package/lib/TranspilerWorker.d.ts.map +1 -0
- package/lib/TranspilerWorker.js +80 -0
- package/lib/TranspilerWorker.js.map +1 -0
- package/lib/TypeScriptBuilder.d.ts +17 -9
- package/lib/TypeScriptBuilder.d.ts.map +1 -1
- package/lib/TypeScriptBuilder.js +213 -133
- package/lib/TypeScriptBuilder.js.map +1 -1
- package/lib/TypeScriptPlugin.d.ts +4 -0
- package/lib/TypeScriptPlugin.d.ts.map +1 -1
- package/lib/TypeScriptPlugin.js +1 -0
- package/lib/TypeScriptPlugin.js.map +1 -1
- package/lib/configureProgramForMultiEmit.d.ts +7 -0
- package/lib/configureProgramForMultiEmit.d.ts.map +1 -0
- package/lib/configureProgramForMultiEmit.js +99 -0
- package/lib/configureProgramForMultiEmit.js.map +1 -0
- package/lib/internalTypings/TypeScriptInternals.d.ts +6 -48
- package/lib/internalTypings/TypeScriptInternals.d.ts.map +1 -1
- package/lib/internalTypings/TypeScriptInternals.js.map +1 -1
- package/lib/schemas/typescript.schema.json +5 -0
- package/lib/types.d.ts +54 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +3 -0
- package/lib/types.js.map +1 -0
- package/package.json +11 -11
- package/lib/EmitFilesPatch.d.ts +0 -28
- package/lib/EmitFilesPatch.d.ts.map +0 -1
- package/lib/EmitFilesPatch.js +0 -99
- package/lib/EmitFilesPatch.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configureProgramForMultiEmit.js","sourceRoot":"","sources":["../src/configureProgramForMultiEmit.ts"],"names":[],"m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B,GAAG,OAAO,CAAC,iCAAiC,CAAE,CAAC;YACzE,uBAAuB,CAAC,MAAM,GAAG,iBAAiB,CAAC;SACpD;IACH,CAAC,CAAC;IACF,OAAO,EAAE,YAAY,EAAE,CAAC;AAC1B,CAAC;AA7ID,oEA6IC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\nimport type * as TTypescript from 'typescript';\nimport { InternalError } from '@rushstack/node-core-library';\n\nimport type { ExtendedTypeScript } from './internalTypings/TypeScriptInternals';\nimport type { ICachedEmitModuleKind } from './types';\n\n// symbols for attaching hidden metadata to ts.Program instances.\nconst INNER_GET_COMPILER_OPTIONS_SYMBOL: unique symbol = Symbol('getCompilerOptions');\nconst INNER_EMIT_SYMBOL: unique symbol = Symbol('emit');\n\nconst JS_EXTENSION_REGEX: RegExp = /\\.js(\\.map)?$/;\n\nfunction wrapWriteFile(\n this: void,\n baseWriteFile: TTypescript.WriteFileCallback,\n jsExtensionOverride: string | undefined\n): TTypescript.WriteFileCallback {\n if (!jsExtensionOverride) {\n return baseWriteFile;\n }\n\n const replacementExtension: string = `${jsExtensionOverride}$1`;\n return (\n fileName: string,\n data: string,\n writeBOM: boolean,\n onError?: ((message: string) => void) | undefined,\n sourceFiles?: readonly TTypescript.SourceFile[] | undefined\n ) => {\n return baseWriteFile(\n fileName.replace(JS_EXTENSION_REGEX, replacementExtension),\n data,\n writeBOM,\n onError,\n sourceFiles\n );\n };\n}\n\nexport function configureProgramForMultiEmit(\n this: void,\n innerProgram: TTypescript.Program,\n ts: ExtendedTypeScript,\n moduleKindsToEmit: ICachedEmitModuleKind[],\n mode: 'transpile' | 'declaration' | 'both'\n): { changedFiles: Set<TTypescript.SourceFile> } {\n interface IProgramWithMultiEmit extends TTypescript.Program {\n // Attach the originals to the Program instance to avoid modifying the same Program twice.\n // Don't use WeakMap because this Program could theoretically get a { ... } applied to it.\n [INNER_GET_COMPILER_OPTIONS_SYMBOL]?: TTypescript.Program['getCompilerOptions'];\n [INNER_EMIT_SYMBOL]?: TTypescript.Program['emit'];\n }\n\n const program: IProgramWithMultiEmit = innerProgram;\n\n // Check to see if this Program has already been modified.\n let { [INNER_EMIT_SYMBOL]: innerEmit, [INNER_GET_COMPILER_OPTIONS_SYMBOL]: innerGetCompilerOptions } =\n program;\n\n if (!innerGetCompilerOptions) {\n program[INNER_GET_COMPILER_OPTIONS_SYMBOL] = innerGetCompilerOptions = program.getCompilerOptions;\n }\n\n if (!innerEmit) {\n program[INNER_EMIT_SYMBOL] = innerEmit = program.emit;\n }\n\n let foundPrimary: boolean = false;\n let defaultModuleKind: TTypescript.ModuleKind;\n\n const multiEmitMap: Map<ICachedEmitModuleKind, TTypescript.CompilerOptions> = new Map();\n for (const moduleKindToEmit of moduleKindsToEmit) {\n const kindCompilerOptions: TTypescript.CompilerOptions = moduleKindToEmit.isPrimary\n ? {\n ...innerGetCompilerOptions()\n }\n : {\n ...innerGetCompilerOptions(),\n module: moduleKindToEmit.moduleKind,\n outDir: moduleKindToEmit.outFolderPath,\n\n // Don't emit declarations for secondary module kinds\n declaration: false,\n declarationMap: false\n };\n if (!kindCompilerOptions.outDir) {\n throw new InternalError('Expected compilerOptions.outDir to be assigned');\n }\n if (mode === 'transpile') {\n kindCompilerOptions.declaration = false;\n kindCompilerOptions.declarationMap = false;\n } else if (mode === 'declaration') {\n kindCompilerOptions.emitDeclarationOnly = true;\n }\n\n if (moduleKindToEmit.isPrimary || mode !== 'declaration') {\n multiEmitMap.set(moduleKindToEmit, kindCompilerOptions);\n }\n\n if (moduleKindToEmit.isPrimary) {\n if (foundPrimary) {\n throw new Error('Multiple primary module emit kinds encountered.');\n } else {\n foundPrimary = true;\n }\n\n defaultModuleKind = moduleKindToEmit.moduleKind;\n }\n }\n\n const changedFiles: Set<TTypescript.SourceFile> = new Set();\n\n program.emit = (\n targetSourceFile?: TTypescript.SourceFile,\n writeFile?: TTypescript.WriteFileCallback,\n cancellationToken?: TTypescript.CancellationToken,\n emitOnlyDtsFiles?: boolean,\n customTransformers?: TTypescript.CustomTransformers\n ) => {\n if (emitOnlyDtsFiles) {\n return program[INNER_EMIT_SYMBOL]!(\n targetSourceFile,\n writeFile,\n cancellationToken,\n emitOnlyDtsFiles,\n customTransformers\n );\n }\n\n if (targetSourceFile && changedFiles) {\n changedFiles.add(targetSourceFile);\n }\n\n const originalCompilerOptions: TTypescript.CompilerOptions =\n program[INNER_GET_COMPILER_OPTIONS_SYMBOL]!();\n\n let defaultModuleKindResult: TTypescript.EmitResult;\n const diagnostics: TTypescript.Diagnostic[] = [];\n let emitSkipped: boolean = false;\n try {\n for (const [moduleKindToEmit, kindCompilerOptions] of multiEmitMap) {\n program.getCompilerOptions = () => kindCompilerOptions;\n // Need to mutate the compiler options for the `module` field specifically, because emitWorker() captures\n // options in the closure and passes it to `ts.getTransformers()`\n originalCompilerOptions.module = moduleKindToEmit.moduleKind;\n const flavorResult: TTypescript.EmitResult = program[INNER_EMIT_SYMBOL]!(\n targetSourceFile,\n writeFile && wrapWriteFile(writeFile, moduleKindToEmit.jsExtensionOverride),\n cancellationToken,\n emitOnlyDtsFiles,\n customTransformers\n );\n\n emitSkipped = emitSkipped || flavorResult.emitSkipped;\n // Need to aggregate diagnostics because some are impacted by the target module type\n for (const diagnostic of flavorResult.diagnostics) {\n diagnostics.push(diagnostic);\n }\n\n if (moduleKindToEmit.moduleKind === defaultModuleKind) {\n defaultModuleKindResult = flavorResult;\n }\n }\n\n const mergedDiagnostics: readonly TTypescript.Diagnostic[] =\n ts.sortAndDeduplicateDiagnostics(diagnostics);\n\n return {\n ...defaultModuleKindResult!,\n changedSourceFiles: changedFiles,\n diagnostics: mergedDiagnostics,\n emitSkipped\n };\n } finally {\n // Restore the original compiler options and module kind for future calls\n program.getCompilerOptions = program[INNER_GET_COMPILER_OPTIONS_SYMBOL]!;\n originalCompilerOptions.module = defaultModuleKind;\n }\n };\n return { changedFiles };\n}\n"]}
|
|
@@ -1,35 +1,8 @@
|
|
|
1
1
|
import type * as TTypescript from 'typescript';
|
|
2
|
-
/**
|
|
3
|
-
* https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/types.ts#L3969-L4010
|
|
4
|
-
*/
|
|
5
|
-
export interface IEmitResolver {
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/types.ts#L5969-L5988
|
|
9
|
-
*/
|
|
10
|
-
export interface IEmitHost {
|
|
11
|
-
writeFile: TTypescript.WriteFileCallback;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/types.ts#L3338-L3341
|
|
15
|
-
*/
|
|
16
|
-
export interface IEmitTransformers {
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/utilities.ts#L3799-L3803
|
|
20
|
-
*/
|
|
21
|
-
export interface IResolveModuleNameResolutionHost {
|
|
22
|
-
getCanonicalFileName(p: string): string;
|
|
23
|
-
getCommonSourceDirectory(): string;
|
|
24
|
-
getCurrentDirectory(): string;
|
|
25
|
-
}
|
|
26
2
|
export interface IExtendedSolutionBuilder extends TTypescript.SolutionBuilder<TTypescript.EmitAndSemanticDiagnosticsBuilderProgram> {
|
|
27
3
|
getBuildOrder(): readonly string[];
|
|
28
4
|
invalidateProject(configFilePath: string, mode: 0 | 1 | 2): void;
|
|
29
5
|
}
|
|
30
|
-
/**
|
|
31
|
-
* @beta
|
|
32
|
-
*/
|
|
33
6
|
export interface IExtendedTypeScript {
|
|
34
7
|
/**
|
|
35
8
|
* https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/performance.ts#L3
|
|
@@ -60,10 +33,11 @@ export interface IExtendedTypeScript {
|
|
|
60
33
|
*/
|
|
61
34
|
getCount(measureName: string): number;
|
|
62
35
|
};
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
36
|
+
transpileOptionValueCompilerOptions: {
|
|
37
|
+
name: keyof TTypescript.CompilerOptions;
|
|
38
|
+
transpileOptionValue: any;
|
|
39
|
+
}[];
|
|
40
|
+
getNewLineCharacter(compilerOptions: TTypescript.CompilerOptions): string;
|
|
67
41
|
/**
|
|
68
42
|
* https://github.com/microsoft/TypeScript/blob/782c09d783e006a697b4ba6d1e7ec2f718ce8393/src/compiler/utilities.ts#L6540
|
|
69
43
|
*/
|
|
@@ -71,22 +45,6 @@ export interface IExtendedTypeScript {
|
|
|
71
45
|
readonly files: ReadonlyArray<string>;
|
|
72
46
|
readonly directories: ReadonlyArray<string>;
|
|
73
47
|
}, realpath: (path: string) => string, directoryExists: (path: string) => boolean): string[];
|
|
74
|
-
/**
|
|
75
|
-
* https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/emitter.ts#L261-L614
|
|
76
|
-
*/
|
|
77
|
-
emitFiles(resolver: IEmitResolver, host: IEmitHost, targetSourceFile: TTypescript.SourceFile | undefined, emitTransformers: IEmitTransformers, emitOnlyDtsFiles?: boolean, onlyBuildInfo?: boolean, forceDtsEmit?: boolean): TTypescript.EmitResult;
|
|
78
|
-
/**
|
|
79
|
-
* https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/transformer.ts#L30-L35
|
|
80
|
-
*/
|
|
81
|
-
getTransformers(compilerOptions: TTypescript.CompilerOptions, customTransformers?: TTypescript.CustomTransformers, emitOnlyDtsFiles?: boolean): IEmitTransformers;
|
|
82
|
-
/**
|
|
83
|
-
* https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/utilities.ts#L6100-L6108
|
|
84
|
-
*/
|
|
85
|
-
removeFileExtension(path: string): string;
|
|
86
|
-
/**
|
|
87
|
-
* https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/utilities.ts#L3826-L3833
|
|
88
|
-
*/
|
|
89
|
-
getExternalModuleNameFromPath(host: IResolveModuleNameResolutionHost, fileName: string, referencePath?: string): string;
|
|
90
48
|
Diagnostics: {
|
|
91
49
|
Found_1_error_Watching_for_file_changes: TTypescript.DiagnosticMessage;
|
|
92
50
|
Found_0_errors_Watching_for_file_changes: TTypescript.DiagnosticMessage;
|
|
@@ -94,5 +52,5 @@ export interface IExtendedTypeScript {
|
|
|
94
52
|
Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1: TTypescript.DiagnosticMessage;
|
|
95
53
|
};
|
|
96
54
|
}
|
|
97
|
-
export
|
|
55
|
+
export type ExtendedTypeScript = typeof TTypescript & IExtendedTypeScript;
|
|
98
56
|
//# sourceMappingURL=TypeScriptInternals.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeScriptInternals.d.ts","sourceRoot":"","sources":["../../src/internalTypings/TypeScriptInternals.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,WAAW,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"TypeScriptInternals.d.ts","sourceRoot":"","sources":["../../src/internalTypings/TypeScriptInternals.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,WAAW,MAAM,YAAY,CAAC;AAE/C,MAAM,WAAW,wBACf,SAAQ,WAAW,CAAC,eAAe,CAAC,WAAW,CAAC,wCAAwC,CAAC;IACzF,aAAa,IAAI,SAAS,MAAM,EAAE,CAAC;IACnC,iBAAiB,CAAC,cAAc,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;CAClE;AAED,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,WAA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EAAE,CAAC;IAEZ,WAAW,EAAE;QAGX,uCAAuC,EAAE,WAAW,CAAC,iBAAiB,CAAC;QAIvE,wCAAwC,EAAE,WAAW,CAAC,iBAAiB,CAAC;QAIxE,+EAA+E,EAAE,WAAW,CAAC,iBAAiB,CAAC;QAI/G,6FAA6F,EAAE,WAAW,CAAC,iBAAiB,CAAC;KAC9H,CAAC;CACH;AAED,MAAM,MAAM,kBAAkB,GAAG,OAAO,WAAW,GAAG,mBAAmB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeScriptInternals.js","sourceRoot":"","sources":["../../src/internalTypings/TypeScriptInternals.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type * as TTypescript from 'typescript';\n\
|
|
1
|
+
{"version":3,"file":"TypeScriptInternals.js","sourceRoot":"","sources":["../../src/internalTypings/TypeScriptInternals.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type * as TTypescript from 'typescript';\n\nexport interface IExtendedSolutionBuilder\n extends TTypescript.SolutionBuilder<TTypescript.EmitAndSemanticDiagnosticsBuilderProgram> {\n getBuildOrder(): readonly string[];\n invalidateProject(configFilePath: string, mode: 0 | 1 | 2): void;\n}\n\nexport interface IExtendedTypeScript {\n /**\n * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/performance.ts#L3\n */\n performance: {\n /**\n * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/performance.ts#L119-L121\n */\n disable(): void;\n\n /**\n * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/performance.ts#L110-L116\n */\n enable(): void;\n\n /**\n * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/performance.ts#L55-L61\n */\n mark(performanceMaker: string): void;\n\n /**\n * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/performance.ts#L72-L78\n */\n measure(measureName: string, startMarkName?: string, endMarkName?: string): void;\n\n /**\n * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/performance.ts#L94-L96\n */\n getDuration(measureName: string): number;\n\n /**\n * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/performance.ts#L85-L87\n */\n getCount(measureName: string): number;\n };\n\n transpileOptionValueCompilerOptions: {\n name: keyof TTypescript.CompilerOptions;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n transpileOptionValue: any;\n }[];\n\n getNewLineCharacter(compilerOptions: TTypescript.CompilerOptions): string;\n\n /**\n * https://github.com/microsoft/TypeScript/blob/782c09d783e006a697b4ba6d1e7ec2f718ce8393/src/compiler/utilities.ts#L6540\n */\n matchFiles(\n path: string,\n extensions: ReadonlyArray<string> | undefined,\n excludes: ReadonlyArray<string> | undefined,\n includes: ReadonlyArray<string> | undefined,\n useCaseSensitiveFileNames: boolean,\n currentDirectory: string,\n depth: number | undefined,\n getFileSystemEntries: (path: string) => {\n readonly files: ReadonlyArray<string>;\n readonly directories: ReadonlyArray<string>;\n },\n realpath: (path: string) => string,\n directoryExists: (path: string) => boolean\n ): string[];\n\n Diagnostics: {\n // https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/diagnosticMessages.json#L4252-L4255\n // eslint-disable-next-line @typescript-eslint/naming-convention\n Found_1_error_Watching_for_file_changes: TTypescript.DiagnosticMessage;\n\n // https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/diagnosticMessages.json#L4256-L4259\n // eslint-disable-next-line @typescript-eslint/naming-convention\n Found_0_errors_Watching_for_file_changes: TTypescript.DiagnosticMessage;\n\n // https://github.com/microsoft/TypeScript/blob/2428ade1a91248e847f3e1561e31a9426650efee/src/compiler/diagnosticMessages.json#L2252\n // eslint-disable-next-line @typescript-eslint/naming-convention\n Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor: TTypescript.DiagnosticMessage;\n\n // https://github.com/microsoft/TypeScript/blob/2428ade1a91248e847f3e1561e31a9426650efee/src/compiler/diagnosticMessages.json#L4920\n // eslint-disable-next-line @typescript-eslint/naming-convention\n Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1: TTypescript.DiagnosticMessage;\n };\n}\n\nexport type ExtendedTypeScript = typeof TTypescript & IExtendedTypeScript;\n"]}
|
|
@@ -52,6 +52,11 @@
|
|
|
52
52
|
"type": "boolean"
|
|
53
53
|
},
|
|
54
54
|
|
|
55
|
+
"useTranspilerWorker": {
|
|
56
|
+
"description": "If true, and the tsconfig has \"isolatedModules\": true, then transpilation will happen in parallel in a worker thread.",
|
|
57
|
+
"type": "boolean"
|
|
58
|
+
},
|
|
59
|
+
|
|
55
60
|
"project": {
|
|
56
61
|
"description": "Specifies the tsconfig.json file that will be used for compilation. Equivalent to the \"project\" argument for the 'tsc' and 'tslint' command line tools. The default value is \"./tsconfig.json\".",
|
|
57
62
|
"type": "string"
|
package/lib/types.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type * as TTypescript from 'typescript';
|
|
2
|
+
export interface ITypescriptWorkerData {
|
|
3
|
+
/**
|
|
4
|
+
* Path to the version of TypeScript to use.
|
|
5
|
+
*/
|
|
6
|
+
typeScriptToolPath: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ITranspilationRequestMessage {
|
|
9
|
+
/**
|
|
10
|
+
* Unique identifier for this request.
|
|
11
|
+
*/
|
|
12
|
+
requestId: number;
|
|
13
|
+
/**
|
|
14
|
+
* The tsconfig compiler options to use for the request.
|
|
15
|
+
*/
|
|
16
|
+
compilerOptions: TTypescript.CompilerOptions;
|
|
17
|
+
/**
|
|
18
|
+
* The variants to emit.
|
|
19
|
+
*/
|
|
20
|
+
moduleKindsToEmit: ICachedEmitModuleKind[];
|
|
21
|
+
/**
|
|
22
|
+
* The set of files to build.
|
|
23
|
+
*/
|
|
24
|
+
filesToTranspile: Map<string, string>;
|
|
25
|
+
}
|
|
26
|
+
export interface ITranspilationSuccessMessage {
|
|
27
|
+
requestId: number;
|
|
28
|
+
type: 'success';
|
|
29
|
+
result: TTypescript.EmitResult;
|
|
30
|
+
}
|
|
31
|
+
export interface ITranspilationErrorMessage {
|
|
32
|
+
requestId: number;
|
|
33
|
+
type: 'error';
|
|
34
|
+
result: {
|
|
35
|
+
message: string;
|
|
36
|
+
[key: string]: unknown;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export type ITranspilationResponseMessage = ITranspilationSuccessMessage | ITranspilationErrorMessage;
|
|
40
|
+
export interface ICachedEmitModuleKind {
|
|
41
|
+
moduleKind: TTypescript.ModuleKind;
|
|
42
|
+
outFolderPath: string;
|
|
43
|
+
/**
|
|
44
|
+
* File extension to use instead of '.js' for emitted ECMAScript files.
|
|
45
|
+
* For example, '.cjs' to indicate commonjs content, or '.mjs' to indicate ECMAScript modules.
|
|
46
|
+
*/
|
|
47
|
+
jsExtensionOverride: string | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* Set to true if this is the emit kind that is specified in the tsconfig.json.
|
|
50
|
+
* Declarations are only emitted for the primary module kind.
|
|
51
|
+
*/
|
|
52
|
+
isPrimary: boolean;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,WAAW,MAAM,YAAY,CAAC;AAE/C,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,4BAA4B;IAC3C;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,eAAe,EAAE,WAAW,CAAC,eAAe,CAAC;IAC7C;;OAEG;IACH,iBAAiB,EAAE,qBAAqB,EAAE,CAAC;IAC3C;;OAEG;IACH,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvC;AAED,MAAM,WAAW,4BAA4B;IAC3C,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,EAAE,WAAW,CAAC,UAAU,CAAC;CAChC;AAED,MAAM,WAAW,0BAA0B;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE;QACN,OAAO,EAAE,MAAM,CAAC;QAChB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;CACH;AAED,MAAM,MAAM,6BAA6B,GAAG,4BAA4B,GAAG,0BAA0B,CAAC;AAEtG,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,WAAW,CAAC,UAAU,CAAC;IAEnC,aAAa,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,mBAAmB,EAAE,MAAM,GAAG,SAAS,CAAC;IAExC;;;OAGG;IACH,SAAS,EAAE,OAAO,CAAC;CACpB"}
|
package/lib/types.js
ADDED
package/lib/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\nimport type * as TTypescript from 'typescript';\n\nexport interface ITypescriptWorkerData {\n /**\n * Path to the version of TypeScript to use.\n */\n typeScriptToolPath: string;\n}\n\nexport interface ITranspilationRequestMessage {\n /**\n * Unique identifier for this request.\n */\n requestId: number;\n /**\n * The tsconfig compiler options to use for the request.\n */\n compilerOptions: TTypescript.CompilerOptions;\n /**\n * The variants to emit.\n */\n moduleKindsToEmit: ICachedEmitModuleKind[];\n /**\n * The set of files to build.\n */\n filesToTranspile: Map<string, string>;\n}\n\nexport interface ITranspilationSuccessMessage {\n requestId: number;\n type: 'success';\n result: TTypescript.EmitResult;\n}\n\nexport interface ITranspilationErrorMessage {\n requestId: number;\n type: 'error';\n result: {\n message: string;\n [key: string]: unknown;\n };\n}\n\nexport type ITranspilationResponseMessage = ITranspilationSuccessMessage | ITranspilationErrorMessage;\n\nexport interface ICachedEmitModuleKind {\n moduleKind: TTypescript.ModuleKind;\n\n outFolderPath: string;\n\n /**\n * File extension to use instead of '.js' for emitted ECMAScript files.\n * For example, '.cjs' to indicate commonjs content, or '.mjs' to indicate ECMAScript modules.\n */\n jsExtensionOverride: string | undefined;\n\n /**\n * Set to true if this is the emit kind that is specified in the tsconfig.json.\n * Declarations are only emitted for the primary module kind.\n */\n isPrimary: boolean;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rushstack/heft-typescript-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0-rc.6",
|
|
4
4
|
"description": "Heft plugin for TypeScript",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -12,23 +12,23 @@
|
|
|
12
12
|
"types": "dist/heft-typescript-plugin.d.ts",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"@rushstack/heft": "0.50.0
|
|
15
|
+
"@rushstack/heft": "0.50.0"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@rushstack/node-core-library": "3.53.3",
|
|
19
|
-
"@rushstack/heft-config-file": "0.11.4",
|
|
20
18
|
"@types/tapable": "1.0.6",
|
|
21
19
|
"semver": "~7.3.0",
|
|
22
|
-
"tapable": "1.1.3"
|
|
20
|
+
"tapable": "1.1.3",
|
|
21
|
+
"@rushstack/node-core-library": "3.59.1",
|
|
22
|
+
"@rushstack/heft-config-file": "0.12.2"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@rushstack/
|
|
26
|
-
"@rushstack/heft": "
|
|
27
|
-
"@
|
|
28
|
-
"@rushstack/heft-node-rig": "1.11.0",
|
|
29
|
-
"@types/node": "12.20.24",
|
|
25
|
+
"@rushstack/heft-legacy": "npm:@rushstack/heft@0.50.6",
|
|
26
|
+
"@rushstack/heft-node-rig": "1.13.0",
|
|
27
|
+
"@types/node": "14.18.36",
|
|
30
28
|
"@types/semver": "7.3.5",
|
|
31
|
-
"typescript": "~
|
|
29
|
+
"typescript": "~5.0.4",
|
|
30
|
+
"@rushstack/eslint-config": "3.3.0",
|
|
31
|
+
"@rushstack/heft": "0.51.0-rc.6"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
34
|
"build": "node ./node_modules/@rushstack/heft-legacy/bin/heft --unmanaged build --clean",
|
package/lib/EmitFilesPatch.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type * as TTypescript from 'typescript';
|
|
2
|
-
import { ExtendedTypeScript } from './internalTypings/TypeScriptInternals';
|
|
3
|
-
export interface ICachedEmitModuleKind {
|
|
4
|
-
moduleKind: TTypescript.ModuleKind;
|
|
5
|
-
outFolderPath: string;
|
|
6
|
-
/**
|
|
7
|
-
* File extension to use instead of '.js' for emitted ECMAScript files.
|
|
8
|
-
* For example, '.cjs' to indicate commonjs content, or '.mjs' to indicate ECMAScript modules.
|
|
9
|
-
*/
|
|
10
|
-
jsExtensionOverride: string | undefined;
|
|
11
|
-
/**
|
|
12
|
-
* Set to true if this is the emit kind that is specified in the tsconfig.json.
|
|
13
|
-
* Declarations are only emitted for the primary module kind.
|
|
14
|
-
*/
|
|
15
|
-
isPrimary: boolean;
|
|
16
|
-
}
|
|
17
|
-
export declare class EmitFilesPatch {
|
|
18
|
-
private static _patchedTs;
|
|
19
|
-
private static _baseEmitFiles;
|
|
20
|
-
static install(ts: ExtendedTypeScript, baseCompilerOptions: TTypescript.CompilerOptions, moduleKindsToEmit: ICachedEmitModuleKind[], changedFiles?: Set<TTypescript.SourceFile>): void;
|
|
21
|
-
static get isInstalled(): boolean;
|
|
22
|
-
/**
|
|
23
|
-
* Wraps the writeFile callback on the IEmitHost to override the .js extension, if applicable
|
|
24
|
-
*/
|
|
25
|
-
static wrapWriteFile(baseWriteFile: TTypescript.WriteFileCallback, jsExtensionOverride: string | undefined): TTypescript.WriteFileCallback;
|
|
26
|
-
static uninstall(ts: ExtendedTypeScript): void;
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=EmitFilesPatch.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EmitFilesPatch.d.ts","sourceRoot":"","sources":["../src/EmitFilesPatch.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,WAAW,MAAM,YAAY,CAAC;AAC/C,OAAO,EACL,kBAAkB,EAInB,MAAM,uCAAuC,CAAC;AAE/C,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,WAAW,CAAC,UAAU,CAAC;IAEnC,aAAa,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,mBAAmB,EAAE,MAAM,GAAG,SAAS,CAAC;IAExC;;;OAGG;IACH,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAC,UAAU,CAA6C;IAEtE,OAAO,CAAC,MAAM,CAAC,cAAc,CAA8B;WAE7C,OAAO,CACnB,EAAE,EAAE,kBAAkB,EACtB,mBAAmB,EAAE,WAAW,CAAC,eAAe,EAChD,iBAAiB,EAAE,qBAAqB,EAAE,EAC1C,YAAY,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,UAAU,CAAC,GACzC,IAAI;IAsHP,WAAkB,WAAW,IAAI,OAAO,CAEvC;IAED;;OAEG;WACW,aAAa,CACzB,aAAa,EAAE,WAAW,CAAC,iBAAiB,EAC5C,mBAAmB,EAAE,MAAM,GAAG,SAAS,GACtC,WAAW,CAAC,iBAAiB;WAuBlB,SAAS,CAAC,EAAE,EAAE,kBAAkB,GAAG,IAAI;CAatD"}
|
package/lib/EmitFilesPatch.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
|
-
// See LICENSE in the project root for license information.
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.EmitFilesPatch = void 0;
|
|
6
|
-
const node_core_library_1 = require("@rushstack/node-core-library");
|
|
7
|
-
class EmitFilesPatch {
|
|
8
|
-
static install(ts, baseCompilerOptions, moduleKindsToEmit, changedFiles) {
|
|
9
|
-
if (EmitFilesPatch._patchedTs === ts) {
|
|
10
|
-
// We already patched this instance of TS
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
if (EmitFilesPatch._patchedTs !== undefined) {
|
|
14
|
-
throw new node_core_library_1.InternalError('EmitFilesPatch.install() cannot be called without first uninstalling the existing patch');
|
|
15
|
-
}
|
|
16
|
-
EmitFilesPatch._patchedTs = ts;
|
|
17
|
-
EmitFilesPatch._baseEmitFiles = ts.emitFiles;
|
|
18
|
-
let foundPrimary = false;
|
|
19
|
-
let defaultModuleKind;
|
|
20
|
-
for (const moduleKindToEmit of moduleKindsToEmit) {
|
|
21
|
-
if (moduleKindToEmit.isPrimary) {
|
|
22
|
-
if (foundPrimary) {
|
|
23
|
-
throw new Error('Multiple primary module emit kinds encountered.');
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
foundPrimary = true;
|
|
27
|
-
}
|
|
28
|
-
defaultModuleKind = moduleKindToEmit.moduleKind;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
const patchedEmitFiles = (resolver, host, targetSourceFile, emitTransformers, emitOnlyDtsFiles, onlyBuildInfo, forceDtsEmit) => {
|
|
32
|
-
if (onlyBuildInfo || emitOnlyDtsFiles) {
|
|
33
|
-
// There should only be one tsBuildInfo and one set of declaration files
|
|
34
|
-
return EmitFilesPatch._baseEmitFiles(resolver, host, targetSourceFile, emitTransformers, emitOnlyDtsFiles, onlyBuildInfo, forceDtsEmit);
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
if (targetSourceFile && changedFiles) {
|
|
38
|
-
changedFiles.add(targetSourceFile);
|
|
39
|
-
}
|
|
40
|
-
let defaultModuleKindResult;
|
|
41
|
-
const diagnostics = [];
|
|
42
|
-
let emitSkipped = false;
|
|
43
|
-
for (const moduleKindToEmit of moduleKindsToEmit) {
|
|
44
|
-
const compilerOptions = moduleKindToEmit.isPrimary
|
|
45
|
-
? Object.assign({}, baseCompilerOptions) : Object.assign(Object.assign({}, baseCompilerOptions), { module: moduleKindToEmit.moduleKind, outDir: moduleKindToEmit.outFolderPath,
|
|
46
|
-
// Don't emit declarations for secondary module kinds
|
|
47
|
-
declaration: false, declarationMap: false });
|
|
48
|
-
if (!compilerOptions.outDir) {
|
|
49
|
-
throw new node_core_library_1.InternalError('Expected compilerOptions.outDir to be assigned');
|
|
50
|
-
}
|
|
51
|
-
const flavorResult = EmitFilesPatch._baseEmitFiles(resolver, Object.assign(Object.assign({}, host), { writeFile: EmitFilesPatch.wrapWriteFile(host.writeFile, moduleKindToEmit.jsExtensionOverride), getCompilerOptions: () => compilerOptions }), targetSourceFile, ts.getTransformers(compilerOptions, undefined, emitOnlyDtsFiles), emitOnlyDtsFiles, onlyBuildInfo, forceDtsEmit);
|
|
52
|
-
emitSkipped = emitSkipped || flavorResult.emitSkipped;
|
|
53
|
-
for (const diagnostic of flavorResult.diagnostics) {
|
|
54
|
-
diagnostics.push(diagnostic);
|
|
55
|
-
}
|
|
56
|
-
if (moduleKindToEmit.moduleKind === defaultModuleKind) {
|
|
57
|
-
defaultModuleKindResult = flavorResult;
|
|
58
|
-
}
|
|
59
|
-
// Should results be aggregated, in case for whatever reason the diagnostics are not the same?
|
|
60
|
-
}
|
|
61
|
-
const mergedDiagnostics = ts.sortAndDeduplicateDiagnostics(diagnostics);
|
|
62
|
-
return Object.assign(Object.assign({}, defaultModuleKindResult), { diagnostics: mergedDiagnostics, emitSkipped });
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
// Override the underlying file emitter to run itself once for each flavor
|
|
66
|
-
// This is a rather inelegant way to convince the TypeScript compiler not to duplicate parse/link/check
|
|
67
|
-
ts.emitFiles = patchedEmitFiles;
|
|
68
|
-
}
|
|
69
|
-
static get isInstalled() {
|
|
70
|
-
return this._patchedTs !== undefined;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Wraps the writeFile callback on the IEmitHost to override the .js extension, if applicable
|
|
74
|
-
*/
|
|
75
|
-
static wrapWriteFile(baseWriteFile, jsExtensionOverride) {
|
|
76
|
-
if (!jsExtensionOverride) {
|
|
77
|
-
return baseWriteFile;
|
|
78
|
-
}
|
|
79
|
-
const replacementExtension = `${jsExtensionOverride}$1`;
|
|
80
|
-
return (fileName, data, writeBOM, onError, sourceFiles) => {
|
|
81
|
-
return baseWriteFile(fileName.replace(/\.js(\.map)?$/g, replacementExtension), data, writeBOM, onError, sourceFiles);
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
static uninstall(ts) {
|
|
85
|
-
if (EmitFilesPatch._patchedTs === undefined) {
|
|
86
|
-
throw new node_core_library_1.InternalError('EmitFilesPatch.uninstall() cannot be called if no patch was installed');
|
|
87
|
-
}
|
|
88
|
-
if (ts !== EmitFilesPatch._patchedTs) {
|
|
89
|
-
throw new node_core_library_1.InternalError('EmitFilesPatch.uninstall() called for the wrong object');
|
|
90
|
-
}
|
|
91
|
-
ts.emitFiles = EmitFilesPatch._baseEmitFiles;
|
|
92
|
-
EmitFilesPatch._patchedTs = undefined;
|
|
93
|
-
EmitFilesPatch._baseEmitFiles = undefined;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
exports.EmitFilesPatch = EmitFilesPatch;
|
|
97
|
-
EmitFilesPatch._patchedTs = undefined;
|
|
98
|
-
EmitFilesPatch._baseEmitFiles = undefined; // eslint-disable-line
|
|
99
|
-
//# sourceMappingURL=EmitFilesPatch.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EmitFilesPatch.js","sourceRoot":"","sources":["../src/EmitFilesPatch.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,oEAA6D;AA2B7D,MAAa,cAAc;IAKlB,MAAM,CAAC,OAAO,CACnB,EAAsB,EACtB,mBAAgD,EAChD,iBAA0C,EAC1C,YAA0C;QAE1C,IAAI,cAAc,CAAC,UAAU,KAAK,EAAE,EAAE;YACpC,yCAAyC;YACzC,OAAO;SACR;QAED,IAAI,cAAc,CAAC,UAAU,KAAK,SAAS,EAAE;YAC3C,MAAM,IAAI,iCAAa,CACrB,yFAAyF,CAC1F,CAAC;SACH;QAED,cAAc,CAAC,UAAU,GAAG,EAAE,CAAC;QAC/B,cAAc,CAAC,cAAc,GAAG,EAAE,CAAC,SAAS,CAAC;QAE7C,IAAI,YAAY,GAAY,KAAK,CAAC;QAClC,IAAI,iBAAyC,CAAC;QAE9C,KAAK,MAAM,gBAAgB,IAAI,iBAAiB,EAAE;YAChD,IAAI,gBAAgB,CAAC,SAAS,EAAE;gBAC9B,IAAI,YAAY,EAAE;oBAChB,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;iBACpE;qBAAM;oBACL,YAAY,GAAG,IAAI,CAAC;iBACrB;gBAED,iBAAiB,GAAG,gBAAgB,CAAC,UAAU,CAAC;aACjD;SACF;QAED,MAAM,gBAAgB,GAAG,CACvB,QAAuB,EACvB,IAAe,EACf,gBA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,EAAE;YACpC,MAAM,IAAI,iCAAa,CAAC,wDAAwD,CAAC,CAAC;SACnF;QAED,EAAE,CAAC,SAAS,GAAG,cAAc,CAAC,cAAc,CAAC;QAE7C,cAAc,CAAC,UAAU,GAAG,SAAS,CAAC;QACtC,cAAc,CAAC,cAAc,GAAG,SAAS,CAAC;IAC5C,CAAC;;AA7KH,wCA8KC;AA7KgB,yBAAU,GAAmC,SAAS,CAAC;AAEvD,6BAAc,GAAoB,SAAS,CAAC,CAAC,sBAAsB","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { InternalError } from '@rushstack/node-core-library';\nimport type * as TTypescript from 'typescript';\nimport {\n ExtendedTypeScript,\n IEmitResolver,\n IEmitHost,\n IEmitTransformers\n} from './internalTypings/TypeScriptInternals';\n\nexport interface ICachedEmitModuleKind {\n moduleKind: TTypescript.ModuleKind;\n\n outFolderPath: string;\n\n /**\n * File extension to use instead of '.js' for emitted ECMAScript files.\n * For example, '.cjs' to indicate commonjs content, or '.mjs' to indicate ECMAScript modules.\n */\n jsExtensionOverride: string | undefined;\n\n /**\n * Set to true if this is the emit kind that is specified in the tsconfig.json.\n * Declarations are only emitted for the primary module kind.\n */\n isPrimary: boolean;\n}\n\nexport class EmitFilesPatch {\n private static _patchedTs: ExtendedTypeScript | undefined = undefined;\n\n private static _baseEmitFiles: any | undefined = undefined; // eslint-disable-line\n\n public static install(\n ts: ExtendedTypeScript,\n baseCompilerOptions: TTypescript.CompilerOptions,\n moduleKindsToEmit: ICachedEmitModuleKind[],\n changedFiles?: Set<TTypescript.SourceFile>\n ): void {\n if (EmitFilesPatch._patchedTs === ts) {\n // We already patched this instance of TS\n return;\n }\n\n if (EmitFilesPatch._patchedTs !== undefined) {\n throw new InternalError(\n 'EmitFilesPatch.install() cannot be called without first uninstalling the existing patch'\n );\n }\n\n EmitFilesPatch._patchedTs = ts;\n EmitFilesPatch._baseEmitFiles = ts.emitFiles;\n\n let foundPrimary: boolean = false;\n let defaultModuleKind: TTypescript.ModuleKind;\n\n for (const moduleKindToEmit of moduleKindsToEmit) {\n if (moduleKindToEmit.isPrimary) {\n if (foundPrimary) {\n throw new Error('Multiple primary module emit kinds encountered.');\n } else {\n foundPrimary = true;\n }\n\n defaultModuleKind = moduleKindToEmit.moduleKind;\n }\n }\n\n const patchedEmitFiles = (\n resolver: IEmitResolver,\n host: IEmitHost,\n targetSourceFile: TTypescript.SourceFile | undefined,\n emitTransformers: IEmitTransformers,\n emitOnlyDtsFiles?: boolean,\n onlyBuildInfo?: boolean,\n forceDtsEmit?: boolean\n ): TTypescript.EmitResult => {\n if (onlyBuildInfo || emitOnlyDtsFiles) {\n // There should only be one tsBuildInfo and one set of declaration files\n return EmitFilesPatch._baseEmitFiles(\n resolver,\n host,\n targetSourceFile,\n emitTransformers,\n emitOnlyDtsFiles,\n onlyBuildInfo,\n forceDtsEmit\n );\n } else {\n if (targetSourceFile && changedFiles) {\n changedFiles.add(targetSourceFile);\n }\n\n let defaultModuleKindResult: TTypescript.EmitResult;\n const diagnostics: TTypescript.Diagnostic[] = [];\n let emitSkipped: boolean = false;\n for (const moduleKindToEmit of moduleKindsToEmit) {\n const compilerOptions: TTypescript.CompilerOptions = moduleKindToEmit.isPrimary\n ? {\n ...baseCompilerOptions\n }\n : {\n ...baseCompilerOptions,\n module: moduleKindToEmit.moduleKind,\n outDir: moduleKindToEmit.outFolderPath,\n\n // Don't emit declarations for secondary module kinds\n declaration: false,\n declarationMap: false\n };\n\n if (!compilerOptions.outDir) {\n throw new InternalError('Expected compilerOptions.outDir to be assigned');\n }\n\n const flavorResult: TTypescript.EmitResult = EmitFilesPatch._baseEmitFiles(\n resolver,\n {\n ...host,\n writeFile: EmitFilesPatch.wrapWriteFile(host.writeFile, moduleKindToEmit.jsExtensionOverride),\n getCompilerOptions: () => compilerOptions\n },\n targetSourceFile,\n ts.getTransformers(compilerOptions, undefined, emitOnlyDtsFiles),\n emitOnlyDtsFiles,\n onlyBuildInfo,\n forceDtsEmit\n );\n\n emitSkipped = emitSkipped || flavorResult.emitSkipped;\n for (const diagnostic of flavorResult.diagnostics) {\n diagnostics.push(diagnostic);\n }\n\n if (moduleKindToEmit.moduleKind === defaultModuleKind) {\n defaultModuleKindResult = flavorResult;\n }\n // Should results be aggregated, in case for whatever reason the diagnostics are not the same?\n }\n\n const mergedDiagnostics: readonly TTypescript.Diagnostic[] =\n ts.sortAndDeduplicateDiagnostics(diagnostics);\n\n return {\n ...defaultModuleKindResult!,\n diagnostics: mergedDiagnostics,\n emitSkipped\n };\n }\n };\n\n // Override the underlying file emitter to run itself once for each flavor\n // This is a rather inelegant way to convince the TypeScript compiler not to duplicate parse/link/check\n ts.emitFiles = patchedEmitFiles;\n }\n\n public static get isInstalled(): boolean {\n return this._patchedTs !== undefined;\n }\n\n /**\n * Wraps the writeFile callback on the IEmitHost to override the .js extension, if applicable\n */\n public static wrapWriteFile(\n baseWriteFile: TTypescript.WriteFileCallback,\n jsExtensionOverride: string | undefined\n ): TTypescript.WriteFileCallback {\n if (!jsExtensionOverride) {\n return baseWriteFile;\n }\n\n const replacementExtension: string = `${jsExtensionOverride}$1`;\n return (\n fileName: string,\n data: string,\n writeBOM: boolean,\n onError?: ((message: string) => void) | undefined,\n sourceFiles?: readonly TTypescript.SourceFile[] | undefined\n ) => {\n return baseWriteFile(\n fileName.replace(/\\.js(\\.map)?$/g, replacementExtension),\n data,\n writeBOM,\n onError,\n sourceFiles\n );\n };\n }\n\n public static uninstall(ts: ExtendedTypeScript): void {\n if (EmitFilesPatch._patchedTs === undefined) {\n throw new InternalError('EmitFilesPatch.uninstall() cannot be called if no patch was installed');\n }\n if (ts !== EmitFilesPatch._patchedTs) {\n throw new InternalError('EmitFilesPatch.uninstall() called for the wrong object');\n }\n\n ts.emitFiles = EmitFilesPatch._baseEmitFiles;\n\n EmitFilesPatch._patchedTs = undefined;\n EmitFilesPatch._baseEmitFiles = undefined;\n }\n}\n"]}
|