@rushstack/heft-typescript-plugin 0.0.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/LICENSE +24 -0
- package/README.md +12 -0
- package/dist/heft-typescript-plugin.d.ts +110 -0
- package/dist/tsdoc-metadata.json +11 -0
- package/heft-plugin.json +10 -0
- package/lib/Performance.d.ts +7 -0
- package/lib/Performance.d.ts.map +1 -0
- package/lib/Performance.js +5 -0
- package/lib/Performance.js.map +1 -0
- package/lib/TranspilerWorker.d.ts +2 -0
- package/lib/TranspilerWorker.d.ts.map +1 -0
- package/lib/TranspilerWorker.js +85 -0
- package/lib/TranspilerWorker.js.map +1 -0
- package/lib/TypeScriptBuilder.d.ts +96 -0
- package/lib/TypeScriptBuilder.d.ts.map +1 -0
- package/lib/TypeScriptBuilder.js +790 -0
- package/lib/TypeScriptBuilder.js.map +1 -0
- package/lib/TypeScriptPlugin.d.ts +100 -0
- package/lib/TypeScriptPlugin.d.ts.map +1 -0
- package/lib/TypeScriptPlugin.js +219 -0
- package/lib/TypeScriptPlugin.js.map +1 -0
- 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/fileSystem/TypeScriptCachedFileSystem.d.ts +36 -0
- package/lib/fileSystem/TypeScriptCachedFileSystem.d.ts.map +1 -0
- package/lib/fileSystem/TypeScriptCachedFileSystem.js +163 -0
- package/lib/fileSystem/TypeScriptCachedFileSystem.js.map +1 -0
- package/lib/index.d.ts +8 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +10 -0
- package/lib/index.js.map +1 -0
- package/lib/internalTypings/TypeScriptInternals.d.ts +56 -0
- package/lib/internalTypings/TypeScriptInternals.d.ts.map +1 -0
- package/lib/internalTypings/TypeScriptInternals.js +5 -0
- package/lib/internalTypings/TypeScriptInternals.js.map +1 -0
- package/lib/schemas/anything.schema.json +28 -0
- package/lib/schemas/typescript.schema.json +101 -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 +39 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.configureProgramForMultiEmit = void 0;
|
|
4
|
+
const node_core_library_1 = require("@rushstack/node-core-library");
|
|
5
|
+
// symbols for attaching hidden metadata to ts.Program instances.
|
|
6
|
+
const INNER_GET_COMPILER_OPTIONS_SYMBOL = Symbol('getCompilerOptions');
|
|
7
|
+
const INNER_EMIT_SYMBOL = Symbol('emit');
|
|
8
|
+
const JS_EXTENSION_REGEX = /\.js(\.map)?$/;
|
|
9
|
+
function wrapWriteFile(baseWriteFile, jsExtensionOverride) {
|
|
10
|
+
if (!jsExtensionOverride) {
|
|
11
|
+
return baseWriteFile;
|
|
12
|
+
}
|
|
13
|
+
const replacementExtension = `${jsExtensionOverride}$1`;
|
|
14
|
+
return (fileName, data, writeBOM, onError, sourceFiles) => {
|
|
15
|
+
return baseWriteFile(fileName.replace(JS_EXTENSION_REGEX, replacementExtension), data, writeBOM, onError, sourceFiles);
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function configureProgramForMultiEmit(innerProgram, ts, moduleKindsToEmit, mode) {
|
|
19
|
+
const program = innerProgram;
|
|
20
|
+
// Check to see if this Program has already been modified.
|
|
21
|
+
let { [INNER_EMIT_SYMBOL]: innerEmit, [INNER_GET_COMPILER_OPTIONS_SYMBOL]: innerGetCompilerOptions } = program;
|
|
22
|
+
if (!innerGetCompilerOptions) {
|
|
23
|
+
program[INNER_GET_COMPILER_OPTIONS_SYMBOL] = innerGetCompilerOptions = program.getCompilerOptions;
|
|
24
|
+
}
|
|
25
|
+
if (!innerEmit) {
|
|
26
|
+
program[INNER_EMIT_SYMBOL] = innerEmit = program.emit;
|
|
27
|
+
}
|
|
28
|
+
let foundPrimary = false;
|
|
29
|
+
let defaultModuleKind;
|
|
30
|
+
const multiEmitMap = new Map();
|
|
31
|
+
for (const moduleKindToEmit of moduleKindsToEmit) {
|
|
32
|
+
const kindCompilerOptions = moduleKindToEmit.isPrimary
|
|
33
|
+
? Object.assign({}, innerGetCompilerOptions()) : Object.assign(Object.assign({}, innerGetCompilerOptions()), { module: moduleKindToEmit.moduleKind, outDir: moduleKindToEmit.outFolderPath,
|
|
34
|
+
// Don't emit declarations for secondary module kinds
|
|
35
|
+
declaration: false, declarationMap: false });
|
|
36
|
+
if (!kindCompilerOptions.outDir) {
|
|
37
|
+
throw new node_core_library_1.InternalError('Expected compilerOptions.outDir to be assigned');
|
|
38
|
+
}
|
|
39
|
+
if (mode === 'transpile') {
|
|
40
|
+
kindCompilerOptions.declaration = false;
|
|
41
|
+
kindCompilerOptions.declarationMap = false;
|
|
42
|
+
}
|
|
43
|
+
else if (mode === 'declaration') {
|
|
44
|
+
kindCompilerOptions.emitDeclarationOnly = true;
|
|
45
|
+
}
|
|
46
|
+
if (moduleKindToEmit.isPrimary || mode !== 'declaration') {
|
|
47
|
+
multiEmitMap.set(moduleKindToEmit, kindCompilerOptions);
|
|
48
|
+
}
|
|
49
|
+
if (moduleKindToEmit.isPrimary) {
|
|
50
|
+
if (foundPrimary) {
|
|
51
|
+
throw new Error('Multiple primary module emit kinds encountered.');
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
foundPrimary = true;
|
|
55
|
+
}
|
|
56
|
+
defaultModuleKind = moduleKindToEmit.moduleKind;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const changedFiles = new Set();
|
|
60
|
+
program.emit = (targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) => {
|
|
61
|
+
if (emitOnlyDtsFiles) {
|
|
62
|
+
return program[INNER_EMIT_SYMBOL](targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers);
|
|
63
|
+
}
|
|
64
|
+
if (targetSourceFile && changedFiles) {
|
|
65
|
+
changedFiles.add(targetSourceFile);
|
|
66
|
+
}
|
|
67
|
+
const originalCompilerOptions = program[INNER_GET_COMPILER_OPTIONS_SYMBOL]();
|
|
68
|
+
let defaultModuleKindResult;
|
|
69
|
+
const diagnostics = [];
|
|
70
|
+
let emitSkipped = false;
|
|
71
|
+
try {
|
|
72
|
+
for (const [moduleKindToEmit, kindCompilerOptions] of multiEmitMap) {
|
|
73
|
+
program.getCompilerOptions = () => kindCompilerOptions;
|
|
74
|
+
// Need to mutate the compiler options for the `module` field specifically, because emitWorker() captures
|
|
75
|
+
// options in the closure and passes it to `ts.getTransformers()`
|
|
76
|
+
originalCompilerOptions.module = moduleKindToEmit.moduleKind;
|
|
77
|
+
const flavorResult = program[INNER_EMIT_SYMBOL](targetSourceFile, writeFile && wrapWriteFile(writeFile, moduleKindToEmit.jsExtensionOverride), cancellationToken, emitOnlyDtsFiles, customTransformers);
|
|
78
|
+
emitSkipped = emitSkipped || flavorResult.emitSkipped;
|
|
79
|
+
// Need to aggregate diagnostics because some are impacted by the target module type
|
|
80
|
+
for (const diagnostic of flavorResult.diagnostics) {
|
|
81
|
+
diagnostics.push(diagnostic);
|
|
82
|
+
}
|
|
83
|
+
if (moduleKindToEmit.moduleKind === defaultModuleKind) {
|
|
84
|
+
defaultModuleKindResult = flavorResult;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const mergedDiagnostics = ts.sortAndDeduplicateDiagnostics(diagnostics);
|
|
88
|
+
return Object.assign(Object.assign({}, defaultModuleKindResult), { changedSourceFiles: changedFiles, diagnostics: mergedDiagnostics, emitSkipped });
|
|
89
|
+
}
|
|
90
|
+
finally {
|
|
91
|
+
// Restore the original compiler options and module kind for future calls
|
|
92
|
+
program.getCompilerOptions = program[INNER_GET_COMPILER_OPTIONS_SYMBOL];
|
|
93
|
+
originalCompilerOptions.module = defaultModuleKind;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
return { changedFiles };
|
|
97
|
+
}
|
|
98
|
+
exports.configureProgramForMultiEmit = configureProgramForMultiEmit;
|
|
99
|
+
//# sourceMappingURL=configureProgramForMultiEmit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configureProgramForMultiEmit.js","sourceRoot":"","sources":["../src/configureProgramForMultiEmit.ts"],"names":[],"mappings":";;;AAGA,oEAA6D;AAK7D,iEAAiE;AACjE,MAAM,iCAAiC,GAAkB,MAAM,CAAC,oBAAoB,CAAC,CAAC;AACtF,MAAM,iBAAiB,GAAkB,MAAM,CAAC,MAAM,CAAC,CAAC;AAExD,MAAM,kBAAkB,GAAW,eAAe,CAAC;AAEnD,SAAS,aAAa,CAEpB,aAA4C,EAC5C,mBAAuC;IAEvC,IAAI,CAAC,mBAAmB,EAAE;QACxB,OAAO,aAAa,CAAC;KACtB;IAED,MAAM,oBAAoB,GAAW,GAAG,mBAAmB,IAAI,CAAC;IAChE,OAAO,CACL,QAAgB,EAChB,IAAY,EACZ,QAAiB,EACjB,OAAiD,EACjD,WAA2D,EAC3D,EAAE;QACF,OAAO,aAAa,CAClB,QAAQ,CAAC,OAAO,CAAC,kBAAkB,EAAE,oBAAoB,CAAC,EAC1D,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,WAAW,CACZ,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED,SAAgB,4BAA4B,CAE1C,YAAiC,EACjC,EAAsB,EACtB,iBAA0C,EAC1C,IAA0C;IAS1C,MAAM,OAAO,GAA0B,YAAY,CAAC;IAEpD,0DAA0D;IAC1D,IAAI,EAAE,CAAC,iBAAiB,CAAC,EAAE,SAAS,EAAE,CAAC,iCAAiC,CAAC,EAAE,uBAAuB,EAAE,GAClG,OAAO,CAAC;IAEV,IAAI,CAAC,uBAAuB,EAAE;QAC5B,OAAO,CAAC,iCAAiC,CAAC,GAAG,uBAAuB,GAAG,OAAO,CAAC,kBAAk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EAAE;oBACrD,uBAAuB,GAAG,YAAY,CAAC;iBACxC;aACF;YAED,MAAM,iBAAiB,GACrB,EAAE,CAAC,6BAA6B,CAAC,WAAW,CAAC,CAAC;YAEhD,uCACK,uBAAwB,KAC3B,kBAAkB,EAAE,YAAY,EAChC,WAAW,EAAE,iBAAiB,EAC9B,WAAW,IACX;SACH;gBAAS;YACR,yEAAyE;YACzE,OAAO,CAAC,kBAAkB,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"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { IFileSystemWriteFileOptions, IFileSystemReadFileOptions, IFileSystemCopyFileOptions, IFileSystemDeleteFileOptions, IFileSystemCreateLinkOptions, FileSystemStats } from '@rushstack/node-core-library';
|
|
3
|
+
export interface IReadFolderFilesAndDirectoriesResult {
|
|
4
|
+
files: string[];
|
|
5
|
+
directories: string[];
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* This is a FileSystem API (largely unrelated to the @rushstack/node-core-library FileSystem API)
|
|
9
|
+
* that provides caching to the Heft TypeScriptBuilder.
|
|
10
|
+
* It uses an in-memory cache to avoid requests against the disk. It assumes that the disk stays
|
|
11
|
+
* static after construction, except for writes performed through the TypeScriptCachedFileSystem
|
|
12
|
+
* instance.
|
|
13
|
+
*/
|
|
14
|
+
export declare class TypeScriptCachedFileSystem {
|
|
15
|
+
private _statsCache;
|
|
16
|
+
private _readFolderCache;
|
|
17
|
+
private _readFileCache;
|
|
18
|
+
private _realPathCache;
|
|
19
|
+
exists: (path: string) => boolean;
|
|
20
|
+
directoryExists: (path: string) => boolean;
|
|
21
|
+
getStatistics: (path: string) => FileSystemStats;
|
|
22
|
+
ensureFolder: (folderPath: string) => void;
|
|
23
|
+
ensureFolderAsync: (folderPath: string) => Promise<void>;
|
|
24
|
+
writeFile: (filePath: string, contents: string | Buffer, options?: IFileSystemWriteFileOptions | undefined) => void;
|
|
25
|
+
readFile: (filePath: string, options?: IFileSystemReadFileOptions | undefined) => string;
|
|
26
|
+
readFileToBuffer: (filePath: string) => Buffer;
|
|
27
|
+
copyFileAsync: (options: IFileSystemCopyFileOptions) => Promise<void>;
|
|
28
|
+
deleteFile: (filePath: string, options?: IFileSystemDeleteFileOptions | undefined) => void;
|
|
29
|
+
createHardLinkAsync: (options: IFileSystemCreateLinkOptions) => Promise<void>;
|
|
30
|
+
getRealPath: (linkPath: string) => string;
|
|
31
|
+
readFolderFilesAndDirectories: (folderPath: string) => IReadFolderFilesAndDirectoriesResult;
|
|
32
|
+
private _sortFolderEntries;
|
|
33
|
+
private _withCaching;
|
|
34
|
+
private _invalidateCacheEntry;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=TypeScriptCachedFileSystem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TypeScriptCachedFileSystem.d.ts","sourceRoot":"","sources":["../../src/fileSystem/TypeScriptCachedFileSystem.ts"],"names":[],"mappings":";AAGA,OAAO,EAGL,2BAA2B,EAC3B,0BAA0B,EAC1B,0BAA0B,EAC1B,4BAA4B,EAC5B,4BAA4B,EAE5B,eAAe,EAGhB,MAAM,8BAA8B,CAAC;AAEtC,MAAM,WAAW,oCAAoC;IACnD,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAOD;;;;;;GAMG;AACH,qBAAa,0BAA0B;IACrC,OAAO,CAAC,WAAW,CAAwD;IAC3E,OAAO,CAAC,gBAAgB,CAA6E;IACrG,OAAO,CAAC,cAAc,CAA+C;IACrE,OAAO,CAAC,cAAc,CAA+C;IAE9D,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAWtC;IAEK,eAAe,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAW/C;IAEK,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,eAAe,CAErD;IAEK,YAAY,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAK/C;IAEK,iBAAiB,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAK7D;IAEK,SAAS,EAAE,CAChB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,GAAG,MAAM,EACzB,OAAO,CAAC,EAAE,2BAA2B,GAAG,SAAS,KAC9C,IAAI,CAOP;IAEK,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,0BAA0B,GAAG,SAAS,KAAK,MAAM,CAU7F;IAEK,gBAAgB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAEnD;IAEK,aAAa,EAAE,CAAC,OAAO,EAAE,0BAA0B,KAAK,OAAO,CAAC,IAAI,CAAC,CAK1E;IAEK,UAAU,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,4BAA4B,GAAG,SAAS,KAAK,IAAI,CAW/F;IAEK,mBAAmB,EAAE,CAAC,OAAO,EAAE,4BAA4B,KAAK,OAAO,CAAC,IAAI,CAAC,CAKlF;IAEK,WAAW,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAiB9C;IAEK,6BAA6B,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,oCAAoC,CAWhG;IAEF,OAAO,CAAC,kBAAkB;IAkB1B,OAAO,CAAC,YAAY;IAuBpB,OAAO,CAAC,qBAAqB;CAM9B"}
|
|
@@ -0,0 +1,163 @@
|
|
|
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.TypeScriptCachedFileSystem = void 0;
|
|
6
|
+
const node_core_library_1 = require("@rushstack/node-core-library");
|
|
7
|
+
/**
|
|
8
|
+
* This is a FileSystem API (largely unrelated to the @rushstack/node-core-library FileSystem API)
|
|
9
|
+
* that provides caching to the Heft TypeScriptBuilder.
|
|
10
|
+
* It uses an in-memory cache to avoid requests against the disk. It assumes that the disk stays
|
|
11
|
+
* static after construction, except for writes performed through the TypeScriptCachedFileSystem
|
|
12
|
+
* instance.
|
|
13
|
+
*/
|
|
14
|
+
class TypeScriptCachedFileSystem {
|
|
15
|
+
constructor() {
|
|
16
|
+
this._statsCache = new Map();
|
|
17
|
+
this._readFolderCache = new Map();
|
|
18
|
+
this._readFileCache = new Map();
|
|
19
|
+
this._realPathCache = new Map();
|
|
20
|
+
this.exists = (path) => {
|
|
21
|
+
try {
|
|
22
|
+
this.getStatistics(path);
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
catch (e) {
|
|
26
|
+
if (node_core_library_1.FileSystem.isNotExistError(e)) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
throw e;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
this.directoryExists = (path) => {
|
|
35
|
+
try {
|
|
36
|
+
const stats = this.getStatistics(path);
|
|
37
|
+
return stats.isDirectory();
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
if (node_core_library_1.FileSystem.isNotExistError(e)) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
throw e;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
this.getStatistics = (path) => {
|
|
49
|
+
return this._withCaching(path, node_core_library_1.FileSystem.getStatistics, this._statsCache);
|
|
50
|
+
};
|
|
51
|
+
this.ensureFolder = (folderPath) => {
|
|
52
|
+
var _a, _b;
|
|
53
|
+
if (!((_a = this._readFolderCache.get(folderPath)) === null || _a === void 0 ? void 0 : _a.entry) && !((_b = this._statsCache.get(folderPath)) === null || _b === void 0 ? void 0 : _b.entry)) {
|
|
54
|
+
node_core_library_1.FileSystem.ensureFolder(folderPath);
|
|
55
|
+
this._invalidateCacheEntry(folderPath);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
this.ensureFolderAsync = async (folderPath) => {
|
|
59
|
+
var _a, _b;
|
|
60
|
+
if (!((_a = this._readFolderCache.get(folderPath)) === null || _a === void 0 ? void 0 : _a.entry) && !((_b = this._statsCache.get(folderPath)) === null || _b === void 0 ? void 0 : _b.entry)) {
|
|
61
|
+
await node_core_library_1.FileSystem.ensureFolderAsync(folderPath);
|
|
62
|
+
this._invalidateCacheEntry(folderPath);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
this.writeFile = (filePath, contents, options) => {
|
|
66
|
+
node_core_library_1.FileSystem.writeFile(filePath, contents, options);
|
|
67
|
+
this._invalidateCacheEntry(filePath);
|
|
68
|
+
};
|
|
69
|
+
this.readFile = (filePath, options) => {
|
|
70
|
+
let contents = this.readFileToBuffer(filePath).toString((options === null || options === void 0 ? void 0 : options.encoding) || node_core_library_1.Encoding.Utf8);
|
|
71
|
+
if (options === null || options === void 0 ? void 0 : options.convertLineEndings) {
|
|
72
|
+
contents = node_core_library_1.Text.convertTo(contents, options.convertLineEndings);
|
|
73
|
+
}
|
|
74
|
+
return contents;
|
|
75
|
+
};
|
|
76
|
+
this.readFileToBuffer = (filePath) => {
|
|
77
|
+
return this._withCaching(filePath, node_core_library_1.FileSystem.readFileToBuffer, this._readFileCache);
|
|
78
|
+
};
|
|
79
|
+
this.copyFileAsync = async (options) => {
|
|
80
|
+
await node_core_library_1.FileSystem.copyFileAsync(options);
|
|
81
|
+
this._invalidateCacheEntry(options.destinationPath);
|
|
82
|
+
};
|
|
83
|
+
this.deleteFile = (filePath, options) => {
|
|
84
|
+
var _a;
|
|
85
|
+
const cachedError = (_a = this._statsCache.get(filePath)) === null || _a === void 0 ? void 0 : _a.error;
|
|
86
|
+
if (!cachedError || !node_core_library_1.FileSystem.isFileDoesNotExistError(cachedError)) {
|
|
87
|
+
node_core_library_1.FileSystem.deleteFile(filePath);
|
|
88
|
+
this._invalidateCacheEntry(filePath);
|
|
89
|
+
}
|
|
90
|
+
else if (options === null || options === void 0 ? void 0 : options.throwIfNotExists) {
|
|
91
|
+
throw cachedError;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
this.createHardLinkAsync = async (options) => {
|
|
95
|
+
await node_core_library_1.FileSystem.createHardLinkAsync(options);
|
|
96
|
+
this._invalidateCacheEntry(options.newLinkPath);
|
|
97
|
+
};
|
|
98
|
+
this.getRealPath = (linkPath) => {
|
|
99
|
+
return this._withCaching(linkPath, (linkPath) => {
|
|
100
|
+
try {
|
|
101
|
+
return node_core_library_1.FileSystem.getRealPath(linkPath);
|
|
102
|
+
}
|
|
103
|
+
catch (e) {
|
|
104
|
+
if (node_core_library_1.FileSystem.isNotExistError(e)) {
|
|
105
|
+
// TypeScript's ts.sys.realpath returns the path it's provided if that path doesn't exist
|
|
106
|
+
return linkPath;
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
throw e;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}, this._realPathCache);
|
|
113
|
+
};
|
|
114
|
+
this.readFolderFilesAndDirectories = (folderPath) => {
|
|
115
|
+
return this._withCaching(folderPath, (path) => {
|
|
116
|
+
const folderEntries = node_core_library_1.FileSystem.readFolderItems(path);
|
|
117
|
+
return this._sortFolderEntries(folderEntries);
|
|
118
|
+
}, this._readFolderCache);
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
_sortFolderEntries(folderEntries) {
|
|
122
|
+
// TypeScript expects entries sorted ordinally by name
|
|
123
|
+
// In practice this might not matter
|
|
124
|
+
folderEntries.sort((a, b) => node_core_library_1.Sort.compareByValue(a, b));
|
|
125
|
+
const files = [];
|
|
126
|
+
const directories = [];
|
|
127
|
+
for (const folderEntry of folderEntries) {
|
|
128
|
+
if (folderEntry.isFile()) {
|
|
129
|
+
files.push(folderEntry.name);
|
|
130
|
+
}
|
|
131
|
+
else if (folderEntry.isDirectory()) {
|
|
132
|
+
directories.push(folderEntry.name);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return { files, directories };
|
|
136
|
+
}
|
|
137
|
+
_withCaching(path, fn, cache) {
|
|
138
|
+
let cacheEntry = cache.get(path);
|
|
139
|
+
if (!cacheEntry) {
|
|
140
|
+
try {
|
|
141
|
+
cacheEntry = { entry: fn(path) };
|
|
142
|
+
}
|
|
143
|
+
catch (e) {
|
|
144
|
+
cacheEntry = { error: e, entry: undefined };
|
|
145
|
+
}
|
|
146
|
+
cache.set(path, cacheEntry);
|
|
147
|
+
}
|
|
148
|
+
if (cacheEntry.entry) {
|
|
149
|
+
return cacheEntry.entry;
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
throw cacheEntry.error;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
_invalidateCacheEntry(path) {
|
|
156
|
+
this._statsCache.delete(path);
|
|
157
|
+
this._readFolderCache.delete(path);
|
|
158
|
+
this._readFileCache.delete(path);
|
|
159
|
+
this._realPathCache.delete(path);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
exports.TypeScriptCachedFileSystem = TypeScriptCachedFileSystem;
|
|
163
|
+
//# sourceMappingURL=TypeScriptCachedFileSystem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TypeScriptCachedFileSystem.js","sourceRoot":"","sources":["../../src/fileSystem/TypeScriptCachedFileSystem.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,oEAYsC;AAYtC;;;;;;GAMG;AACH,MAAa,0BAA0B;IAAvC;QACU,gBAAW,GAA8C,IAAI,GAAG,EAAE,CAAC;QACnE,qBAAgB,GAAmE,IAAI,GAAG,EAAE,CAAC;QAC7F,mBAAc,GAAqC,IAAI,GAAG,EAAE,CAAC;QAC7D,mBAAc,GAAqC,IAAI,GAAG,EAAE,CAAC;QAE9D,WAAM,GAA8B,CAAC,IAAY,EAAE,EAAE;YAC1D,IAAI;gBACF,IAAI,CAAC,aAAa,CAAC,IAAI,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AU,CAAC,KAAK,EAAE;YACpB,OAAO,UAAU,CAAC,KAAK,CAAC;SACzB;aAAM;YACL,MAAM,UAAU,CAAC,KAAK,CAAC;SACxB;IACH,CAAC;IAEO,qBAAqB,CAAC,IAAY;QACxC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC9B,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;CACF;AAzLD,gEAyLC","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 {\n Encoding,\n Text,\n IFileSystemWriteFileOptions,\n IFileSystemReadFileOptions,\n IFileSystemCopyFileOptions,\n IFileSystemDeleteFileOptions,\n IFileSystemCreateLinkOptions,\n FileSystem,\n FileSystemStats,\n Sort,\n FolderItem\n} from '@rushstack/node-core-library';\n\nexport interface IReadFolderFilesAndDirectoriesResult {\n files: string[];\n directories: string[];\n}\n\ninterface ICacheEntry<TEntry> {\n entry: TEntry | undefined;\n error?: NodeJS.ErrnoException;\n}\n\n/**\n * This is a FileSystem API (largely unrelated to the @rushstack/node-core-library FileSystem API)\n * that provides caching to the Heft TypeScriptBuilder.\n * It uses an in-memory cache to avoid requests against the disk. It assumes that the disk stays\n * static after construction, except for writes performed through the TypeScriptCachedFileSystem\n * instance.\n */\nexport class TypeScriptCachedFileSystem {\n private _statsCache: Map<string, ICacheEntry<FileSystemStats>> = new Map();\n private _readFolderCache: Map<string, ICacheEntry<IReadFolderFilesAndDirectoriesResult>> = new Map();\n private _readFileCache: Map<string, ICacheEntry<Buffer>> = new Map();\n private _realPathCache: Map<string, ICacheEntry<string>> = new Map();\n\n public exists: (path: string) => boolean = (path: string) => {\n try {\n this.getStatistics(path);\n return true;\n } catch (e) {\n if (FileSystem.isNotExistError(e as Error)) {\n return false;\n } else {\n throw e;\n }\n }\n };\n\n public directoryExists: (path: string) => boolean = (path: string) => {\n try {\n const stats: FileSystemStats = this.getStatistics(path);\n return stats.isDirectory();\n } catch (e) {\n if (FileSystem.isNotExistError(e as Error)) {\n return false;\n } else {\n throw e;\n }\n }\n };\n\n public getStatistics: (path: string) => FileSystemStats = (path: string) => {\n return this._withCaching(path, FileSystem.getStatistics, this._statsCache);\n };\n\n public ensureFolder: (folderPath: string) => void = (folderPath: string) => {\n if (!this._readFolderCache.get(folderPath)?.entry && !this._statsCache.get(folderPath)?.entry) {\n FileSystem.ensureFolder(folderPath);\n this._invalidateCacheEntry(folderPath);\n }\n };\n\n public ensureFolderAsync: (folderPath: string) => Promise<void> = async (folderPath: string) => {\n if (!this._readFolderCache.get(folderPath)?.entry && !this._statsCache.get(folderPath)?.entry) {\n await FileSystem.ensureFolderAsync(folderPath);\n this._invalidateCacheEntry(folderPath);\n }\n };\n\n public writeFile: (\n filePath: string,\n contents: string | Buffer,\n options?: IFileSystemWriteFileOptions | undefined\n ) => void = (\n filePath: string,\n contents: string | Buffer,\n options?: IFileSystemWriteFileOptions | undefined\n ) => {\n FileSystem.writeFile(filePath, contents, options);\n this._invalidateCacheEntry(filePath);\n };\n\n public readFile: (filePath: string, options?: IFileSystemReadFileOptions | undefined) => string = (\n filePath: string,\n options?: IFileSystemReadFileOptions | undefined\n ) => {\n let contents: string = this.readFileToBuffer(filePath).toString(options?.encoding || Encoding.Utf8);\n if (options?.convertLineEndings) {\n contents = Text.convertTo(contents, options.convertLineEndings);\n }\n\n return contents;\n };\n\n public readFileToBuffer: (filePath: string) => Buffer = (filePath: string) => {\n return this._withCaching(filePath, FileSystem.readFileToBuffer, this._readFileCache);\n };\n\n public copyFileAsync: (options: IFileSystemCopyFileOptions) => Promise<void> = async (\n options: IFileSystemCopyFileOptions\n ) => {\n await FileSystem.copyFileAsync(options);\n this._invalidateCacheEntry(options.destinationPath);\n };\n\n public deleteFile: (filePath: string, options?: IFileSystemDeleteFileOptions | undefined) => void = (\n filePath: string,\n options?: IFileSystemDeleteFileOptions | undefined\n ) => {\n const cachedError: Error | undefined = this._statsCache.get(filePath)?.error;\n if (!cachedError || !FileSystem.isFileDoesNotExistError(cachedError)) {\n FileSystem.deleteFile(filePath);\n this._invalidateCacheEntry(filePath);\n } else if (options?.throwIfNotExists) {\n throw cachedError;\n }\n };\n\n public createHardLinkAsync: (options: IFileSystemCreateLinkOptions) => Promise<void> = async (\n options: IFileSystemCreateLinkOptions\n ) => {\n await FileSystem.createHardLinkAsync(options);\n this._invalidateCacheEntry(options.newLinkPath);\n };\n\n public getRealPath: (linkPath: string) => string = (linkPath: string) => {\n return this._withCaching(\n linkPath,\n (linkPath: string) => {\n try {\n return FileSystem.getRealPath(linkPath);\n } catch (e) {\n if (FileSystem.isNotExistError(e as Error)) {\n // TypeScript's ts.sys.realpath returns the path it's provided if that path doesn't exist\n return linkPath;\n } else {\n throw e;\n }\n }\n },\n this._realPathCache\n );\n };\n\n public readFolderFilesAndDirectories: (folderPath: string) => IReadFolderFilesAndDirectoriesResult = (\n folderPath: string\n ) => {\n return this._withCaching(\n folderPath,\n (path: string) => {\n const folderEntries: FolderItem[] = FileSystem.readFolderItems(path);\n return this._sortFolderEntries(folderEntries);\n },\n this._readFolderCache\n );\n };\n\n private _sortFolderEntries(folderEntries: FolderItem[]): IReadFolderFilesAndDirectoriesResult {\n // TypeScript expects entries sorted ordinally by name\n // In practice this might not matter\n folderEntries.sort((a, b) => Sort.compareByValue(a, b));\n\n const files: string[] = [];\n const directories: string[] = [];\n for (const folderEntry of folderEntries) {\n if (folderEntry.isFile()) {\n files.push(folderEntry.name);\n } else if (folderEntry.isDirectory()) {\n directories.push(folderEntry.name);\n }\n }\n\n return { files, directories };\n }\n\n private _withCaching<TResult>(\n path: string,\n fn: (path: string) => TResult,\n cache: Map<string, ICacheEntry<TResult>>\n ): TResult {\n let cacheEntry: ICacheEntry<TResult> | undefined = cache.get(path);\n if (!cacheEntry) {\n try {\n cacheEntry = { entry: fn(path) };\n } catch (e) {\n cacheEntry = { error: e as Error, entry: undefined };\n }\n\n cache.set(path, cacheEntry);\n }\n\n if (cacheEntry.entry) {\n return cacheEntry.entry;\n } else {\n throw cacheEntry.error;\n }\n }\n\n private _invalidateCacheEntry(path: string): void {\n this._statsCache.delete(path);\n this._readFolderCache.delete(path);\n this._readFileCache.delete(path);\n this._realPathCache.delete(path);\n }\n}\n"]}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Heft plugin for using TypeScript.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
export type { IEmitModuleKind, IStaticAssetsCopyConfiguration, ITypeScriptConfigurationJson, IPartialTsconfigCompilerOptions, IPartialTsconfig, IChangedFilesHookOptions, ITypeScriptPluginAccessor } from './TypeScriptPlugin';
|
|
7
|
+
export { PLUGIN_NAME as TypeScriptPluginName, loadTypeScriptConfigurationFileAsync, loadPartialTsconfigFileAsync } from './TypeScriptPlugin';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AAEH,YAAY,EACV,eAAe,EACf,8BAA8B,EAC9B,4BAA4B,EAC5B,+BAA+B,EAC/B,gBAAgB,EAChB,wBAAwB,EACxB,yBAAyB,EAC1B,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,WAAW,IAAI,oBAAoB,EACnC,oCAAoC,EACpC,4BAA4B,EAC7B,MAAM,oBAAoB,CAAC"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
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.loadPartialTsconfigFileAsync = exports.loadTypeScriptConfigurationFileAsync = exports.TypeScriptPluginName = void 0;
|
|
6
|
+
var TypeScriptPlugin_1 = require("./TypeScriptPlugin");
|
|
7
|
+
Object.defineProperty(exports, "TypeScriptPluginName", { enumerable: true, get: function () { return TypeScriptPlugin_1.PLUGIN_NAME; } });
|
|
8
|
+
Object.defineProperty(exports, "loadTypeScriptConfigurationFileAsync", { enumerable: true, get: function () { return TypeScriptPlugin_1.loadTypeScriptConfigurationFileAsync; } });
|
|
9
|
+
Object.defineProperty(exports, "loadPartialTsconfigFileAsync", { enumerable: true, get: function () { return TypeScriptPlugin_1.loadPartialTsconfigFileAsync; } });
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAkB3D,uDAI4B;AAH1B,wHAAA,WAAW,OAAwB;AACnC,wIAAA,oCAAoC,OAAA;AACpC,gIAAA,4BAA4B,OAAA","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\n/**\n * A Heft plugin for using TypeScript.\n *\n * @packageDocumentation\n */\n\nexport type {\n IEmitModuleKind,\n IStaticAssetsCopyConfiguration,\n ITypeScriptConfigurationJson,\n IPartialTsconfigCompilerOptions,\n IPartialTsconfig,\n IChangedFilesHookOptions,\n ITypeScriptPluginAccessor\n} from './TypeScriptPlugin';\n\nexport {\n PLUGIN_NAME as TypeScriptPluginName,\n loadTypeScriptConfigurationFileAsync,\n loadPartialTsconfigFileAsync\n} from './TypeScriptPlugin';\n"]}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type * as TTypescript from 'typescript';
|
|
2
|
+
export interface IExtendedSolutionBuilder extends TTypescript.SolutionBuilder<TTypescript.EmitAndSemanticDiagnosticsBuilderProgram> {
|
|
3
|
+
getBuildOrder(): readonly string[];
|
|
4
|
+
invalidateProject(configFilePath: string, mode: 0 | 1 | 2): void;
|
|
5
|
+
}
|
|
6
|
+
export interface IExtendedTypeScript {
|
|
7
|
+
/**
|
|
8
|
+
* https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/performance.ts#L3
|
|
9
|
+
*/
|
|
10
|
+
performance: {
|
|
11
|
+
/**
|
|
12
|
+
* https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/performance.ts#L119-L121
|
|
13
|
+
*/
|
|
14
|
+
disable(): void;
|
|
15
|
+
/**
|
|
16
|
+
* https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/performance.ts#L110-L116
|
|
17
|
+
*/
|
|
18
|
+
enable(): void;
|
|
19
|
+
/**
|
|
20
|
+
* https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/performance.ts#L55-L61
|
|
21
|
+
*/
|
|
22
|
+
mark(performanceMaker: string): void;
|
|
23
|
+
/**
|
|
24
|
+
* https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/performance.ts#L72-L78
|
|
25
|
+
*/
|
|
26
|
+
measure(measureName: string, startMarkName?: string, endMarkName?: string): void;
|
|
27
|
+
/**
|
|
28
|
+
* https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/performance.ts#L94-L96
|
|
29
|
+
*/
|
|
30
|
+
getDuration(measureName: string): number;
|
|
31
|
+
/**
|
|
32
|
+
* https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/performance.ts#L85-L87
|
|
33
|
+
*/
|
|
34
|
+
getCount(measureName: string): number;
|
|
35
|
+
};
|
|
36
|
+
transpileOptionValueCompilerOptions: {
|
|
37
|
+
name: keyof TTypescript.CompilerOptions;
|
|
38
|
+
transpileOptionValue: any;
|
|
39
|
+
}[];
|
|
40
|
+
getNewLineCharacter(compilerOptions: TTypescript.CompilerOptions): string;
|
|
41
|
+
/**
|
|
42
|
+
* https://github.com/microsoft/TypeScript/blob/782c09d783e006a697b4ba6d1e7ec2f718ce8393/src/compiler/utilities.ts#L6540
|
|
43
|
+
*/
|
|
44
|
+
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) => {
|
|
45
|
+
readonly files: ReadonlyArray<string>;
|
|
46
|
+
readonly directories: ReadonlyArray<string>;
|
|
47
|
+
}, realpath: (path: string) => string, directoryExists: (path: string) => boolean): string[];
|
|
48
|
+
Diagnostics: {
|
|
49
|
+
Found_1_error_Watching_for_file_changes: TTypescript.DiagnosticMessage;
|
|
50
|
+
Found_0_errors_Watching_for_file_changes: TTypescript.DiagnosticMessage;
|
|
51
|
+
Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor: TTypescript.DiagnosticMessage;
|
|
52
|
+
Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1: TTypescript.DiagnosticMessage;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export type ExtendedTypeScript = typeof TTypescript & IExtendedTypeScript;
|
|
56
|
+
//# sourceMappingURL=TypeScriptInternals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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,w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MAAM,KAAK;QACtC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;QACtC,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;KAC7C,EACD,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,EAClC,eAAe,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,GACzC,MAAM,EAAE,CAAC;IAEZ,WAAW,EAAE;QAGX,uCAAuC,EAAE,WAAW,CAAC,iBAAiB,CAAC;QAIvE,wCAAwC,EAAE,WAAW,CAAC,iBAAiB,CAAC;QAIxE,+EAA+E,EAAE,WAAW,CAAC,iBAAiB,CAAC;QAI/G,6FAA6F,EAAE,WAAW,CAAC,iBAAiB,CAAC;KAC9H,CAAC;CACH;AAED,MAAM,MAAM,kBAAkB,GAAG,OAAO,WAAW,GAAG,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
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
|
+
//# sourceMappingURL=TypeScriptInternals.js.map
|
|
@@ -0,0 +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\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"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-04/schema#",
|
|
3
|
+
"description": "Schema that matches anything",
|
|
4
|
+
|
|
5
|
+
"oneOf": [
|
|
6
|
+
{
|
|
7
|
+
"type": "array"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"type": "boolean"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"type": "integer"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"type": "null"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"type": "number"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"type": "object"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"type": "string"
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-04/schema#",
|
|
3
|
+
"title": "TypeScript Build Configuration",
|
|
4
|
+
"description": "Defines optional options for TypeScript build.",
|
|
5
|
+
"type": "object",
|
|
6
|
+
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
|
|
9
|
+
"properties": {
|
|
10
|
+
"$schema": {
|
|
11
|
+
"description": "Part of the JSON Schema standard, this optional keyword declares the URL of the schema that the file conforms to. Editors may download the schema and use it to perform syntax highlighting.",
|
|
12
|
+
"type": "string"
|
|
13
|
+
},
|
|
14
|
+
|
|
15
|
+
"extends": {
|
|
16
|
+
"description": "Optionally specifies another JSON config file that this file extends from. This provides a way for standard settings to be shared across multiple projects.",
|
|
17
|
+
"type": "string"
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
"additionalModuleKindsToEmit": {
|
|
21
|
+
"type": "array",
|
|
22
|
+
"description": "If provided, emit these module kinds in addition to the modules specified in the tsconfig. Note that this option only applies to the main tsconfig.json configuration.",
|
|
23
|
+
"items": {
|
|
24
|
+
"type": "object",
|
|
25
|
+
"properties": {
|
|
26
|
+
"moduleKind": {
|
|
27
|
+
"type": "string",
|
|
28
|
+
"enum": ["commonjs", "amd", "umd", "system", "es2015", "esnext"]
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
"outFolderName": {
|
|
32
|
+
"type": "string",
|
|
33
|
+
"pattern": "[^\\\\\\/]"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"required": ["moduleKind", "outFolderName"]
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
"emitCjsExtensionForCommonJS": {
|
|
41
|
+
"description": "If true, emit CommonJS module output to the folder specified in the tsconfig \"outDir\" compiler option with the .cjs extension alongside (or instead of, if TSConfig specifies CommonJS) the default compilation output.",
|
|
42
|
+
"type": "boolean"
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
"emitMjsExtensionForESModule": {
|
|
46
|
+
"description": "If true, emit ESNext module output to the folder specified in the tsconfig \"outDir\" compiler option with the .mjs extension alongside (or instead of, if TSConfig specifies ESNext) the default compilation output.",
|
|
47
|
+
"type": "boolean"
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
"buildProjectReferences": {
|
|
51
|
+
"description": "If true, enable behavior analogous to the \"tsc --build\" command. Will build projects referenced by the main project. Note that this will effectively enable \"noEmitOnError\".",
|
|
52
|
+
"type": "boolean"
|
|
53
|
+
},
|
|
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
|
+
|
|
60
|
+
"project": {
|
|
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\".",
|
|
62
|
+
"type": "string"
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
"staticAssetsToCopy": {
|
|
66
|
+
"description": "Configures additional file types that should be copied into the TypeScript compiler's emit folders, for example so that these files can be resolved by import statements.",
|
|
67
|
+
"type": "object",
|
|
68
|
+
|
|
69
|
+
"additionalProperties": false,
|
|
70
|
+
|
|
71
|
+
"properties": {
|
|
72
|
+
"fileExtensions": {
|
|
73
|
+
"type": "array",
|
|
74
|
+
"description": "File extensions that should be copied from the source folder to the destination folder(s)",
|
|
75
|
+
"items": {
|
|
76
|
+
"type": "string",
|
|
77
|
+
"pattern": "^\\.[A-z0-9-_.]*[A-z0-9-_]+$"
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
"excludeGlobs": {
|
|
82
|
+
"type": "array",
|
|
83
|
+
"description": "Globs that should be explicitly excluded. This takes precedence over globs listed in \"includeGlobs\" and files that match the file extensions provided in \"fileExtensions\".",
|
|
84
|
+
"items": {
|
|
85
|
+
"type": "string",
|
|
86
|
+
"pattern": "[^\\\\]"
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
"includeGlobs": {
|
|
91
|
+
"type": "array",
|
|
92
|
+
"description": "Globs that should be explicitly included.",
|
|
93
|
+
"items": {
|
|
94
|
+
"type": "string",
|
|
95
|
+
"pattern": "[^\\\\]"
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|