@rushstack/heft-typescript-plugin 0.1.0-dev.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.
Files changed (36) hide show
  1. package/LICENSE +24 -0
  2. package/README.md +12 -0
  3. package/dist/heft-typescript-plugin.d.ts +111 -0
  4. package/dist/tsdoc-metadata.json +11 -0
  5. package/heft-plugin.json +10 -0
  6. package/lib/EmitFilesPatch.d.ts +28 -0
  7. package/lib/EmitFilesPatch.d.ts.map +1 -0
  8. package/lib/EmitFilesPatch.js +99 -0
  9. package/lib/EmitFilesPatch.js.map +1 -0
  10. package/lib/Performance.d.ts +7 -0
  11. package/lib/Performance.d.ts.map +1 -0
  12. package/lib/Performance.js +5 -0
  13. package/lib/Performance.js.map +1 -0
  14. package/lib/TypeScriptBuilder.d.ts +69 -0
  15. package/lib/TypeScriptBuilder.d.ts.map +1 -0
  16. package/lib/TypeScriptBuilder.js +681 -0
  17. package/lib/TypeScriptBuilder.js.map +1 -0
  18. package/lib/TypeScriptPlugin.d.ts +102 -0
  19. package/lib/TypeScriptPlugin.d.ts.map +1 -0
  20. package/lib/TypeScriptPlugin.js +191 -0
  21. package/lib/TypeScriptPlugin.js.map +1 -0
  22. package/lib/fileSystem/TypeScriptCachedFileSystem.d.ts +36 -0
  23. package/lib/fileSystem/TypeScriptCachedFileSystem.d.ts.map +1 -0
  24. package/lib/fileSystem/TypeScriptCachedFileSystem.js +163 -0
  25. package/lib/fileSystem/TypeScriptCachedFileSystem.js.map +1 -0
  26. package/lib/index.d.ts +8 -0
  27. package/lib/index.d.ts.map +1 -0
  28. package/lib/index.js +10 -0
  29. package/lib/index.js.map +1 -0
  30. package/lib/internalTypings/TypeScriptInternals.d.ts +90 -0
  31. package/lib/internalTypings/TypeScriptInternals.d.ts.map +1 -0
  32. package/lib/internalTypings/TypeScriptInternals.js +5 -0
  33. package/lib/internalTypings/TypeScriptInternals.js.map +1 -0
  34. package/lib/schemas/anything.schema.json +28 -0
  35. package/lib/schemas/typescript.schema.json +101 -0
  36. package/package.json +39 -0
