@rushstack/heft-typescript-plugin 0.6.1 → 0.6.3
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 +36 -0
- package/CHANGELOG.md +11 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/TypeScriptPlugin.js +2 -2
- package/lib/TypeScriptPlugin.js.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.json
CHANGED
|
@@ -1,6 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rushstack/heft-typescript-plugin",
|
|
3
3
|
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"version": "0.6.3",
|
|
6
|
+
"tag": "@rushstack/heft-typescript-plugin_v0.6.3",
|
|
7
|
+
"date": "Mon, 09 Dec 2024 20:31:43 GMT",
|
|
8
|
+
"comments": {
|
|
9
|
+
"dependency": [
|
|
10
|
+
{
|
|
11
|
+
"comment": "Updating dependency \"@rushstack/heft-config-file\" to `0.16.1`"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"comment": "Updating dependency \"@rushstack/heft\" to `0.68.10`"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"comment": "Updating dependency \"@rushstack/heft\" from `0.68.9` to `0.68.10`"
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"version": "0.6.2",
|
|
24
|
+
"tag": "@rushstack/heft-typescript-plugin_v0.6.2",
|
|
25
|
+
"date": "Tue, 03 Dec 2024 16:11:07 GMT",
|
|
26
|
+
"comments": {
|
|
27
|
+
"dependency": [
|
|
28
|
+
{
|
|
29
|
+
"comment": "Updating dependency \"@rushstack/heft-config-file\" to `0.16.0`"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"comment": "Updating dependency \"@rushstack/heft\" to `0.68.9`"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"comment": "Updating dependency \"@rushstack/heft\" from `0.68.8` to `0.68.9`"
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
},
|
|
4
40
|
{
|
|
5
41
|
"version": "0.6.1",
|
|
6
42
|
"tag": "@rushstack/heft-typescript-plugin_v0.6.1",
|
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
# Change Log - @rushstack/heft-typescript-plugin
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Mon, 09 Dec 2024 20:31:43 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 0.6.3
|
|
6
|
+
Mon, 09 Dec 2024 20:31:43 GMT
|
|
7
|
+
|
|
8
|
+
_Version update only_
|
|
9
|
+
|
|
10
|
+
## 0.6.2
|
|
11
|
+
Tue, 03 Dec 2024 16:11:07 GMT
|
|
12
|
+
|
|
13
|
+
_Version update only_
|
|
4
14
|
|
|
5
15
|
## 0.6.1
|
|
6
16
|
Sat, 23 Nov 2024 01:18:55 GMT
|
package/dist/tsdoc-metadata.json
CHANGED
package/lib/TypeScriptPlugin.js
CHANGED
|
@@ -54,7 +54,7 @@ async function loadTypeScriptConfigurationFileAsync(heftConfiguration, terminal)
|
|
|
54
54
|
if (!typescriptConfigurationFilePromise) {
|
|
55
55
|
// Ensure that the file loader has been initialized.
|
|
56
56
|
if (!_typeScriptConfigurationFileLoader) {
|
|
57
|
-
_typeScriptConfigurationFileLoader = new heft_config_file_1.
|
|
57
|
+
_typeScriptConfigurationFileLoader = new heft_config_file_1.ProjectConfigurationFile({
|
|
58
58
|
projectRelativeFilePath: 'config/typescript.json',
|
|
59
59
|
jsonSchemaObject: typescript_schema_json_1.default,
|
|
60
60
|
propertyInheritance: {
|
|
@@ -99,7 +99,7 @@ async function loadPartialTsconfigFileAsync(heftConfiguration, terminal, typeScr
|
|
|
99
99
|
else {
|
|
100
100
|
// Ensure that the file loader has been initialized.
|
|
101
101
|
if (!_partialTsconfigFileLoader) {
|
|
102
|
-
_partialTsconfigFileLoader = new heft_config_file_1.
|
|
102
|
+
_partialTsconfigFileLoader = new heft_config_file_1.ProjectConfigurationFile({
|
|
103
103
|
projectRelativeFilePath: (typeScriptConfigurationJson === null || typeScriptConfigurationJson === void 0 ? void 0 : typeScriptConfigurationJson.project) || 'tsconfig.json',
|
|
104
104
|
jsonSchemaObject: anything_schema_json_1.default,
|
|
105
105
|
propertyInheritance: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeScriptPlugin.js","sourceRoot":"","sources":["../src/TypeScriptPlugin.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,2CAA6B;AAG7B,qCAAmC;AACnC,oEAAgE;AAEhE,kEAAuG;AAWvG,2DAA8F;AAC9F,0FAA4D;AAC5D,8FAAsE;AAEtE;;;;GAIG;AACU,QAAA,WAAW,GAAwB,mBAAmB,CAAC;AAoGpE,IAAI,kCAA+F,CAAC;AACpG,MAAM,wCAAwC,GAG1C,IAAI,GAAG,EAAE,CAAC;AAEd;;GAEG;AACI,KAAK,UAAU,oCAAoC,CACxD,iBAAoC,EACpC,QAAmB;IAEnB,MAAM,eAAe,GAAW,iBAAiB,CAAC,eAAe,CAAC;IAElE,wBAAwB;IACxB,IAAI,kCAAkC,GACpC,wCAAwC,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAEhE,IAAI,CAAC,kCAAkC,EAAE,CAAC;QACxC,oDAAoD;QACpD,IAAI,CAAC,kCAAkC,EAAE,CAAC;YACxC,kCAAkC,GAAG,IAAI,oCAAiB,CAA+B;gBACvF,uBAAuB,EAAE,wBAAwB;gBACjD,gBAAgB,EAAE,gCAAsB;gBACxC,mBAAmB,EAAE;oBACnB,kBAAkB,EAAE;wBAClB,8DAA8D;wBAC9D,eAAe,EAAE,kCAAe,CAAC,KAAK;qBACvC;iBACF;aACF,CAAC,CAAC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AC,CAAC;gBACnE,CAAC;YACH,CAAC;SACF,CAAC;QAEF,kBAAkB;QAClB,MAAM,iBAAiB,GAAsB,IAAI,qCAAiB,CAAC,8BAA8B,CAAC,CAAC;QACnG,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAEO,KAAK,CAAC,uBAAuB,CACnC,WAA6B,EAC7B,iBAAoC,EACpC,uBAAiE;;QAEjE,MAAM,mBAAmB,GAAiC,MAAM,4BAA4B,CAC1F,iBAAiB,EACjB,WAAW,CAAC,MAAM,CAAC,QAAQ,EAC3B,uBAAuB,CACxB,CAAC;QACF,OAAO,MAAA,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAE,eAAe,0CAAE,MAAM,CAAC;IACtD,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 'path';\n\nimport type * as TTypescript from 'typescript';\nimport { SyncHook } from 'tapable';\nimport { FileSystem, Path } from '@rushstack/node-core-library';\nimport type { ITerminal } from '@rushstack/terminal';\nimport { ConfigurationFile, InheritanceType, PathResolutionMethod } from '@rushstack/heft-config-file';\nimport type {\n HeftConfiguration,\n IHeftTaskSession,\n IHeftTaskPlugin,\n IHeftTaskRunHookOptions,\n IHeftTaskRunIncrementalHookOptions,\n ICopyOperation,\n IHeftTaskFileOperations\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';\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\nlet _typeScriptConfigurationFileLoader: ConfigurationFile<ITypeScriptConfigurationJson> | undefined;\nconst _typeScriptConfigurationFilePromiseCache: Map<\n string,\n Promise<ITypeScriptConfigurationJson | undefined>\n> = new Map();\n\n/**\n * @beta\n */\nexport async function loadTypeScriptConfigurationFileAsync(\n heftConfiguration: HeftConfiguration,\n terminal: ITerminal\n): Promise<ITypeScriptConfigurationJson | undefined> {\n const buildFolderPath: string = heftConfiguration.buildFolderPath;\n\n // Check the cache first\n let typescriptConfigurationFilePromise: Promise<ITypeScriptConfigurationJson | undefined> | undefined =\n _typeScriptConfigurationFilePromiseCache.get(buildFolderPath);\n\n if (!typescriptConfigurationFilePromise) {\n // Ensure that the file loader has been initialized.\n if (!_typeScriptConfigurationFileLoader) {\n _typeScriptConfigurationFileLoader = new ConfigurationFile<ITypeScriptConfigurationJson>({\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 });\n }\n\n typescriptConfigurationFilePromise =\n _typeScriptConfigurationFileLoader.tryLoadConfigurationFileForProjectAsync(\n terminal,\n buildFolderPath,\n heftConfiguration.rigConfig\n );\n _typeScriptConfigurationFilePromiseCache.set(buildFolderPath, typescriptConfigurationFilePromise);\n }\n\n return await typescriptConfigurationFilePromise;\n}\n\nlet _partialTsconfigFileLoader: ConfigurationFile<IPartialTsconfig> | undefined;\nconst _partialTsconfigFilePromiseCache: Map<string, Promise<IPartialTsconfig | undefined>> = new Map();\n\nfunction getTsconfigFilePath(\n heftConfiguration: HeftConfiguration,\n typeScriptConfigurationJson?: ITypeScriptConfigurationJson\n): string {\n return Path.convertToSlashes(\n // Use path.resolve because the path can start with `./` or `../`\n path.resolve(heftConfiguration.buildFolderPath, typeScriptConfigurationJson?.project || './tsconfig.json')\n );\n}\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(heftConfiguration, typeScriptConfigurationJson);\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 ConfigurationFile<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\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 typeScriptConfiguration: ITypeScriptConfigurationJson | undefined =\n await loadTypeScriptConfigurationFileAsync(heftConfiguration, taskSession.logger.terminal);\n\n // We only care about the copy if static assets were specified.\n const copyOperations: ICopyOperation[] = [];\n if (\n typeScriptConfiguration?.staticAssetsToCopy?.fileExtensions?.length ||\n typeScriptConfiguration?.staticAssetsToCopy?.includeGlobs?.length ||\n typeScriptConfiguration?.staticAssetsToCopy?.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 = await this._getTsconfigOutDirAsync(\n taskSession,\n heftConfiguration,\n typeScriptConfiguration\n );\n if (tsconfigOutDir) {\n destinationFolderPaths.add(tsconfigOutDir);\n }\n for (const emitModule of typeScriptConfiguration?.additionalModuleKindsToEmit || []) {\n destinationFolderPaths.add(`${heftConfiguration.buildFolderPath}/${emitModule.outFolderName}`);\n }\n\n copyOperations.push({\n ...typeScriptConfiguration?.staticAssetsToCopy,\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 return copyOperations;\n }\n\n private async _getTypeScriptBuilderAsync(\n taskSession: IHeftTaskSession,\n heftConfiguration: HeftConfiguration\n ): Promise<TypeScriptBuilder | false> {\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 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 const typeScriptToolPath: string = await heftConfiguration.rigPackageResolver.resolvePackageAsync(\n 'typescript',\n terminal\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 typeScriptToolPath: typeScriptToolPath,\n\n buildProjectReferences: typeScriptConfigurationJson?.buildProjectReferences,\n\n useTranspilerWorker: typeScriptConfigurationJson?.useTranspilerWorker,\n\n onlyResolveSymlinksInNodeModules: typeScriptConfigurationJson?.onlyResolveSymlinksInNodeModules,\n\n tsconfigPath: getTsconfigFilePath(heftConfiguration, typeScriptConfigurationJson),\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 _getTsconfigOutDirAsync(\n taskSession: IHeftTaskSession,\n heftConfiguration: HeftConfiguration,\n typeScriptConfiguration: ITypeScriptConfigurationJson | undefined\n ): Promise<string | undefined> {\n const partialTsconfigFile: IPartialTsconfig | undefined = await loadPartialTsconfigFileAsync(\n heftConfiguration,\n taskSession.logger.terminal,\n typeScriptConfiguration\n );\n return partialTsconfigFile?.compilerOptions?.outDir;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TypeScriptPlugin.js","sourceRoot":"","sources":["../src/TypeScriptPlugin.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,2CAA6B;AAG7B,qCAAmC;AACnC,oEAAgE;AAEhE,kEAA8G;AAW9G,2DAA8F;AAC9F,0FAA4D;AAC5D,8FAAsE;AAEtE;;;;GAIG;AACU,QAAA,WAAW,GAAwB,mBAAmB,CAAC;AAoGpE,IAAI,kCAAsG,CAAC;AAC3G,MAAM,wCAAwC,GAG1C,IAAI,GAAG,EAAE,CAAC;AAEd;;GAEG;AACI,KAAK,UAAU,oCAAoC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,2BAA2B;YACrF,2BAA2B,EAAE,CAAC,CAAC,CAAA,2BAA2B,aAA3B,2BAA2B,uBAA3B,2BAA2B,CAAE,2BAA2B,CAAA;YACvF,2BAA2B,EAAE,CAAC,CAAC,CAAA,2BAA2B,aAA3B,2BAA2B,uBAA3B,2BAA2B,CAAE,2BAA2B,CAAA;YACvF,YAAY,EAAE,WAAW,CAAC,MAAM;YAChC,wBAAwB,EAAE,CACxB,OAA4B,EAC5B,YAA0C,EAC1C,EAAE;gBACF,mDAAmD;gBACnD,IAAI,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,MAAM,EAAE,EAAE,CAAC;oBAC9C,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC,CAAC;gBACnE,CAAC;YACH,CAAC;SACF,CAAC;QAEF,kBAAkB;QAClB,MAAM,iBAAiB,GAAsB,IAAI,qCAAiB,CAAC,8BAA8B,CAAC,CAAC;QACnG,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAEO,KAAK,CAAC,uBAAuB,CACnC,WAA6B,EAC7B,iBAAoC,EACpC,uBAAiE;;QAEjE,MAAM,mBAAmB,GAAiC,MAAM,4BAA4B,CAC1F,iBAAiB,EACjB,WAAW,CAAC,MAAM,CAAC,QAAQ,EAC3B,uBAAuB,CACxB,CAAC;QACF,OAAO,MAAA,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAE,eAAe,0CAAE,MAAM,CAAC;IACtD,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 'path';\n\nimport type * as TTypescript from 'typescript';\nimport { SyncHook } from 'tapable';\nimport { FileSystem, Path } 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} from '@rushstack/heft';\n\nimport { TypeScriptBuilder, type ITypeScriptBuilderConfiguration } from './TypeScriptBuilder';\nimport anythingSchema from './schemas/anything.schema.json';\nimport typescriptConfigSchema from './schemas/typescript.schema.json';\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\nlet _typeScriptConfigurationFileLoader: ProjectConfigurationFile<ITypeScriptConfigurationJson> | undefined;\nconst _typeScriptConfigurationFilePromiseCache: Map<\n string,\n Promise<ITypeScriptConfigurationJson | undefined>\n> = new Map();\n\n/**\n * @beta\n */\nexport async function loadTypeScriptConfigurationFileAsync(\n heftConfiguration: HeftConfiguration,\n terminal: ITerminal\n): Promise<ITypeScriptConfigurationJson | undefined> {\n const buildFolderPath: string = heftConfiguration.buildFolderPath;\n\n // Check the cache first\n let typescriptConfigurationFilePromise: Promise<ITypeScriptConfigurationJson | undefined> | undefined =\n _typeScriptConfigurationFilePromiseCache.get(buildFolderPath);\n\n if (!typescriptConfigurationFilePromise) {\n // Ensure that the file loader has been initialized.\n if (!_typeScriptConfigurationFileLoader) {\n _typeScriptConfigurationFileLoader = new ProjectConfigurationFile<ITypeScriptConfigurationJson>({\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 });\n }\n\n typescriptConfigurationFilePromise =\n _typeScriptConfigurationFileLoader.tryLoadConfigurationFileForProjectAsync(\n terminal,\n buildFolderPath,\n heftConfiguration.rigConfig\n );\n _typeScriptConfigurationFilePromiseCache.set(buildFolderPath, typescriptConfigurationFilePromise);\n }\n\n return await typescriptConfigurationFilePromise;\n}\n\nlet _partialTsconfigFileLoader: ProjectConfigurationFile<IPartialTsconfig> | undefined;\nconst _partialTsconfigFilePromiseCache: Map<string, Promise<IPartialTsconfig | undefined>> = new Map();\n\nfunction getTsconfigFilePath(\n heftConfiguration: HeftConfiguration,\n typeScriptConfigurationJson?: ITypeScriptConfigurationJson\n): string {\n return Path.convertToSlashes(\n // Use path.resolve because the path can start with `./` or `../`\n path.resolve(heftConfiguration.buildFolderPath, typeScriptConfigurationJson?.project || './tsconfig.json')\n );\n}\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(heftConfiguration, typeScriptConfigurationJson);\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\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 typeScriptConfiguration: ITypeScriptConfigurationJson | undefined =\n await loadTypeScriptConfigurationFileAsync(heftConfiguration, taskSession.logger.terminal);\n\n // We only care about the copy if static assets were specified.\n const copyOperations: ICopyOperation[] = [];\n if (\n typeScriptConfiguration?.staticAssetsToCopy?.fileExtensions?.length ||\n typeScriptConfiguration?.staticAssetsToCopy?.includeGlobs?.length ||\n typeScriptConfiguration?.staticAssetsToCopy?.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 = await this._getTsconfigOutDirAsync(\n taskSession,\n heftConfiguration,\n typeScriptConfiguration\n );\n if (tsconfigOutDir) {\n destinationFolderPaths.add(tsconfigOutDir);\n }\n for (const emitModule of typeScriptConfiguration?.additionalModuleKindsToEmit || []) {\n destinationFolderPaths.add(`${heftConfiguration.buildFolderPath}/${emitModule.outFolderName}`);\n }\n\n copyOperations.push({\n ...typeScriptConfiguration?.staticAssetsToCopy,\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 return copyOperations;\n }\n\n private async _getTypeScriptBuilderAsync(\n taskSession: IHeftTaskSession,\n heftConfiguration: HeftConfiguration\n ): Promise<TypeScriptBuilder | false> {\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 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 const typeScriptToolPath: string = await heftConfiguration.rigPackageResolver.resolvePackageAsync(\n 'typescript',\n terminal\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 typeScriptToolPath: typeScriptToolPath,\n\n buildProjectReferences: typeScriptConfigurationJson?.buildProjectReferences,\n\n useTranspilerWorker: typeScriptConfigurationJson?.useTranspilerWorker,\n\n onlyResolveSymlinksInNodeModules: typeScriptConfigurationJson?.onlyResolveSymlinksInNodeModules,\n\n tsconfigPath: getTsconfigFilePath(heftConfiguration, typeScriptConfigurationJson),\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 _getTsconfigOutDirAsync(\n taskSession: IHeftTaskSession,\n heftConfiguration: HeftConfiguration,\n typeScriptConfiguration: ITypeScriptConfigurationJson | undefined\n ): Promise<string | undefined> {\n const partialTsconfigFile: IPartialTsconfig | undefined = await loadPartialTsconfigFileAsync(\n heftConfiguration,\n taskSession.logger.terminal,\n typeScriptConfiguration\n );\n return partialTsconfigFile?.compilerOptions?.outDir;\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rushstack/heft-typescript-plugin",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"description": "Heft plugin for TypeScript",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -12,23 +12,23 @@
|
|
|
12
12
|
"types": "dist/heft-typescript-plugin.d.ts",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"@rushstack/heft": "0.68.
|
|
15
|
+
"@rushstack/heft": "0.68.10"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@types/tapable": "1.0.6",
|
|
19
19
|
"semver": "~7.5.4",
|
|
20
20
|
"tapable": "1.1.3",
|
|
21
21
|
"@rushstack/node-core-library": "5.10.0",
|
|
22
|
-
"@rushstack/heft-config-file": "0.
|
|
22
|
+
"@rushstack/heft-config-file": "0.16.1"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@rushstack/heft-node-rig": "2.6.
|
|
25
|
+
"@rushstack/heft-node-rig": "2.6.43",
|
|
26
26
|
"@types/node": "18.17.15",
|
|
27
27
|
"@types/semver": "7.5.0",
|
|
28
28
|
"typescript": "~5.4.2",
|
|
29
29
|
"local-eslint-config": "1.0.0",
|
|
30
30
|
"@rushstack/terminal": "0.14.3",
|
|
31
|
-
"@rushstack/heft": "0.68.
|
|
31
|
+
"@rushstack/heft": "0.68.10"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
34
|
"build": "heft test --clean",
|