Skip to content

Commit

Permalink
fix(typescript): fix .js.map files being treated as declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
ianyong committed Aug 29, 2023
1 parent d517378 commit d60cf8c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/typescript/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import findTypescriptOutput, {
normalizePath,
emitFile,
isDeclarationOutputFile,
isMapOutputFile
isTypeScriptMapOutputFile
} from './outputFile';
import { preflight } from './preflight';
import createWatchProgram, { WatchProgramHelper } from './watchProgram';
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions packages/typescript/src/outputFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down

0 comments on commit d60cf8c

Please sign in to comment.