@rushstack/heft-typescript-plugin 1.1.3 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +35 -0
- package/CHANGELOG.md +13 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/TypeScriptPlugin.d.ts.map +1 -1
- package/lib/TypeScriptPlugin.js +18 -1
- package/lib/TypeScriptPlugin.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.json
CHANGED
|
@@ -1,6 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rushstack/heft-typescript-plugin",
|
|
3
3
|
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"version": "1.1.5",
|
|
6
|
+
"tag": "@rushstack/heft-typescript-plugin_v1.1.5",
|
|
7
|
+
"date": "Wed, 12 Nov 2025 01:12:56 GMT",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"comment": "Support \"${configDir}\" token in tsconfig when using file copier."
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"dependency": [
|
|
15
|
+
{
|
|
16
|
+
"comment": "Updating dependency \"@rushstack/heft\" to `1.1.5`"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"comment": "Updating dependency \"@rushstack/heft\" from `1.1.4` to `1.1.5`"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"version": "1.1.4",
|
|
26
|
+
"tag": "@rushstack/heft-typescript-plugin_v1.1.4",
|
|
27
|
+
"date": "Tue, 04 Nov 2025 08:15:14 GMT",
|
|
28
|
+
"comments": {
|
|
29
|
+
"dependency": [
|
|
30
|
+
{
|
|
31
|
+
"comment": "Updating dependency \"@rushstack/heft\" to `1.1.4`"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"comment": "Updating dependency \"@rushstack/heft\" from `1.1.3` to `1.1.4`"
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
},
|
|
4
39
|
{
|
|
5
40
|
"version": "1.1.3",
|
|
6
41
|
"tag": "@rushstack/heft-typescript-plugin_v1.1.3",
|
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
# Change Log - @rushstack/heft-typescript-plugin
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Wed, 12 Nov 2025 01:12:56 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 1.1.5
|
|
6
|
+
Wed, 12 Nov 2025 01:12:56 GMT
|
|
7
|
+
|
|
8
|
+
### Patches
|
|
9
|
+
|
|
10
|
+
- Support "${configDir}" token in tsconfig when using file copier.
|
|
11
|
+
|
|
12
|
+
## 1.1.4
|
|
13
|
+
Tue, 04 Nov 2025 08:15:14 GMT
|
|
14
|
+
|
|
15
|
+
_Version update only_
|
|
4
16
|
|
|
5
17
|
## 1.1.3
|
|
6
18
|
Fri, 24 Oct 2025 00:13:38 GMT
|
package/dist/tsdoc-metadata.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeScriptPlugin.d.ts","sourceRoot":"","sources":["../src/TypeScriptPlugin.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,WAAW,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAGnC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EAMhB,MAAM,iBAAiB,CAAC;AAOzB;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,mBAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"TypeScriptPlugin.d.ts","sourceRoot":"","sources":["../src/TypeScriptPlugin.ts"],"names":[],"mappings":"AAKA,OA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AEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,eAAe,CAAC,EAAE,+BAA+B,CAAC;CACnD;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC;IAC7B,YAAY,CAAC,EAAE,WAAW,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;CACpD;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,kBAAkB,EAAE,QAAQ,CAAC,wBAAwB,CAAC,CAAC;CACjE;AAmBD;;GAEG;AACH,wBAAsB,oCAAoC,CACxD,iBAAiB,EAAE,iBAAiB,EACpC,QAAQ,EAAE,SAAS,GAClB,OAAO,CAAC,4BAA4B,GAAG,SAAS,CAAC,CAKnD;AAKD;;GAEG;AACH,wBAAsB,4BAA4B,CAChD,iBAAiB,EAAE,iBAAiB,EACpC,QAAQ,EAAE,SAAS,EACnB,2BAA2B,EAAE,4BAA4B,GAAG,SAAS,GACpE,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CA8DvC;AAOD,MAAM,CAAC,OAAO,OAAO,gBAAiB,YAAW,eAAe;IACvD,QAAQ,EAAE,yBAAyB,CAExC;IAEK,KAAK,CAAC,WAAW,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,iBAAiB,GAAG,IAAI;YA6CzE,kCAAkC;YA6ClC,0BAA0B;YAkD1B,gBAAgB;CAoB/B"}
|
package/lib/TypeScriptPlugin.js
CHANGED
|
@@ -55,6 +55,11 @@ const tsconfigLoader_1 = require("./tsconfigLoader");
|
|
|
55
55
|
* @public
|
|
56
56
|
*/
|
|
57
57
|
exports.PLUGIN_NAME = 'typescript-plugin';
|
|
58
|
+
/**
|
|
59
|
+
* The ${configDir} token supported in TypeScript 5.5
|
|
60
|
+
* @see {@link https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-5.html#the-configdir-template-variable-for-configuration-files}
|
|
61
|
+
*/
|
|
62
|
+
const CONFIG_DIR_TOKEN = '${configDir}';
|
|
58
63
|
const TYPESCRIPT_LOADER_CONFIG = {
|
|
59
64
|
projectRelativeFilePath: 'config/typescript.json',
|
|
60
65
|
jsonSchemaObject: typescript_schema_json_1.default,
|
|
@@ -108,7 +113,19 @@ async function loadPartialTsconfigFileAsync(heftConfiguration, terminal, typeScr
|
|
|
108
113
|
},
|
|
109
114
|
jsonPathMetadata: {
|
|
110
115
|
'$.compilerOptions.outDir': {
|
|
111
|
-
pathResolutionMethod: heft_config_file_1.PathResolutionMethod.
|
|
116
|
+
pathResolutionMethod: heft_config_file_1.PathResolutionMethod.custom,
|
|
117
|
+
customResolver(resolverOptions) {
|
|
118
|
+
if (resolverOptions.propertyValue.includes(CONFIG_DIR_TOKEN)) {
|
|
119
|
+
// Typescript 5.5. introduced the `${configDir}` token to refer to the directory containing the root tsconfig
|
|
120
|
+
const configDir = path.dirname(tsconfigFilePath);
|
|
121
|
+
// The token is an absolute path, so it should occur at most once.
|
|
122
|
+
return path.resolve(resolverOptions.propertyValue.replace(CONFIG_DIR_TOKEN, configDir));
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
const thisConfigDir = path.dirname(resolverOptions.configurationFilePath);
|
|
126
|
+
return path.resolve(thisConfigDir, resolverOptions.propertyValue);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
112
129
|
}
|
|
113
130
|
}
|
|
114
131
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeScriptPlugin.js","sourceRoot":"","sources":["../src/TypeScriptPlugin.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuJ3D,oFAQC;AAQD,oEAqDC;AA1ND,gDAAkC;AAGlC,qCAAmC;AAEnC,oEAA0D;AAE1D,kEAA8G;AAY9G,2DAA8F;AAC9F,0FAA4D;AAC5D,8FAAsE;AACtE,qDAAuD;AAEvD;;;;GAIG;AACU,QAAA,WA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QAExD,MAAM,2BAA2B,GAC/B,MAAM,oCAAoC,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC;QAE1E,MAAM,mBAAmB,GAAiC,MAAM,4BAA4B,CAC1F,iBAAiB,EACjB,QAAQ,EACR,2BAA2B,CAC5B,CAAC;QAEF,OAAO;YACL,2BAA2B;YAC3B,mBAAmB;SACpB,CAAC;IACJ,CAAC;CACF;AArKD,mCAqKC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as path from 'node:path';\n\nimport type * as TTypescript from 'typescript';\nimport { SyncHook } from 'tapable';\n\nimport { FileSystem } from '@rushstack/node-core-library';\nimport type { ITerminal } from '@rushstack/terminal';\nimport { ProjectConfigurationFile, InheritanceType, PathResolutionMethod } from '@rushstack/heft-config-file';\nimport type {\n HeftConfiguration,\n IHeftTaskSession,\n IHeftTaskPlugin,\n IHeftTaskRunHookOptions,\n IHeftTaskRunIncrementalHookOptions,\n ICopyOperation,\n IHeftTaskFileOperations,\n ConfigurationFile\n} from '@rushstack/heft';\n\nimport { TypeScriptBuilder, type ITypeScriptBuilderConfiguration } from './TypeScriptBuilder';\nimport anythingSchema from './schemas/anything.schema.json';\nimport typescriptConfigSchema from './schemas/typescript.schema.json';\nimport { getTsconfigFilePath } from './tsconfigLoader';\n\n/**\n * The name of the plugin, as specified in heft-plugin.json\n *\n * @public\n */\nexport const PLUGIN_NAME: 'typescript-plugin' = 'typescript-plugin';\n\n/**\n * @beta\n */\nexport interface IEmitModuleKind {\n moduleKind: 'commonjs' | 'amd' | 'umd' | 'system' | 'es2015' | 'esnext';\n outFolderName: string;\n jsExtensionOverride?: string;\n}\n\n/**\n * @beta\n */\nexport interface IStaticAssetsCopyConfiguration {\n fileExtensions: string[];\n excludeGlobs: string[];\n includeGlobs: string[];\n}\n\n/**\n * @beta\n */\nexport interface ITypeScriptConfigurationJson {\n /**\n * If provided, emit these module kinds in addition to the modules specified in the tsconfig.\n * Note that this option only applies to the main tsconfig.json configuration.\n */\n additionalModuleKindsToEmit?: IEmitModuleKind[] | undefined;\n\n /**\n * If 'true', emit CommonJS output into the TSConfig outDir with the file extension '.cjs'\n */\n emitCjsExtensionForCommonJS?: boolean | undefined;\n\n /**\n * If 'true', emit ESModule output into the TSConfig outDir with the file extension '.mjs'\n */\n emitMjsExtensionForESModule?: boolean | undefined;\n\n /**\n * If true, enable behavior analogous to the \"tsc --build\" command. Will build projects referenced by the main project in dependency order.\n * Note that this will effectively enable \\\"noEmitOnError\\\".\n */\n buildProjectReferences?: boolean;\n\n /**\n * If true, and the tsconfig has \\\"isolatedModules\\\": true, then transpilation will happen in parallel in a worker thread.\n */\n useTranspilerWorker?: boolean;\n\n /**\n * If true, the TypeScript compiler will only resolve symlinks to their targets if the links are in a node_modules folder.\n * This significantly reduces file system operations in typical usage.\n */\n onlyResolveSymlinksInNodeModules?: boolean;\n\n /*\n * Specifies the tsconfig.json file that will be used for compilation. Equivalent to the \"project\" argument for the 'tsc' and 'tslint' command line tools.\n *\n * The default value is \"./tsconfig.json\"\n */\n project?: string;\n\n /**\n * Configures additional file types that should be copied into the TypeScript compiler's emit folders, for example\n * so that these files can be resolved by import statements.\n */\n staticAssetsToCopy?: IStaticAssetsCopyConfiguration;\n}\n\n/**\n * @beta\n */\nexport interface IPartialTsconfigCompilerOptions {\n outDir?: string;\n}\n\n/**\n * @beta\n */\nexport interface IPartialTsconfig {\n compilerOptions?: IPartialTsconfigCompilerOptions;\n}\n\n/**\n * @beta\n */\nexport interface IChangedFilesHookOptions {\n program: TTypescript.Program;\n changedFiles?: ReadonlySet<TTypescript.SourceFile>;\n}\n\n/**\n * @beta\n */\nexport interface ITypeScriptPluginAccessor {\n readonly onChangedFilesHook: SyncHook<IChangedFilesHookOptions>;\n}\n\nconst TYPESCRIPT_LOADER_CONFIG: ConfigurationFile.IProjectConfigurationFileSpecification<ITypeScriptConfigurationJson> =\n {\n projectRelativeFilePath: 'config/typescript.json',\n jsonSchemaObject: typescriptConfigSchema,\n propertyInheritance: {\n staticAssetsToCopy: {\n // When merging objects, arrays will be automatically appended\n inheritanceType: InheritanceType.merge\n }\n },\n jsonPathMetadata: {\n '$.additionalModuleKindsToEmit.*.outFolderName': {\n pathResolutionMethod: PathResolutionMethod.resolvePathRelativeToProjectRoot\n }\n }\n };\n\n/**\n * @beta\n */\nexport async function loadTypeScriptConfigurationFileAsync(\n heftConfiguration: HeftConfiguration,\n terminal: ITerminal\n): Promise<ITypeScriptConfigurationJson | undefined> {\n return await heftConfiguration.tryLoadProjectConfigurationFileAsync<ITypeScriptConfigurationJson>(\n TYPESCRIPT_LOADER_CONFIG,\n terminal\n );\n}\n\nlet _partialTsconfigFileLoader: ProjectConfigurationFile<IPartialTsconfig> | undefined;\nconst _partialTsconfigFilePromiseCache: Map<string, Promise<IPartialTsconfig | undefined>> = new Map();\n\n/**\n * @beta\n */\nexport async function loadPartialTsconfigFileAsync(\n heftConfiguration: HeftConfiguration,\n terminal: ITerminal,\n typeScriptConfigurationJson: ITypeScriptConfigurationJson | undefined\n): Promise<IPartialTsconfig | undefined> {\n const buildFolderPath: string = heftConfiguration.buildFolderPath;\n\n // Check the cache first\n let partialTsconfigFilePromise: Promise<IPartialTsconfig | undefined> | undefined =\n _partialTsconfigFilePromiseCache.get(buildFolderPath);\n\n if (!partialTsconfigFilePromise) {\n // We don't want to load the tsconfig.json file through the rig, but we do want to take\n // advantage of the extends functionality that ConfigurationFile provides. So we'll\n // check to see if the file exists and exit early if not.\n\n const tsconfigFilePath: string = getTsconfigFilePath(\n heftConfiguration,\n typeScriptConfigurationJson?.project\n );\n terminal.writeVerboseLine(`Looking for tsconfig at ${tsconfigFilePath}`);\n const tsconfigExists: boolean = await FileSystem.existsAsync(tsconfigFilePath);\n if (!tsconfigExists) {\n partialTsconfigFilePromise = Promise.resolve(undefined);\n } else {\n // Ensure that the file loader has been initialized.\n if (!_partialTsconfigFileLoader) {\n _partialTsconfigFileLoader = new ProjectConfigurationFile<IPartialTsconfig>({\n projectRelativeFilePath: typeScriptConfigurationJson?.project || 'tsconfig.json',\n jsonSchemaObject: anythingSchema,\n propertyInheritance: {\n compilerOptions: {\n inheritanceType: InheritanceType.merge\n }\n },\n jsonPathMetadata: {\n '$.compilerOptions.outDir': {\n pathResolutionMethod: PathResolutionMethod.resolvePathRelativeToConfigurationFile\n }\n }\n });\n }\n\n partialTsconfigFilePromise = _partialTsconfigFileLoader.loadConfigurationFileForProjectAsync(\n terminal,\n buildFolderPath,\n heftConfiguration.rigConfig\n );\n }\n _partialTsconfigFilePromiseCache.set(buildFolderPath, partialTsconfigFilePromise);\n }\n\n return await partialTsconfigFilePromise;\n}\n\ninterface ITypeScriptConfigurationJsonAndPartialTsconfigFile {\n typeScriptConfigurationJson: ITypeScriptConfigurationJson | undefined;\n partialTsconfigFile: IPartialTsconfig | undefined;\n}\n\nexport default class TypeScriptPlugin implements IHeftTaskPlugin {\n public accessor: ITypeScriptPluginAccessor = {\n onChangedFilesHook: new SyncHook<IChangedFilesHookOptions>(['changedFilesHookOptions'])\n };\n\n public apply(taskSession: IHeftTaskSession, heftConfiguration: HeftConfiguration): void {\n taskSession.hooks.registerFileOperations.tapPromise(\n PLUGIN_NAME,\n async (fileOperations: IHeftTaskFileOperations): Promise<IHeftTaskFileOperations> => {\n // TODO: We should consider maybe only doing one copy of static assets and pointing\n // all source files to this set of static assets. This would allow us to avoid\n // having to copy the static assets multiple times, increasing build times and\n // package size.\n for (const copyOperation of await this._getStaticAssetCopyOperationsAsync(\n taskSession,\n heftConfiguration\n )) {\n fileOperations.copyOperations.add(copyOperation);\n }\n\n return fileOperations;\n }\n );\n\n taskSession.hooks.run.tapPromise(PLUGIN_NAME, async (runOptions: IHeftTaskRunHookOptions) => {\n const builder: TypeScriptBuilder | false = await this._getTypeScriptBuilderAsync(\n taskSession,\n heftConfiguration\n );\n if (builder) {\n await builder.invokeAsync();\n }\n });\n\n let incrementalBuilder: TypeScriptBuilder | undefined | false;\n taskSession.hooks.runIncremental.tapPromise(\n PLUGIN_NAME,\n async (runIncrementalOptions: IHeftTaskRunIncrementalHookOptions) => {\n if (incrementalBuilder === undefined) {\n // eslint-disable-next-line require-atomic-updates\n incrementalBuilder = await this._getTypeScriptBuilderAsync(taskSession, heftConfiguration);\n }\n\n if (incrementalBuilder) {\n await incrementalBuilder.invokeAsync(runIncrementalOptions.requestRun);\n }\n }\n );\n }\n\n private async _getStaticAssetCopyOperationsAsync(\n taskSession: IHeftTaskSession,\n heftConfiguration: HeftConfiguration\n ): Promise<ICopyOperation[]> {\n const { typeScriptConfigurationJson, partialTsconfigFile } = await this._loadConfigAsync(\n taskSession,\n heftConfiguration\n );\n\n // We only care about the copy if static assets were specified.\n const copyOperations: ICopyOperation[] = [];\n const staticAssetsConfig: IStaticAssetsCopyConfiguration | undefined =\n typeScriptConfigurationJson?.staticAssetsToCopy;\n if (\n staticAssetsConfig &&\n (staticAssetsConfig.fileExtensions?.length ||\n staticAssetsConfig.includeGlobs?.length ||\n staticAssetsConfig.excludeGlobs?.length)\n ) {\n const destinationFolderPaths: Set<string> = new Set<string>();\n\n // Add the output folder and all additional module kind output folders as destinations\n const tsconfigOutDir: string | undefined = partialTsconfigFile?.compilerOptions?.outDir;\n if (tsconfigOutDir) {\n destinationFolderPaths.add(tsconfigOutDir);\n }\n\n for (const emitModule of typeScriptConfigurationJson?.additionalModuleKindsToEmit || []) {\n destinationFolderPaths.add(emitModule.outFolderName);\n }\n\n copyOperations.push({\n ...staticAssetsConfig,\n\n // For now - these may need to be revised later\n sourcePath: path.resolve(heftConfiguration.buildFolderPath, 'src'),\n destinationFolders: Array.from(destinationFolderPaths),\n flatten: false,\n hardlink: false\n });\n }\n\n return copyOperations;\n }\n\n private async _getTypeScriptBuilderAsync(\n taskSession: IHeftTaskSession,\n heftConfiguration: HeftConfiguration\n ): Promise<TypeScriptBuilder | false> {\n const { typeScriptConfigurationJson, partialTsconfigFile } = await this._loadConfigAsync(\n taskSession,\n heftConfiguration\n );\n\n if (!partialTsconfigFile) {\n // There is no tsconfig file, we can exit early\n // This check may need watch mode to break on tsconfig addition/deletion\n return false;\n }\n\n // Build out the configuration\n const typeScriptBuilderConfiguration: ITypeScriptBuilderConfiguration = {\n buildFolderPath: heftConfiguration.buildFolderPath,\n // Build metadata is just another build output, but we put it in the temp folder because it will\n // usually be discarded when published.\n buildMetadataFolderPath: taskSession.tempFolderPath,\n heftConfiguration,\n\n buildProjectReferences: typeScriptConfigurationJson?.buildProjectReferences,\n\n useTranspilerWorker: typeScriptConfigurationJson?.useTranspilerWorker,\n\n onlyResolveSymlinksInNodeModules: typeScriptConfigurationJson?.onlyResolveSymlinksInNodeModules,\n\n tsconfigPath: getTsconfigFilePath(heftConfiguration, typeScriptConfigurationJson?.project),\n additionalModuleKindsToEmit: typeScriptConfigurationJson?.additionalModuleKindsToEmit,\n emitCjsExtensionForCommonJS: !!typeScriptConfigurationJson?.emitCjsExtensionForCommonJS,\n emitMjsExtensionForESModule: !!typeScriptConfigurationJson?.emitMjsExtensionForESModule,\n scopedLogger: taskSession.logger,\n emitChangedFilesCallback: (\n program: TTypescript.Program,\n changedFiles?: Set<TTypescript.SourceFile>\n ) => {\n // Provide the typescript program dependent plugins\n if (this.accessor.onChangedFilesHook.isUsed()) {\n this.accessor.onChangedFilesHook.call({ program, changedFiles });\n }\n }\n };\n\n // Run the builder\n const typeScriptBuilder: TypeScriptBuilder = new TypeScriptBuilder(typeScriptBuilderConfiguration);\n return typeScriptBuilder;\n }\n\n private async _loadConfigAsync(\n taskSession: IHeftTaskSession,\n heftConfiguration: HeftConfiguration\n ): Promise<ITypeScriptConfigurationJsonAndPartialTsconfigFile> {\n const terminal: ITerminal = taskSession.logger.terminal;\n\n const typeScriptConfigurationJson: ITypeScriptConfigurationJson | undefined =\n await loadTypeScriptConfigurationFileAsync(heftConfiguration, terminal);\n\n const partialTsconfigFile: IPartialTsconfig | undefined = await loadPartialTsconfigFileAsync(\n heftConfiguration,\n terminal,\n typeScriptConfigurationJson\n );\n\n return {\n typeScriptConfigurationJson,\n partialTsconfigFile\n };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TypeScriptPlugin.js","sourceRoot":"","sources":["../src/TypeScriptPlugin.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6J3D,oFAQC;AAQD,oEAkEC;AA7OD,gDAAkC;AAGlC,qCAAmC;AAEnC,oEAA0D;AAE1D,kEAA8G;AAY9G,2DAA8F;AAC9F,0FAA4D;AAC5D,8FAAsE;AACtE,qDAAuD;AAEvD;;;;GAIG;AACU,QAAA,WAAW,GAAwB,mBAAmB,CAAC;AAEpE;;;GAGG;AACH,MAAM,gBAAgB,GAAmB,cAAc,CAAC;AAoGxD,MAAM,wBAAwB,GAC5B;IACE,uBAAuB,EAAE,wBAAwB;IACjD,gBAAgB,EAAE,gCAAsB;IACxC,mBAAmB,EAAE;QACnB,kBAAkB,EAAE;YAClB,8DAA8D;YAC9D,eAAe,EAAE,kCAAe,CAAC,KAAK;SACvC;KACF;IACD,gBAAgB,EAAE;QAChB,+CAA+C,EAAE;YAC/C,oBAAoB,EAAE,uCAAoB,CAAC,gCAAgC;SAC5E;KACF;CACF,CAAC;AAEJ;;GAEG;AACI,KAAK,UAAU,oCAAoC,CACxD,iBAAoC,EACpC,QAAmB;IAEnB,OAAO,MAAM,iBAAiB,CAAC,oCAAoC,CACjE,wBAAwB,EACxB,QAAQ,CACT,CAAC;AACJ,CAAC;AAED,IAAI,0BAAkF,CAAC;AACvF,MAAM,gCAAgC,GAAuD,IAAI,GAAG,EAAE,CAAC;AAEvG;;GAEG;AACI,KAAK,UAAU,4BAA4B,CAChD,iBAAoC,EACpC,QAAmB,EACnB,2BAAqE;IAErE,MAAM,eAAe,GAAW,iBAAiB,CAAC,eAAe,CAAC;IAElE,wBAAwB;IACxB,IAAI,0BAA0B,GAC5B,gCAAgC,CAAC,GAAG,C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AAC;IACJ,CAAC;CACF;AArKD,mCAqKC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as path from 'node:path';\n\nimport type * as TTypescript from 'typescript';\nimport { SyncHook } from 'tapable';\n\nimport { FileSystem } from '@rushstack/node-core-library';\nimport type { ITerminal } from '@rushstack/terminal';\nimport { ProjectConfigurationFile, InheritanceType, PathResolutionMethod } from '@rushstack/heft-config-file';\nimport type {\n HeftConfiguration,\n IHeftTaskSession,\n IHeftTaskPlugin,\n IHeftTaskRunHookOptions,\n IHeftTaskRunIncrementalHookOptions,\n ICopyOperation,\n IHeftTaskFileOperations,\n ConfigurationFile\n} from '@rushstack/heft';\n\nimport { TypeScriptBuilder, type ITypeScriptBuilderConfiguration } from './TypeScriptBuilder';\nimport anythingSchema from './schemas/anything.schema.json';\nimport typescriptConfigSchema from './schemas/typescript.schema.json';\nimport { getTsconfigFilePath } from './tsconfigLoader';\n\n/**\n * The name of the plugin, as specified in heft-plugin.json\n *\n * @public\n */\nexport const PLUGIN_NAME: 'typescript-plugin' = 'typescript-plugin';\n\n/**\n * The ${configDir} token supported in TypeScript 5.5\n * @see {@link https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-5.html#the-configdir-template-variable-for-configuration-files}\n */\nconst CONFIG_DIR_TOKEN: '${configDir}' = '${configDir}';\n\n/**\n * @beta\n */\nexport interface IEmitModuleKind {\n moduleKind: 'commonjs' | 'amd' | 'umd' | 'system' | 'es2015' | 'esnext';\n outFolderName: string;\n jsExtensionOverride?: string;\n}\n\n/**\n * @beta\n */\nexport interface IStaticAssetsCopyConfiguration {\n fileExtensions: string[];\n excludeGlobs: string[];\n includeGlobs: string[];\n}\n\n/**\n * @beta\n */\nexport interface ITypeScriptConfigurationJson {\n /**\n * If provided, emit these module kinds in addition to the modules specified in the tsconfig.\n * Note that this option only applies to the main tsconfig.json configuration.\n */\n additionalModuleKindsToEmit?: IEmitModuleKind[] | undefined;\n\n /**\n * If 'true', emit CommonJS output into the TSConfig outDir with the file extension '.cjs'\n */\n emitCjsExtensionForCommonJS?: boolean | undefined;\n\n /**\n * If 'true', emit ESModule output into the TSConfig outDir with the file extension '.mjs'\n */\n emitMjsExtensionForESModule?: boolean | undefined;\n\n /**\n * If true, enable behavior analogous to the \"tsc --build\" command. Will build projects referenced by the main project in dependency order.\n * Note that this will effectively enable \\\"noEmitOnError\\\".\n */\n buildProjectReferences?: boolean;\n\n /**\n * If true, and the tsconfig has \\\"isolatedModules\\\": true, then transpilation will happen in parallel in a worker thread.\n */\n useTranspilerWorker?: boolean;\n\n /**\n * If true, the TypeScript compiler will only resolve symlinks to their targets if the links are in a node_modules folder.\n * This significantly reduces file system operations in typical usage.\n */\n onlyResolveSymlinksInNodeModules?: boolean;\n\n /*\n * Specifies the tsconfig.json file that will be used for compilation. Equivalent to the \"project\" argument for the 'tsc' and 'tslint' command line tools.\n *\n * The default value is \"./tsconfig.json\"\n */\n project?: string;\n\n /**\n * Configures additional file types that should be copied into the TypeScript compiler's emit folders, for example\n * so that these files can be resolved by import statements.\n */\n staticAssetsToCopy?: IStaticAssetsCopyConfiguration;\n}\n\n/**\n * @beta\n */\nexport interface IPartialTsconfigCompilerOptions {\n outDir?: string;\n}\n\n/**\n * @beta\n */\nexport interface IPartialTsconfig {\n compilerOptions?: IPartialTsconfigCompilerOptions;\n}\n\n/**\n * @beta\n */\nexport interface IChangedFilesHookOptions {\n program: TTypescript.Program;\n changedFiles?: ReadonlySet<TTypescript.SourceFile>;\n}\n\n/**\n * @beta\n */\nexport interface ITypeScriptPluginAccessor {\n readonly onChangedFilesHook: SyncHook<IChangedFilesHookOptions>;\n}\n\nconst TYPESCRIPT_LOADER_CONFIG: ConfigurationFile.IProjectConfigurationFileSpecification<ITypeScriptConfigurationJson> =\n {\n projectRelativeFilePath: 'config/typescript.json',\n jsonSchemaObject: typescriptConfigSchema,\n propertyInheritance: {\n staticAssetsToCopy: {\n // When merging objects, arrays will be automatically appended\n inheritanceType: InheritanceType.merge\n }\n },\n jsonPathMetadata: {\n '$.additionalModuleKindsToEmit.*.outFolderName': {\n pathResolutionMethod: PathResolutionMethod.resolvePathRelativeToProjectRoot\n }\n }\n };\n\n/**\n * @beta\n */\nexport async function loadTypeScriptConfigurationFileAsync(\n heftConfiguration: HeftConfiguration,\n terminal: ITerminal\n): Promise<ITypeScriptConfigurationJson | undefined> {\n return await heftConfiguration.tryLoadProjectConfigurationFileAsync<ITypeScriptConfigurationJson>(\n TYPESCRIPT_LOADER_CONFIG,\n terminal\n );\n}\n\nlet _partialTsconfigFileLoader: ProjectConfigurationFile<IPartialTsconfig> | undefined;\nconst _partialTsconfigFilePromiseCache: Map<string, Promise<IPartialTsconfig | undefined>> = new Map();\n\n/**\n * @beta\n */\nexport async function loadPartialTsconfigFileAsync(\n heftConfiguration: HeftConfiguration,\n terminal: ITerminal,\n typeScriptConfigurationJson: ITypeScriptConfigurationJson | undefined\n): Promise<IPartialTsconfig | undefined> {\n const buildFolderPath: string = heftConfiguration.buildFolderPath;\n\n // Check the cache first\n let partialTsconfigFilePromise: Promise<IPartialTsconfig | undefined> | undefined =\n _partialTsconfigFilePromiseCache.get(buildFolderPath);\n\n if (!partialTsconfigFilePromise) {\n // We don't want to load the tsconfig.json file through the rig, but we do want to take\n // advantage of the extends functionality that ConfigurationFile provides. So we'll\n // check to see if the file exists and exit early if not.\n\n const tsconfigFilePath: string = getTsconfigFilePath(\n heftConfiguration,\n typeScriptConfigurationJson?.project\n );\n terminal.writeVerboseLine(`Looking for tsconfig at ${tsconfigFilePath}`);\n const tsconfigExists: boolean = await FileSystem.existsAsync(tsconfigFilePath);\n if (!tsconfigExists) {\n partialTsconfigFilePromise = Promise.resolve(undefined);\n } else {\n // Ensure that the file loader has been initialized.\n if (!_partialTsconfigFileLoader) {\n _partialTsconfigFileLoader = new ProjectConfigurationFile<IPartialTsconfig>({\n projectRelativeFilePath: typeScriptConfigurationJson?.project || 'tsconfig.json',\n jsonSchemaObject: anythingSchema,\n propertyInheritance: {\n compilerOptions: {\n inheritanceType: InheritanceType.merge\n }\n },\n jsonPathMetadata: {\n '$.compilerOptions.outDir': {\n pathResolutionMethod: PathResolutionMethod.custom,\n customResolver(\n resolverOptions: ConfigurationFile.IJsonPathMetadataResolverOptions<IPartialTsconfig>\n ): string {\n if (resolverOptions.propertyValue.includes(CONFIG_DIR_TOKEN)) {\n // Typescript 5.5. introduced the `${configDir}` token to refer to the directory containing the root tsconfig\n const configDir: string = path.dirname(tsconfigFilePath);\n // The token is an absolute path, so it should occur at most once.\n return path.resolve(resolverOptions.propertyValue.replace(CONFIG_DIR_TOKEN, configDir));\n } else {\n const thisConfigDir: string = path.dirname(resolverOptions.configurationFilePath);\n return path.resolve(thisConfigDir, resolverOptions.propertyValue);\n }\n }\n }\n }\n });\n }\n\n partialTsconfigFilePromise = _partialTsconfigFileLoader.loadConfigurationFileForProjectAsync(\n terminal,\n buildFolderPath,\n heftConfiguration.rigConfig\n );\n }\n _partialTsconfigFilePromiseCache.set(buildFolderPath, partialTsconfigFilePromise);\n }\n\n return await partialTsconfigFilePromise;\n}\n\ninterface ITypeScriptConfigurationJsonAndPartialTsconfigFile {\n typeScriptConfigurationJson: ITypeScriptConfigurationJson | undefined;\n partialTsconfigFile: IPartialTsconfig | undefined;\n}\n\nexport default class TypeScriptPlugin implements IHeftTaskPlugin {\n public accessor: ITypeScriptPluginAccessor = {\n onChangedFilesHook: new SyncHook<IChangedFilesHookOptions>(['changedFilesHookOptions'])\n };\n\n public apply(taskSession: IHeftTaskSession, heftConfiguration: HeftConfiguration): void {\n taskSession.hooks.registerFileOperations.tapPromise(\n PLUGIN_NAME,\n async (fileOperations: IHeftTaskFileOperations): Promise<IHeftTaskFileOperations> => {\n // TODO: We should consider maybe only doing one copy of static assets and pointing\n // all source files to this set of static assets. This would allow us to avoid\n // having to copy the static assets multiple times, increasing build times and\n // package size.\n for (const copyOperation of await this._getStaticAssetCopyOperationsAsync(\n taskSession,\n heftConfiguration\n )) {\n fileOperations.copyOperations.add(copyOperation);\n }\n\n return fileOperations;\n }\n );\n\n taskSession.hooks.run.tapPromise(PLUGIN_NAME, async (runOptions: IHeftTaskRunHookOptions) => {\n const builder: TypeScriptBuilder | false = await this._getTypeScriptBuilderAsync(\n taskSession,\n heftConfiguration\n );\n if (builder) {\n await builder.invokeAsync();\n }\n });\n\n let incrementalBuilder: TypeScriptBuilder | undefined | false;\n taskSession.hooks.runIncremental.tapPromise(\n PLUGIN_NAME,\n async (runIncrementalOptions: IHeftTaskRunIncrementalHookOptions) => {\n if (incrementalBuilder === undefined) {\n // eslint-disable-next-line require-atomic-updates\n incrementalBuilder = await this._getTypeScriptBuilderAsync(taskSession, heftConfiguration);\n }\n\n if (incrementalBuilder) {\n await incrementalBuilder.invokeAsync(runIncrementalOptions.requestRun);\n }\n }\n );\n }\n\n private async _getStaticAssetCopyOperationsAsync(\n taskSession: IHeftTaskSession,\n heftConfiguration: HeftConfiguration\n ): Promise<ICopyOperation[]> {\n const { typeScriptConfigurationJson, partialTsconfigFile } = await this._loadConfigAsync(\n taskSession,\n heftConfiguration\n );\n\n // We only care about the copy if static assets were specified.\n const copyOperations: ICopyOperation[] = [];\n const staticAssetsConfig: IStaticAssetsCopyConfiguration | undefined =\n typeScriptConfigurationJson?.staticAssetsToCopy;\n if (\n staticAssetsConfig &&\n (staticAssetsConfig.fileExtensions?.length ||\n staticAssetsConfig.includeGlobs?.length ||\n staticAssetsConfig.excludeGlobs?.length)\n ) {\n const destinationFolderPaths: Set<string> = new Set<string>();\n\n // Add the output folder and all additional module kind output folders as destinations\n const tsconfigOutDir: string | undefined = partialTsconfigFile?.compilerOptions?.outDir;\n if (tsconfigOutDir) {\n destinationFolderPaths.add(tsconfigOutDir);\n }\n\n for (const emitModule of typeScriptConfigurationJson?.additionalModuleKindsToEmit || []) {\n destinationFolderPaths.add(emitModule.outFolderName);\n }\n\n copyOperations.push({\n ...staticAssetsConfig,\n\n // For now - these may need to be revised later\n sourcePath: path.resolve(heftConfiguration.buildFolderPath, 'src'),\n destinationFolders: Array.from(destinationFolderPaths),\n flatten: false,\n hardlink: false\n });\n }\n\n return copyOperations;\n }\n\n private async _getTypeScriptBuilderAsync(\n taskSession: IHeftTaskSession,\n heftConfiguration: HeftConfiguration\n ): Promise<TypeScriptBuilder | false> {\n const { typeScriptConfigurationJson, partialTsconfigFile } = await this._loadConfigAsync(\n taskSession,\n heftConfiguration\n );\n\n if (!partialTsconfigFile) {\n // There is no tsconfig file, we can exit early\n // This check may need watch mode to break on tsconfig addition/deletion\n return false;\n }\n\n // Build out the configuration\n const typeScriptBuilderConfiguration: ITypeScriptBuilderConfiguration = {\n buildFolderPath: heftConfiguration.buildFolderPath,\n // Build metadata is just another build output, but we put it in the temp folder because it will\n // usually be discarded when published.\n buildMetadataFolderPath: taskSession.tempFolderPath,\n heftConfiguration,\n\n buildProjectReferences: typeScriptConfigurationJson?.buildProjectReferences,\n\n useTranspilerWorker: typeScriptConfigurationJson?.useTranspilerWorker,\n\n onlyResolveSymlinksInNodeModules: typeScriptConfigurationJson?.onlyResolveSymlinksInNodeModules,\n\n tsconfigPath: getTsconfigFilePath(heftConfiguration, typeScriptConfigurationJson?.project),\n additionalModuleKindsToEmit: typeScriptConfigurationJson?.additionalModuleKindsToEmit,\n emitCjsExtensionForCommonJS: !!typeScriptConfigurationJson?.emitCjsExtensionForCommonJS,\n emitMjsExtensionForESModule: !!typeScriptConfigurationJson?.emitMjsExtensionForESModule,\n scopedLogger: taskSession.logger,\n emitChangedFilesCallback: (\n program: TTypescript.Program,\n changedFiles?: Set<TTypescript.SourceFile>\n ) => {\n // Provide the typescript program dependent plugins\n if (this.accessor.onChangedFilesHook.isUsed()) {\n this.accessor.onChangedFilesHook.call({ program, changedFiles });\n }\n }\n };\n\n // Run the builder\n const typeScriptBuilder: TypeScriptBuilder = new TypeScriptBuilder(typeScriptBuilderConfiguration);\n return typeScriptBuilder;\n }\n\n private async _loadConfigAsync(\n taskSession: IHeftTaskSession,\n heftConfiguration: HeftConfiguration\n ): Promise<ITypeScriptConfigurationJsonAndPartialTsconfigFile> {\n const terminal: ITerminal = taskSession.logger.terminal;\n\n const typeScriptConfigurationJson: ITypeScriptConfigurationJson | undefined =\n await loadTypeScriptConfigurationFileAsync(heftConfiguration, terminal);\n\n const partialTsconfigFile: IPartialTsconfig | undefined = await loadPartialTsconfigFileAsync(\n heftConfiguration,\n terminal,\n typeScriptConfigurationJson\n );\n\n return {\n typeScriptConfigurationJson,\n partialTsconfigFile\n };\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rushstack/heft-typescript-plugin",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"description": "Heft plugin for TypeScript",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"types": "dist/heft-typescript-plugin.d.ts",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"@rushstack/heft": "1.1.
|
|
15
|
+
"@rushstack/heft": "1.1.5"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@types/tapable": "1.0.6",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"@types/semver": "7.5.0",
|
|
26
26
|
"eslint": "~9.37.0",
|
|
27
27
|
"typescript": "~5.8.2",
|
|
28
|
+
"@rushstack/heft": "1.1.5",
|
|
28
29
|
"@rushstack/terminal": "0.19.3",
|
|
29
|
-
"@rushstack/heft": "1.1.3",
|
|
30
30
|
"decoupled-local-node-rig": "1.0.0"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|