diff --git a/packages/typescript/src/index.ts b/packages/typescript/src/index.ts index 293e341d9..bea3e736d 100644 --- a/packages/typescript/src/index.ts +++ b/packages/typescript/src/index.ts @@ -17,7 +17,7 @@ import findTypescriptOutput, { normalizePath, emitFile, isDeclarationOutputFile, - isMapOutputFile + isTypeScriptMapOutputFile } from './outputFile'; import { preflight } from './preflight'; import createWatchProgram, { WatchProgramHelper } from './watchProgram'; @@ -156,11 +156,11 @@ export default function typescript(options: RollupTypescriptOptions = {}): Plugi }, async generateBundle(outputOptions) { - const declarationAndMapFiles = [...emittedFiles.keys()].filter( - (fileName) => isDeclarationOutputFile(fileName) || isMapOutputFile(fileName) + const declarationAndTypeScriptMapFiles = [...emittedFiles.keys()].filter( + (fileName) => isDeclarationOutputFile(fileName) || isTypeScriptMapOutputFile(fileName) ); - declarationAndMapFiles.forEach((id) => { + declarationAndTypeScriptMapFiles.forEach((id) => { const code = getEmittedFile(id, emittedFiles, tsCache); if (!code || !parsedOptions.options.declaration) { return; diff --git a/packages/typescript/src/outputFile.ts b/packages/typescript/src/outputFile.ts index 4dc0de04d..d7b080ab1 100644 --- a/packages/typescript/src/outputFile.ts +++ b/packages/typescript/src/outputFile.ts @@ -24,6 +24,13 @@ export function isCodeOutputFile(name: string): boolean { * Checks if the given OutputFile represents some source map */ export function isMapOutputFile(name: string): boolean { + return name.endsWith('.map'); +} + +/** + * Checks if the given OutputFile represents some TypeScript source map + */ +export function isTypeScriptMapOutputFile(name: string): boolean { return name.endsWith('ts.map'); }