@rushstack/heft-typescript-plugin 0.2.2 → 0.2.4
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/lib/TranspilerWorker.js +1 -1
- package/lib/TranspilerWorker.js.map +1 -1
- package/lib/TypeScriptPlugin.js.map +1 -1
- package/lib/configureProgramForMultiEmit.d.ts.map +1 -1
- package/lib/configureProgramForMultiEmit.js +2 -0
- package/lib/configureProgramForMultiEmit.js.map +1 -1
- package/lib/fileSystem/TypeScriptCachedFileSystem.d.ts +1 -1
- package/lib/fileSystem/TypeScriptCachedFileSystem.d.ts.map +1 -1
- package/lib/fileSystem/TypeScriptCachedFileSystem.js +3 -3
- package/lib/fileSystem/TypeScriptCachedFileSystem.js.map +1 -1
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js +2 -0
- package/lib/types.js.map +1 -1
- package/package.json +6 -6
package/lib/TranspilerWorker.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
2
|
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
4
3
|
// See LICENSE in the project root for license information.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
const node_worker_threads_1 = require("node:worker_threads");
|
|
6
6
|
const configureProgramForMultiEmit_1 = require("./configureProgramForMultiEmit");
|
|
7
7
|
const typedWorkerData = node_worker_threads_1.workerData;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TranspilerWorker.js","sourceRoot":"","sources":["../src/TranspilerWorker.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TranspilerWorker.js","sourceRoot":"","sources":["../src/TranspilerWorker.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;AAE3D,6DAA6D;AAU7D,iFAA8E;AAE9E,MAAM,eAAe,GAA0B,gCAAU,CAAC;A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AAE,CAAC,QAAgB,EAAE,EAAE,CAAC,gBAAgB,CAAC,GAAG,CAAC,QAAQ,CAAC;QAChE,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE;QAClB,eAAe,EAAE,GAAG,EAAE,CAAC,IAAI;QAC3B,cAAc,EAAE,GAAG,EAAE,CAAC,EAAE;KACzB,CAAC;IAEF,MAAM,OAAO,GAAwB,EAAE,CAAC,aAAa,CAAC,aAAa,EAAE,eAAe,EAAE,YAAY,CAAC,CAAC;IAEpG,IAAA,2DAA4B,EAAC,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAE,WAAW,CAAC,CAAC;IAE1E,MAAM,MAAM,GAA2B,OAAO,CAAC,IAAI,CACjD,SAAS;IACT,wEAAwE;IACxE,EAAE,CAAC,GAAG,CAAC,SAAS,EAChB,SAAS,EACT,SAAS,EACT,SAAS,CACV,CAAC;IAEF,MAAM,QAAQ,GAAiC;QAC7C,SAAS;QACT,IAAI,EAAE,SAAS;QACf,MAAM;KACP,CAAC;IAEF,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,gCAAW,CAAC,EAAE,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC","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 { parentPort, workerData } from 'node:worker_threads';\n\nimport type * as TTypescript from 'typescript';\nimport type {\n ITranspilationErrorMessage,\n ITranspilationRequestMessage,\n ITranspilationSuccessMessage,\n ITypescriptWorkerData\n} from './types';\nimport type { ExtendedTypeScript } from './internalTypings/TypeScriptInternals';\nimport { configureProgramForMultiEmit } from './configureProgramForMultiEmit';\n\nconst typedWorkerData: ITypescriptWorkerData = workerData;\n\nconst ts: ExtendedTypeScript = require(typedWorkerData.typeScriptToolPath);\n\nfunction handleMessage(message: ITranspilationRequestMessage | false): void {\n if (!message) {\n process.exit(0);\n }\n\n try {\n const response: ITranspilationSuccessMessage = runTranspiler(message);\n parentPort!.postMessage(response);\n } catch (err) {\n const errorResponse: ITranspilationErrorMessage = {\n requestId: message.requestId,\n type: 'error',\n result: {\n message: err.message,\n ...Object.fromEntries(Object.entries(err))\n }\n };\n parentPort!.postMessage(errorResponse);\n }\n}\n\nfunction runTranspiler(message: ITranspilationRequestMessage): ITranspilationSuccessMessage {\n const { requestId, compilerOptions, moduleKindsToEmit, filesToTranspile } = message;\n\n const fullySkipTypeCheck: boolean =\n /* TypeScript 5+ */ compilerOptions.verbatimModuleSyntax ||\n /* TypeScript 4 */ compilerOptions.importsNotUsedAsValues === ts.ImportsNotUsedAsValues.Error;\n\n for (const [option, value] of Object.entries(ts.getDefaultCompilerOptions())) {\n if (compilerOptions[option] === undefined) {\n compilerOptions[option] = value;\n }\n }\n\n const { target: rawTarget } = compilerOptions;\n\n for (const option of ts.transpileOptionValueCompilerOptions) {\n compilerOptions[option.name] = option.transpileOptionValue;\n }\n\n compilerOptions.suppressOutputPathCheck = true;\n compilerOptions.skipDefaultLibCheck = true;\n // To fully disable the type checker, we have to set `hasNoDefaultLib: true` on every source file.\n // However, doing so loses the information about which imports are used.\n // To retain the imports, we use `preserveValueImports`. However, if some imports are only used for types,\n // this will produce invalid runtime output unless said imports are marked with `type `.\n // Thus we can only enable this optimization if `verbatimModuleSyntax` is enabled (or equivalent).\n compilerOptions.preserveValueImports = fullySkipTypeCheck;\n\n const sourceFileByPath: Map<string, TTypescript.SourceFile> = new Map();\n\n const includedFiles: string[] = [];\n for (const [fileName, sourceText] of filesToTranspile) {\n if (sourceText) {\n const sourceFile: TTypescript.SourceFile = ts.createSourceFile(fileName, sourceText, rawTarget!);\n sourceFile.hasNoDefaultLib = fullySkipTypeCheck;\n sourceFileByPath.set(fileName, sourceFile);\n includedFiles.push(fileName);\n }\n }\n\n const newLine: string = ts.getNewLineCharacter(compilerOptions);\n\n const compilerHost: TTypescript.CompilerHost = {\n getSourceFile: (fileName: string) => sourceFileByPath.get(fileName),\n writeFile: ts.sys.writeFile,\n getDefaultLibFileName: () => 'lib.d.ts',\n useCaseSensitiveFileNames: () => true,\n getCanonicalFileName: (fileName: string) => fileName,\n getCurrentDirectory: () => '',\n getNewLine: () => newLine,\n fileExists: (fileName: string) => sourceFileByPath.has(fileName),\n readFile: () => '',\n directoryExists: () => true,\n getDirectories: () => []\n };\n\n const program: TTypescript.Program = ts.createProgram(includedFiles, compilerOptions, compilerHost);\n\n configureProgramForMultiEmit(program, ts, moduleKindsToEmit, 'transpile');\n\n const result: TTypescript.EmitResult = program.emit(\n undefined,\n // The writeFile callback must be provided for the multi-emit redirector\n ts.sys.writeFile,\n undefined,\n undefined,\n undefined\n );\n\n const response: ITranspilationSuccessMessage = {\n requestId,\n type: 'success',\n result\n };\n\n return response;\n}\n\nparentPort!.on('message', handleMessage);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeScriptPlugin.js","sourceRoot":"","sources":["../src/TypeScriptPlugin.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,2CAA6B;AAG7B,qCAAmC;AACnC,oEAAgF;AAChF,kEAAuG;AAWvG,2DAAyF;AACzF,0FAA4D;AAC5D,8FAAsE;AAEtE;;;;GAIG;AACU,QAAA,WAAW,GAAwB,mBAAmB,CAAC;AA8FpE,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;QACvC,oDAAoD;QACpD,IAAI,CAAC,kCAAkC,EAAE;YACvC,kCAAkC,GAAG,IAAI,oCAAiB,CAA+B;gBACvF,uBAAu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,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;AAnKD,mCAmKC","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, type ITerminal } from '@rushstack/node-core-library';\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, 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 * 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._getStaticAssetCopyOperations(\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 _getStaticAssetCopyOperations(\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 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,oEAAgF;AAChF,kEAAuG;AAWvG,2DAA8F;AAC9F,0FAA4D;AAC5D,8FAAsE;AAEtE;;;;GAIG;AACU,QAAA,WAAW,GAAwB,mBAAmB,CAAC;AA8FpE,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;QACvC,oDAAoD;QACpD,IAAI,CAAC,kCAAkC,EAAE;YACvC,kCAAkC,GAAG,IAAI,oCAAiB,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,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;AAnKD,mCAmKC","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, type ITerminal } from '@rushstack/node-core-library';\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 * 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._getStaticAssetCopyOperations(\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 _getStaticAssetCopyOperations(\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 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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configureProgramForMultiEmit.d.ts","sourceRoot":"","sources":["../src/configureProgramForMultiEmit.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"configureProgramForMultiEmit.d.ts","sourceRoot":"","sources":["../src/configureProgramForMultiEmit.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,WAAW,MAAM,YAAY,CAAC;AAG/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAmCrD,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,WAAW,CAAC,OAAO,EACjC,EAAE,EAAE,kBAAkB,EACtB,iBAAiB,EAAE,qBAAqB,EAAE,EAC1C,IAAI,EAAE,WAAW,GAAG,aAAa,GAAG,MAAM,GACzC;IAAE,YAAY,EAAE,GAAG,CAAC,WAAW,CAAC,UAAU,CAAC,CAAA;CAAE,CAuI/C"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
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.
|
|
2
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
5
|
exports.configureProgramForMultiEmit = void 0;
|
|
4
6
|
const node_core_library_1 = require("@rushstack/node-core-library");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configureProgramForMultiEmit.js","sourceRoot":"","sources":["../src/configureProgramForMultiEmit.ts"],"names":[],"mappings":";;;AAGA,oEAA6D;AAK7D,iEAAiE;AACjE,MAAM,iCAAiC,GAAkB,MAAM,CAAC,oBAAoB,CAAC,CAAC;AACtF,MAAM,iBAAiB,GAAkB,MAAM,CAAC,MAAM,CAAC,CAAC;AAExD,MAAM,kBAAkB,GAAW,eAAe,CAAC;AAEnD,SAAS,aAAa,CAEpB,aAA4C,EAC5C,mBAAuC;IAEvC,IAAI,CAAC,mBAAmB,EAAE;QACxB,OAAO,aAAa,CAAC;KACtB;IAED,MAAM,oBAAoB,GAAW,GAAG,mBAAmB,IAAI,CAAC;IAChE,OAAO,CACL,QAAgB,EAChB,IAAY,EACZ,QAAiB,EACjB,OAAiD,EACjD,WAA2D,EAC3D,EAAE;QACF,OAAO,aAAa,CAClB,QAAQ,CAAC,OAAO,CAAC,kBAAkB,EAAE,oBAAoB,CAAC,EAC1D,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,WAAW,CACZ,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED,SAAgB,4BAA4B,CAE1C,YAAiC,EACjC,EAAsB,EACtB,iBAA0C,EAC1C,IAA0C;IAS1C,MAAM,OAAO,GAA0B,YAAY,CAAC;IAEpD,0DAA0D;IAC1D,IAAI,EAAE,CAAC,iBAAiB,CAAC,EAAE,SAAS,EAAE,CAAC,iCAAiC,CAAC,EAAE,uBAAuB,EAAE,GAClG,OAAO,CAAC;IAEV,IAAI,CAAC,uBAAuB,EAAE;Q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AU,CAAC,CAAC;iBAC9B;gBAED,IAAI,gBAAgB,CAAC,UAAU,KAAK,iBAAiB,EAAE;oBACrD,uBAAuB,GAAG,YAAY,CAAC;iBACxC;aACF;YAED,MAAM,iBAAiB,GACrB,EAAE,CAAC,6BAA6B,CAAC,WAAW,CAAC,CAAC;YAEhD,uCACK,uBAAwB,KAC3B,kBAAkB,EAAE,YAAY,EAChC,WAAW,EAAE,iBAAiB,EAC9B,WAAW,IACX;SACH;gBAAS;YACR,yEAAyE;YACzE,OAAO,CAAC,kBAAkB,GAAG,OAAO,CAAC,iCAAiC,CAAE,CAAC;YACzE,uBAAuB,CAAC,MAAM,GAAG,iBAAiB,CAAC;SACpD;IACH,CAAC,CAAC;IACF,OAAO,EAAE,YAAY,EAAE,CAAC;AAC1B,CAAC;AA7ID,oEA6IC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\nimport type * as TTypescript from 'typescript';\nimport { InternalError } from '@rushstack/node-core-library';\n\nimport type { ExtendedTypeScript } from './internalTypings/TypeScriptInternals';\nimport type { ICachedEmitModuleKind } from './types';\n\n// symbols for attaching hidden metadata to ts.Program instances.\nconst INNER_GET_COMPILER_OPTIONS_SYMBOL: unique symbol = Symbol('getCompilerOptions');\nconst INNER_EMIT_SYMBOL: unique symbol = Symbol('emit');\n\nconst JS_EXTENSION_REGEX: RegExp = /\\.js(\\.map)?$/;\n\nfunction wrapWriteFile(\n this: void,\n baseWriteFile: TTypescript.WriteFileCallback,\n jsExtensionOverride: string | undefined\n): TTypescript.WriteFileCallback {\n if (!jsExtensionOverride) {\n return baseWriteFile;\n }\n\n const replacementExtension: string = `${jsExtensionOverride}$1`;\n return (\n fileName: string,\n data: string,\n writeBOM: boolean,\n onError?: ((message: string) => void) | undefined,\n sourceFiles?: readonly TTypescript.SourceFile[] | undefined\n ) => {\n return baseWriteFile(\n fileName.replace(JS_EXTENSION_REGEX, replacementExtension),\n data,\n writeBOM,\n onError,\n sourceFiles\n );\n };\n}\n\nexport function configureProgramForMultiEmit(\n this: void,\n innerProgram: TTypescript.Program,\n ts: ExtendedTypeScript,\n moduleKindsToEmit: ICachedEmitModuleKind[],\n mode: 'transpile' | 'declaration' | 'both'\n): { changedFiles: Set<TTypescript.SourceFile> } {\n interface IProgramWithMultiEmit extends TTypescript.Program {\n // Attach the originals to the Program instance to avoid modifying the same Program twice.\n // Don't use WeakMap because this Program could theoretically get a { ... } applied to it.\n [INNER_GET_COMPILER_OPTIONS_SYMBOL]?: TTypescript.Program['getCompilerOptions'];\n [INNER_EMIT_SYMBOL]?: TTypescript.Program['emit'];\n }\n\n const program: IProgramWithMultiEmit = innerProgram;\n\n // Check to see if this Program has already been modified.\n let { [INNER_EMIT_SYMBOL]: innerEmit, [INNER_GET_COMPILER_OPTIONS_SYMBOL]: innerGetCompilerOptions } =\n program;\n\n if (!innerGetCompilerOptions) {\n program[INNER_GET_COMPILER_OPTIONS_SYMBOL] = innerGetCompilerOptions = program.getCompilerOptions;\n }\n\n if (!innerEmit) {\n program[INNER_EMIT_SYMBOL] = innerEmit = program.emit;\n }\n\n let foundPrimary: boolean = false;\n let defaultModuleKind: TTypescript.ModuleKind;\n\n const multiEmitMap: Map<ICachedEmitModuleKind, TTypescript.CompilerOptions> = new Map();\n for (const moduleKindToEmit of moduleKindsToEmit) {\n const kindCompilerOptions: TTypescript.CompilerOptions = moduleKindToEmit.isPrimary\n ? {\n ...innerGetCompilerOptions()\n }\n : {\n ...innerGetCompilerOptions(),\n module: moduleKindToEmit.moduleKind,\n outDir: moduleKindToEmit.outFolderPath,\n\n // Don't emit declarations for secondary module kinds\n declaration: false,\n declarationMap: false\n };\n if (!kindCompilerOptions.outDir) {\n throw new InternalError('Expected compilerOptions.outDir to be assigned');\n }\n if (mode === 'transpile') {\n kindCompilerOptions.declaration = false;\n kindCompilerOptions.declarationMap = false;\n } else if (mode === 'declaration') {\n kindCompilerOptions.emitDeclarationOnly = true;\n }\n\n if (moduleKindToEmit.isPrimary || mode !== 'declaration') {\n multiEmitMap.set(moduleKindToEmit, kindCompilerOptions);\n }\n\n if (moduleKindToEmit.isPrimary) {\n if (foundPrimary) {\n throw new Error('Multiple primary module emit kinds encountered.');\n } else {\n foundPrimary = true;\n }\n\n defaultModuleKind = moduleKindToEmit.moduleKind;\n }\n }\n\n const changedFiles: Set<TTypescript.SourceFile> = new Set();\n\n program.emit = (\n targetSourceFile?: TTypescript.SourceFile,\n writeFile?: TTypescript.WriteFileCallback,\n cancellationToken?: TTypescript.CancellationToken,\n emitOnlyDtsFiles?: boolean,\n customTransformers?: TTypescript.CustomTransformers\n ) => {\n if (emitOnlyDtsFiles) {\n return program[INNER_EMIT_SYMBOL]!(\n targetSourceFile,\n writeFile,\n cancellationToken,\n emitOnlyDtsFiles,\n customTransformers\n );\n }\n\n if (targetSourceFile && changedFiles) {\n changedFiles.add(targetSourceFile);\n }\n\n const originalCompilerOptions: TTypescript.CompilerOptions =\n program[INNER_GET_COMPILER_OPTIONS_SYMBOL]!();\n\n let defaultModuleKindResult: TTypescript.EmitResult;\n const diagnostics: TTypescript.Diagnostic[] = [];\n let emitSkipped: boolean = false;\n try {\n for (const [moduleKindToEmit, kindCompilerOptions] of multiEmitMap) {\n program.getCompilerOptions = () => kindCompilerOptions;\n // Need to mutate the compiler options for the `module` field specifically, because emitWorker() captures\n // options in the closure and passes it to `ts.getTransformers()`\n originalCompilerOptions.module = moduleKindToEmit.moduleKind;\n const flavorResult: TTypescript.EmitResult = program[INNER_EMIT_SYMBOL]!(\n targetSourceFile,\n writeFile && wrapWriteFile(writeFile, moduleKindToEmit.jsExtensionOverride),\n cancellationToken,\n emitOnlyDtsFiles,\n customTransformers\n );\n\n emitSkipped = emitSkipped || flavorResult.emitSkipped;\n // Need to aggregate diagnostics because some are impacted by the target module type\n for (const diagnostic of flavorResult.diagnostics) {\n diagnostics.push(diagnostic);\n }\n\n if (moduleKindToEmit.moduleKind === defaultModuleKind) {\n defaultModuleKindResult = flavorResult;\n }\n }\n\n const mergedDiagnostics: readonly TTypescript.Diagnostic[] =\n ts.sortAndDeduplicateDiagnostics(diagnostics);\n\n return {\n ...defaultModuleKindResult!,\n changedSourceFiles: changedFiles,\n diagnostics: mergedDiagnostics,\n emitSkipped\n };\n } finally {\n // Restore the original compiler options and module kind for future calls\n program.getCompilerOptions = program[INNER_GET_COMPILER_OPTIONS_SYMBOL]!;\n originalCompilerOptions.module = defaultModuleKind;\n }\n };\n return { changedFiles };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"configureProgramForMultiEmit.js","sourceRoot":"","sources":["../src/configureProgramForMultiEmit.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,oEAA6D;AAK7D,iEAAiE;AACjE,MAAM,iCAAiC,GAAkB,MAAM,CAAC,oBAAoB,CAAC,CAAC;AACtF,MAAM,iBAAiB,GAAkB,MAAM,CAAC,MAAM,CAAC,CAAC;AAExD,MAAM,kBAAkB,GAAW,eAAe,CAAC;AAEnD,SAAS,aAAa,CAEpB,aAA4C,EAC5C,mBAAuC;IAEvC,IAAI,CAAC,mBAAmB,EAAE;QACxB,OAAO,aAAa,CAAC;KACtB;IAED,MAAM,oBAAoB,GAAW,GAAG,mBAAmB,IAAI,CAAC;IAChE,OAAO,CACL,QAAgB,EAChB,IAAY,EACZ,QAAiB,EACjB,OAAiD,EACjD,WAA2D,EAC3D,EAAE;QACF,OAAO,aAAa,CAClB,QAAQ,CAAC,OAAO,CAAC,kBAAkB,EAAE,oBAAoB,CAAC,EAC1D,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,WAAW,CACZ,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED,SAAgB,4BAA4B,CAE1C,YAAiC,EACjC,EAAsB,EACtB,iBAA0C,EAC1C,IAA0C;IAS1C,MAAM,OAAO,GAA0B,YAAY,CAAC;IAEpD,0DAA0D;IAC1D,IAAI,EAAE,CAAC,iBAAiB,CAAC,EAAE,SAAS,E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oFAAoF;gBACpF,KAAK,MAAM,UAAU,IAAI,YAAY,CAAC,WAAW,EAAE;oBACjD,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;iBAC9B;gBAED,IAAI,gBAAgB,CAAC,UAAU,KAAK,iBAAiB,EAAE;oBACrD,uBAAuB,GAAG,YAAY,CAAC;iBACxC;aACF;YAED,MAAM,iBAAiB,GACrB,EAAE,CAAC,6BAA6B,CAAC,WAAW,CAAC,CAAC;YAEhD,uCACK,uBAAwB,KAC3B,kBAAkB,EAAE,YAAY,EAChC,WAAW,EAAE,iBAAiB,EAC9B,WAAW,IACX;SACH;gBAAS;YACR,yEAAyE;YACzE,OAAO,CAAC,kBAAkB,GAAG,OAAO,CAAC,iCAAiC,CAAE,CAAC;YACzE,uBAAuB,CAAC,MAAM,GAAG,iBAAiB,CAAC;SACpD;IACH,CAAC,CAAC;IACF,OAAO,EAAE,YAAY,EAAE,CAAC;AAC1B,CAAC;AA7ID,oEA6IC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type * as TTypescript from 'typescript';\nimport { InternalError } from '@rushstack/node-core-library';\n\nimport type { ExtendedTypeScript } from './internalTypings/TypeScriptInternals';\nimport type { ICachedEmitModuleKind } from './types';\n\n// symbols for attaching hidden metadata to ts.Program instances.\nconst INNER_GET_COMPILER_OPTIONS_SYMBOL: unique symbol = Symbol('getCompilerOptions');\nconst INNER_EMIT_SYMBOL: unique symbol = Symbol('emit');\n\nconst JS_EXTENSION_REGEX: RegExp = /\\.js(\\.map)?$/;\n\nfunction wrapWriteFile(\n this: void,\n baseWriteFile: TTypescript.WriteFileCallback,\n jsExtensionOverride: string | undefined\n): TTypescript.WriteFileCallback {\n if (!jsExtensionOverride) {\n return baseWriteFile;\n }\n\n const replacementExtension: string = `${jsExtensionOverride}$1`;\n return (\n fileName: string,\n data: string,\n writeBOM: boolean,\n onError?: ((message: string) => void) | undefined,\n sourceFiles?: readonly TTypescript.SourceFile[] | undefined\n ) => {\n return baseWriteFile(\n fileName.replace(JS_EXTENSION_REGEX, replacementExtension),\n data,\n writeBOM,\n onError,\n sourceFiles\n );\n };\n}\n\nexport function configureProgramForMultiEmit(\n this: void,\n innerProgram: TTypescript.Program,\n ts: ExtendedTypeScript,\n moduleKindsToEmit: ICachedEmitModuleKind[],\n mode: 'transpile' | 'declaration' | 'both'\n): { changedFiles: Set<TTypescript.SourceFile> } {\n interface IProgramWithMultiEmit extends TTypescript.Program {\n // Attach the originals to the Program instance to avoid modifying the same Program twice.\n // Don't use WeakMap because this Program could theoretically get a { ... } applied to it.\n [INNER_GET_COMPILER_OPTIONS_SYMBOL]?: TTypescript.Program['getCompilerOptions'];\n [INNER_EMIT_SYMBOL]?: TTypescript.Program['emit'];\n }\n\n const program: IProgramWithMultiEmit = innerProgram;\n\n // Check to see if this Program has already been modified.\n let { [INNER_EMIT_SYMBOL]: innerEmit, [INNER_GET_COMPILER_OPTIONS_SYMBOL]: innerGetCompilerOptions } =\n program;\n\n if (!innerGetCompilerOptions) {\n program[INNER_GET_COMPILER_OPTIONS_SYMBOL] = innerGetCompilerOptions = program.getCompilerOptions;\n }\n\n if (!innerEmit) {\n program[INNER_EMIT_SYMBOL] = innerEmit = program.emit;\n }\n\n let foundPrimary: boolean = false;\n let defaultModuleKind: TTypescript.ModuleKind;\n\n const multiEmitMap: Map<ICachedEmitModuleKind, TTypescript.CompilerOptions> = new Map();\n for (const moduleKindToEmit of moduleKindsToEmit) {\n const kindCompilerOptions: TTypescript.CompilerOptions = moduleKindToEmit.isPrimary\n ? {\n ...innerGetCompilerOptions()\n }\n : {\n ...innerGetCompilerOptions(),\n module: moduleKindToEmit.moduleKind,\n outDir: moduleKindToEmit.outFolderPath,\n\n // Don't emit declarations for secondary module kinds\n declaration: false,\n declarationMap: false\n };\n if (!kindCompilerOptions.outDir) {\n throw new InternalError('Expected compilerOptions.outDir to be assigned');\n }\n if (mode === 'transpile') {\n kindCompilerOptions.declaration = false;\n kindCompilerOptions.declarationMap = false;\n } else if (mode === 'declaration') {\n kindCompilerOptions.emitDeclarationOnly = true;\n }\n\n if (moduleKindToEmit.isPrimary || mode !== 'declaration') {\n multiEmitMap.set(moduleKindToEmit, kindCompilerOptions);\n }\n\n if (moduleKindToEmit.isPrimary) {\n if (foundPrimary) {\n throw new Error('Multiple primary module emit kinds encountered.');\n } else {\n foundPrimary = true;\n }\n\n defaultModuleKind = moduleKindToEmit.moduleKind;\n }\n }\n\n const changedFiles: Set<TTypescript.SourceFile> = new Set();\n\n program.emit = (\n targetSourceFile?: TTypescript.SourceFile,\n writeFile?: TTypescript.WriteFileCallback,\n cancellationToken?: TTypescript.CancellationToken,\n emitOnlyDtsFiles?: boolean,\n customTransformers?: TTypescript.CustomTransformers\n ) => {\n if (emitOnlyDtsFiles) {\n return program[INNER_EMIT_SYMBOL]!(\n targetSourceFile,\n writeFile,\n cancellationToken,\n emitOnlyDtsFiles,\n customTransformers\n );\n }\n\n if (targetSourceFile && changedFiles) {\n changedFiles.add(targetSourceFile);\n }\n\n const originalCompilerOptions: TTypescript.CompilerOptions =\n program[INNER_GET_COMPILER_OPTIONS_SYMBOL]!();\n\n let defaultModuleKindResult: TTypescript.EmitResult;\n const diagnostics: TTypescript.Diagnostic[] = [];\n let emitSkipped: boolean = false;\n try {\n for (const [moduleKindToEmit, kindCompilerOptions] of multiEmitMap) {\n program.getCompilerOptions = () => kindCompilerOptions;\n // Need to mutate the compiler options for the `module` field specifically, because emitWorker() captures\n // options in the closure and passes it to `ts.getTransformers()`\n originalCompilerOptions.module = moduleKindToEmit.moduleKind;\n const flavorResult: TTypescript.EmitResult = program[INNER_EMIT_SYMBOL]!(\n targetSourceFile,\n writeFile && wrapWriteFile(writeFile, moduleKindToEmit.jsExtensionOverride),\n cancellationToken,\n emitOnlyDtsFiles,\n customTransformers\n );\n\n emitSkipped = emitSkipped || flavorResult.emitSkipped;\n // Need to aggregate diagnostics because some are impacted by the target module type\n for (const diagnostic of flavorResult.diagnostics) {\n diagnostics.push(diagnostic);\n }\n\n if (moduleKindToEmit.moduleKind === defaultModuleKind) {\n defaultModuleKindResult = flavorResult;\n }\n }\n\n const mergedDiagnostics: readonly TTypescript.Diagnostic[] =\n ts.sortAndDeduplicateDiagnostics(diagnostics);\n\n return {\n ...defaultModuleKindResult!,\n changedSourceFiles: changedFiles,\n diagnostics: mergedDiagnostics,\n emitSkipped\n };\n } finally {\n // Restore the original compiler options and module kind for future calls\n program.getCompilerOptions = program[INNER_GET_COMPILER_OPTIONS_SYMBOL]!;\n originalCompilerOptions.module = defaultModuleKind;\n }\n };\n return { changedFiles };\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { IFileSystemWriteFileOptions, IFileSystemReadFileOptions, IFileSystemCopyFileOptions, IFileSystemDeleteFileOptions, IFileSystemCreateLinkOptions, FileSystemStats } from '@rushstack/node-core-library';
|
|
2
|
+
import { type IFileSystemWriteFileOptions, type IFileSystemReadFileOptions, type IFileSystemCopyFileOptions, type IFileSystemDeleteFileOptions, type IFileSystemCreateLinkOptions, type FileSystemStats } from '@rushstack/node-core-library';
|
|
3
3
|
export interface IReadFolderFilesAndDirectoriesResult {
|
|
4
4
|
files: string[];
|
|
5
5
|
directories: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeScriptCachedFileSystem.d.ts","sourceRoot":"","sources":["../../src/fileSystem/TypeScriptCachedFileSystem.ts"],"names":[],"mappings":";AAGA,OAAO,EAGL,2BAA2B,
|
|
1
|
+
{"version":3,"file":"TypeScriptCachedFileSystem.d.ts","sourceRoot":"","sources":["../../src/fileSystem/TypeScriptCachedFileSystem.ts"],"names":[],"mappings":";AAGA,OAAO,EAGL,KAAK,2BAA2B,EAChC,KAAK,0BAA0B,EAC/B,KAAK,0BAA0B,EAC/B,KAAK,4BAA4B,EACjC,KAAK,4BAA4B,EAEjC,KAAK,eAAe,EAGr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CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAiB9C;IAEK,6BAA6B,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,oCAAoC,CAWhG;IAEF,OAAO,CAAC,kBAAkB;IAkB1B,OAAO,CAAC,YAAY;IAuBpB,OAAO,CAAC,qBAAqB;CAM9B"}
|
|
@@ -96,14 +96,14 @@ class TypeScriptCachedFileSystem {
|
|
|
96
96
|
this._invalidateCacheEntry(options.newLinkPath);
|
|
97
97
|
};
|
|
98
98
|
this.getRealPath = (linkPath) => {
|
|
99
|
-
return this._withCaching(linkPath, (
|
|
99
|
+
return this._withCaching(linkPath, (path) => {
|
|
100
100
|
try {
|
|
101
|
-
return node_core_library_1.FileSystem.getRealPath(
|
|
101
|
+
return node_core_library_1.FileSystem.getRealPath(path);
|
|
102
102
|
}
|
|
103
103
|
catch (e) {
|
|
104
104
|
if (node_core_library_1.FileSystem.isNotExistError(e)) {
|
|
105
105
|
// TypeScript's ts.sys.realpath returns the path it's provided if that path doesn't exist
|
|
106
|
-
return
|
|
106
|
+
return path;
|
|
107
107
|
}
|
|
108
108
|
else {
|
|
109
109
|
throw e;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeScriptCachedFileSystem.js","sourceRoot":"","sources":["../../src/fileSystem/TypeScriptCachedFileSystem.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,oEAYsC;AAYtC;;;;;;GAMG;AACH,MAAa,0BAA0B;IAAvC;QACU,gBAAW,GAA8C,IAAI,GAAG,EAAE,CAAC;QACnE,qBAAgB,GAAmE,IAAI,GAAG,EAAE,CAAC;QAC7F,mBAAc,GAAqC,IAAI,GAAG,EAAE,CAAC;QAC7D,mBAAc,GAAqC,IAAI,GAAG,EAAE,CAAC;QAE9D,WAAM,GAA8B,CAAC,IAAY,EAAE,EAAE;YAC1D,IAAI;gBACF,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;gBACzB,OAAO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pB,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"]}
|
|
1
|
+
{"version":3,"file":"TypeScriptCachedFileSystem.js","sourceRoot":"","sources":["../../src/fileSystem/TypeScriptCachedFileSystem.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,oEAYsC;AAYtC;;;;;;GAMG;AACH,MAAa,0BAA0B;IAAvC;QACU,gBAAW,GAA8C,IAAI,GAAG,EAAE,CAAC;QACnE,qBAAgB,GAAmE,IAAI,GAAG,EAAE,CAAC;QAC7F,mBAAc,GAAqC,IAAI,GAAG,EAAE,CAAC;QAC7D,mBAAc,GAAqC,IAAI,GAAG,EAAE,CAAC;QAE9D,WAAM,GAA8B,CAAC,IAAY,EAAE,EAAE;YAC1D,IAAI;gBACF,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;gBACzB,OAAO,IAAI,CAAC;aACb;YAAC,OAAO,CAAC,EAAE;gBACV,IAAI,8BAAU,CAAC,eAAe,CAAC,CAAU,CAAC,EAAE;oBAC1C,OAAO,KAAK,CAAC;iBACd;qBAAM;oBACL,MAAM,CAAC,CAAC;iBACT;aACF;QACH,CAAC,CAAC;QAEK,oBAAe,GAA8B,CAAC,IAAY,EAAE,EAAE;YACnE,IAAI;gBACF,MAAM,KAAK,GAAoB,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;gBACxD,OAAO,KAAK,CAAC,WAAW,EAAE,CAAC;aAC5B;YAAC,OAAO,CAAC,EAAE;gBACV,IAAI,8BAAU,CAAC,eAAe,CAAC,CAAU,CAAC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licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport {\n Encoding,\n Text,\n type IFileSystemWriteFileOptions,\n type IFileSystemReadFileOptions,\n type IFileSystemCopyFileOptions,\n type IFileSystemDeleteFileOptions,\n type IFileSystemCreateLinkOptions,\n FileSystem,\n type FileSystemStats,\n Sort,\n type 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 (path: string) => {\n try {\n return FileSystem.getRealPath(path);\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 path;\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/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,WAAW,MAAM,YAAY,CAAC;AAE/C,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,4BAA4B;IAC3C;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,eAAe,EAAE,WAAW,CAAC,eAAe,CAAC;IAC7C;;OAEG;IACH,iBAAiB,EAAE,qBAAqB,EAAE,CAAC;IAC3C;;OAEG;IACH,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvC;AAED,MAAM,WAAW,4BAA4B;IAC3C,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,EAAE,WAAW,CAAC,UAAU,CAAC;CAChC;AAED,MAAM,WAAW,0BAA0B;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE;QACN,OAAO,EAAE,MAAM,CAAC;QAChB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;CACH;AAED,MAAM,MAAM,6BAA6B,GAAG,4BAA4B,GAAG,0BAA0B,CAAC;AAEtG,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,WAAW,CAAC,UAAU,CAAC;IAEnC,aAAa,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,mBAAmB,EAAE,MAAM,GAAG,SAAS,CAAC;IAExC;;;OAGG;IACH,SAAS,EAAE,OAAO,CAAC;CACpB"}
|
package/lib/types.js
CHANGED
package/lib/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\nimport type * as TTypescript from 'typescript';\n\nexport interface ITypescriptWorkerData {\n /**\n * Path to the version of TypeScript to use.\n */\n typeScriptToolPath: string;\n}\n\nexport interface ITranspilationRequestMessage {\n /**\n * Unique identifier for this request.\n */\n requestId: number;\n /**\n * The tsconfig compiler options to use for the request.\n */\n compilerOptions: TTypescript.CompilerOptions;\n /**\n * The variants to emit.\n */\n moduleKindsToEmit: ICachedEmitModuleKind[];\n /**\n * The set of files to build.\n */\n filesToTranspile: Map<string, string>;\n}\n\nexport interface ITranspilationSuccessMessage {\n requestId: number;\n type: 'success';\n result: TTypescript.EmitResult;\n}\n\nexport interface ITranspilationErrorMessage {\n requestId: number;\n type: 'error';\n result: {\n message: string;\n [key: string]: unknown;\n };\n}\n\nexport type ITranspilationResponseMessage = ITranspilationSuccessMessage | ITranspilationErrorMessage;\n\nexport interface ICachedEmitModuleKind {\n moduleKind: TTypescript.ModuleKind;\n\n outFolderPath: string;\n\n /**\n * File extension to use instead of '.js' for emitted ECMAScript files.\n * For example, '.cjs' to indicate commonjs content, or '.mjs' to indicate ECMAScript modules.\n */\n jsExtensionOverride: string | undefined;\n\n /**\n * Set to true if this is the emit kind that is specified in the tsconfig.json.\n * Declarations are only emitted for the primary module kind.\n */\n isPrimary: boolean;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type * as TTypescript from 'typescript';\n\nexport interface ITypescriptWorkerData {\n /**\n * Path to the version of TypeScript to use.\n */\n typeScriptToolPath: string;\n}\n\nexport interface ITranspilationRequestMessage {\n /**\n * Unique identifier for this request.\n */\n requestId: number;\n /**\n * The tsconfig compiler options to use for the request.\n */\n compilerOptions: TTypescript.CompilerOptions;\n /**\n * The variants to emit.\n */\n moduleKindsToEmit: ICachedEmitModuleKind[];\n /**\n * The set of files to build.\n */\n filesToTranspile: Map<string, string>;\n}\n\nexport interface ITranspilationSuccessMessage {\n requestId: number;\n type: 'success';\n result: TTypescript.EmitResult;\n}\n\nexport interface ITranspilationErrorMessage {\n requestId: number;\n type: 'error';\n result: {\n message: string;\n [key: string]: unknown;\n };\n}\n\nexport type ITranspilationResponseMessage = ITranspilationSuccessMessage | ITranspilationErrorMessage;\n\nexport interface ICachedEmitModuleKind {\n moduleKind: TTypescript.ModuleKind;\n\n outFolderPath: string;\n\n /**\n * File extension to use instead of '.js' for emitted ECMAScript files.\n * For example, '.cjs' to indicate commonjs content, or '.mjs' to indicate ECMAScript modules.\n */\n jsExtensionOverride: string | undefined;\n\n /**\n * Set to true if this is the emit kind that is specified in the tsconfig.json.\n * Declarations are only emitted for the primary module kind.\n */\n isPrimary: boolean;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rushstack/heft-typescript-plugin",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "Heft plugin for TypeScript",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -12,22 +12,22 @@
|
|
|
12
12
|
"types": "dist/heft-typescript-plugin.d.ts",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"@rushstack/heft": "0.61.
|
|
15
|
+
"@rushstack/heft": "0.61.2"
|
|
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
|
-
"@rushstack/node-core-library": "3.60.
|
|
22
|
-
"@rushstack/heft-config-file": "0.14.
|
|
21
|
+
"@rushstack/node-core-library": "3.60.1",
|
|
22
|
+
"@rushstack/heft-config-file": "0.14.1"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@rushstack/heft-node-rig": "2.2.23",
|
|
26
26
|
"@types/node": "18.17.15",
|
|
27
27
|
"@types/semver": "7.5.0",
|
|
28
28
|
"typescript": "~5.0.4",
|
|
29
|
-
"
|
|
30
|
-
"@rushstack/heft": "0.61.
|
|
29
|
+
"local-eslint-config": "1.0.0",
|
|
30
|
+
"@rushstack/heft": "0.61.2"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
33
|
"build": "heft test --clean",
|