@@ -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":"Typ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EAAE,CAAC;IAChC,CAAC;IAEO,YAAY,CAClB,IAAY,EACZ,EAA6B,EAC7B,KAAwC;QAExC,IAAI,UAAU,GAAqC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACnE,IAAI,CAAC,UAAU,EAAE;YACf,IAAI;gBACF,UAAU,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;aAClC;YAAC,OAAO,CAAC,EAAE;gBACV,UAAU,GAAG,EAAE,KAAK,EAAE,CAAU,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;aACtD;YAED,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;SAC7B;QAED,IAAI,UAAU,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
@@ -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,90 @@
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
+ /**
27
+ * @beta
28
+ */
29
+ export interface IExtendedTypeScript {
30
+ /**
31
+ * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/performance.ts#L3
32
+ */
33
+ performance: {
34
+ /**
35
+ * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/performance.ts#L110-L116
36
+ */
37
+ enable(): void;
38
+ /**
39
+ * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/performance.ts#L55-L61
40
+ */
41
+ mark(performanceMaker: string): void;
42
+ /**
43
+ * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/performance.ts#L72-L78
44
+ */
45
+ measure(measureName: string, startMarkName?: string, endMarkName?: string): void;
46
+ /**
47
+ * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/performance.ts#L94-L96
48
+ */
49
+ getDuration(measureName: string): number;
50
+ /**
51
+ * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/performance.ts#L85-L87
52
+ */
53
+ getCount(measureName: string): number;
54
+ };
55
+ /**
56
+ * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/utilities.ts#L4720-L4734
57
+ */
58
+ readJson(filePath: string): object;
59
+ /**
60
+ * https://github.com/microsoft/TypeScript/blob/782c09d783e006a697b4ba6d1e7ec2f718ce8393/src/compiler/utilities.ts#L6540
61
+ */
62
+ 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) => {
63
+ readonly files: ReadonlyArray<string>;
64
+ readonly directories: ReadonlyArray<string>;
65
+ }, realpath: (path: string) => string, directoryExists: (path: string) => boolean): string[];
66
+ /**
67
+ * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/emitter.ts#L261-L614
68
+ */
69
+ emitFiles(resolver: IEmitResolver, host: IEmitHost, targetSourceFile: TTypescript.SourceFile | undefined, emitTransformers: IEmitTransformers, emitOnlyDtsFiles?: boolean, onlyBuildInfo?: boolean, forceDtsEmit?: boolean): TTypescript.EmitResult;
70
+ /**
71
+ * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/transformer.ts#L30-L35
72
+ */
73
+ getTransformers(compilerOptions: TTypescript.CompilerOptions, customTransformers?: TTypescript.CustomTransformers, emitOnlyDtsFiles?: boolean): IEmitTransformers;
74
+ /**
75
+ * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/utilities.ts#L6100-L6108
76
+ */
77
+ removeFileExtension(path: string): string;
78
+ /**
79
+ * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/utilities.ts#L3826-L3833
80
+ */
81
+ getExternalModuleNameFromPath(host: IResolveModuleNameResolutionHost, fileName: string, referencePath?: string): string;
82
+ Diagnostics: {
83
+ Found_1_error_Watching_for_file_changes: TTypescript.DiagnosticMessage;
84
+ Found_0_errors_Watching_for_file_changes: TTypescript.DiagnosticMessage;
85
+ Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor: TTypescript.DiagnosticMessage;
86
+ Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1: TTypescript.DiagnosticMessage;
87
+ };
88
+ }
89
+ export declare type ExtendedTypeScript = typeof TTypescript & IExtendedTypeScript;
90
+ //# 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;AAG/C;;GAEG;AACH,MAAM,WAAW,aAAa;CAAG;AAEjC;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,WAAW,CAAC,iBAAiB,CAAC;CAC1C;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;CAAG;AAErC;;GAEG;AACH,MAAM,WAAW,gCAAgC;IAC/C,oBAAoB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxC,wBAAwB,IAAI,MAAM,C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EACvB,IAAI,EAAE,SAAS,EACf,gBAAgB,EAAE,WAAW,CAAC,UAAU,GAAG,SAAS,EACpD,gBAAgB,EAAE,iBAAiB,EACnC,gBAAgB,CAAC,EAAE,OAAO,EAC1B,aAAa,CAAC,EAAE,OAAO,EACvB,YAAY,CAAC,EAAE,OAAO,GACrB,WAAW,CAAC,UAAU,CAAC;IAE1B;;OAEG;IACH,eAAe,CACb,eAAe,EAAE,WAAW,CAAC,eAAe,EAC5C,kBAAkB,CAAC,EAAE,WAAW,CAAC,kBAAkB,EACnD,gBAAgB,CAAC,EAAE,OAAO,GACzB,iBAAiB,CAAC;IAErB;;OAEG;IACH,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAE1C;;OAEG;IACH,6BAA6B,CAC3B,IAAI,EAAE,gCAAgC,EACtC,QAAQ,EAAE,MAAM,EAChB,aAAa,CAAC,EAAE,MAAM,GACrB,MAAM,CAAC;IAEV,WAAW,EAAE;QAGX,uCAAuC,EAAE,WAAW,CAAC,iBAAiB,CAAC;QAIvE,wCAAwC,EAAE,WAAW,CAAC,iBAAiB,CAAC;QAIxE,+EAA+E,EAAE,WAAW,CAAC,iBAAiB,CAAC;QAI/G,6FAA6F,EAAE,WAAW,CAAC,iBAAiB,CAAC;KAC9H,CAAC;CACH;AAED,oBAAY,kBAAkB,GAAG,OAAO,WAAW,GAAG,mBAAmB,CAAC"}
@@ -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\n// The specifics of these types aren't important\n/**\n * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/types.ts#L3969-L4010\n */\nexport interface IEmitResolver {}\n\n/**\n * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/types.ts#L5969-L5988\n */\nexport interface IEmitHost {\n writeFile: TTypescript.WriteFileCallback;\n}\n\n/**\n * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/types.ts#L3338-L3341\n */\nexport interface IEmitTransformers {}\n\n/**\n * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/utilities.ts#L3799-L3803\n */\nexport interface IResolveModuleNameResolutionHost {\n getCanonicalFileName(p: string): string;\n getCommonSourceDirectory(): string;\n getCurrentDirectory(): string;\n}\n\n/**\n * @beta\n */\nexport interface IExtendedTypeScript {\n /**\n * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/performance.ts#L3\n */\n performance: {\n /**\n * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/performance.ts#L110-L116\n */\n enable(): void;\n\n /**\n * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/performance.ts#L55-L61\n */\n mark(performanceMaker: string): void;\n\n /**\n * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/performance.ts#L72-L78\n */\n measure(measureName: string, startMarkName?: string, endMarkName?: string): void;\n\n /**\n * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/performance.ts#L94-L96\n */\n getDuration(measureName: string): number;\n\n /**\n * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/performance.ts#L85-L87\n */\n getCount(measureName: string): number;\n };\n\n /**\n * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/utilities.ts#L4720-L4734\n */\n readJson(filePath: string): object;\n\n /**\n * https://github.com/microsoft/TypeScript/blob/782c09d783e006a697b4ba6d1e7ec2f718ce8393/src/compiler/utilities.ts#L6540\n */\n matchFiles(\n path: string,\n extensions: ReadonlyArray<string> | undefined,\n excludes: ReadonlyArray<string> | undefined,\n includes: ReadonlyArray<string> | undefined,\n useCaseSensitiveFileNames: boolean,\n currentDirectory: string,\n depth: number | undefined,\n getFileSystemEntries: (path: string) => {\n readonly files: ReadonlyArray<string>;\n readonly directories: ReadonlyArray<string>;\n },\n realpath: (path: string) => string,\n directoryExists: (path: string) => boolean\n ): string[];\n\n /**\n * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/emitter.ts#L261-L614\n */\n emitFiles(\n resolver: IEmitResolver,\n host: IEmitHost,\n targetSourceFile: TTypescript.SourceFile | undefined,\n emitTransformers: IEmitTransformers,\n emitOnlyDtsFiles?: boolean,\n onlyBuildInfo?: boolean,\n forceDtsEmit?: boolean\n ): TTypescript.EmitResult;\n\n /**\n * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/transformer.ts#L30-L35\n */\n getTransformers(\n compilerOptions: TTypescript.CompilerOptions,\n customTransformers?: TTypescript.CustomTransformers,\n emitOnlyDtsFiles?: boolean\n ): IEmitTransformers;\n\n /**\n * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/utilities.ts#L6100-L6108\n */\n removeFileExtension(path: string): string;\n\n /**\n * https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/utilities.ts#L3826-L3833\n */\n getExternalModuleNameFromPath(\n host: IResolveModuleNameResolutionHost,\n fileName: string,\n referencePath?: string\n ): string;\n\n Diagnostics: {\n // https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/diagnosticMessages.json#L4252-L4255\n // eslint-disable-next-line @typescript-eslint/naming-convention\n Found_1_error_Watching_for_file_changes: TTypescript.DiagnosticMessage;\n\n // https://github.com/microsoft/TypeScript/blob/5f597e69b2e3b48d788cb548df40bcb703c8adb1/src/compiler/diagnosticMessages.json#L4256-L4259\n // eslint-disable-next-line @typescript-eslint/naming-convention\n Found_0_errors_Watching_for_file_changes: TTypescript.DiagnosticMessage;\n\n // https://github.com/microsoft/TypeScript/blob/2428ade1a91248e847f3e1561e31a9426650efee/src/compiler/diagnosticMessages.json#L2252\n // eslint-disable-next-line @typescript-eslint/naming-convention\n Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor: TTypescript.DiagnosticMessage;\n\n // https://github.com/microsoft/TypeScript/blob/2428ade1a91248e847f3e1561e31a9426650efee/src/compiler/diagnosticMessages.json#L4920\n // eslint-disable-next-line @typescript-eslint/naming-convention\n Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1: TTypescript.DiagnosticMessage;\n };\n}\n\nexport type ExtendedTypeScript = typeof TTypescript & IExtendedTypeScript;\n"]}
@@ -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
+ "project": {
56
+ "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
+ "type": "string"
58
+ },
59
+
60
+ "maxWriteParallelism": {
61
+ "description": "Set this to change the maximum write parallelism. The default is 50.",
62
+ "type": "number"
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
+ }
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@rushstack/heft-typescript-plugin",
3
+ "version": "0.1.0-dev.0",
4
+ "description": "Heft plugin for TypeScript",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/microsoft/rushstack.git",
8
+ "directory": "heft-plugins/heft-typescript-plugin"
9
+ },
10
+ "homepage": "https://rushstack.io/pages/heft/overview/",
11
+ "main": "lib/index.js",
12
+ "types": "dist/heft-typescript-plugin.d.ts",
13
+ "license": "MIT",
14
+ "peerDependencies": {
15
+ "@rushstack/heft": "^0.48.0-dev.0"
16
+ },
17
+ "dependencies": {
18
+ "@rushstack/node-core-library": "3.52.0",
19
+ "@rushstack/heft-config-file": "0.10.0",
20
+ "@types/tapable": "1.0.6",
21
+ "semver": "~7.3.0",
22
+ "tapable": "1.1.3"
23
+ },
24
+ "devDependencies": {
25
+ "@rushstack/eslint-config": "3.0.1",
26
+ "@rushstack/heft": "0.48.0-dev.0",
27
+ "@rushstack/heft-legacy": "npm:@rushstack/heft@0.47.0",
28
+ "@rushstack/heft-node-rig": "1.10.0",
29
+ "@types/node": "12.20.24",
30
+ "@types/semver": "7.3.5",
31
+ "typescript": "~4.7.4"
32
+ },
33
+ "scripts": {
34
+ "build": "node ./node_modules/@rushstack/heft-legacy/bin/heft --unmanaged build --clean",
35
+ "start": "node ./node_modules/@rushstack/heft-legacy/bin/heft --unmanaged test --clean --watch",
36
+ "_phase:build": "node ./node_modules/@rushstack/heft-legacy/bin/heft --unmanaged build --clean",
37
+ "_phase:test": "node ./node_modules/@rushstack/heft-legacy/bin/heft --unmanaged test --no-build"
38
+ }
39
+ }