diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index acecfcbf2..d5a0b898a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,6 +21,7 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 2 + token: ${{ secrets.GH_TOKEN }} - name: Update Master run: | @@ -75,7 +76,7 @@ jobs: git config pull.rebase false git config --global user.email "release-workflow@rollup.dev" git config --global user.name "Release Workflow" - git remote set-url origin https://x-access-token:${{ secrets.GH_TOKEN }}@github.com/${{ github.repository }} + git remote set-url origin https://github.com/${{ github.repository }} - name: pnpm install run: pnpm install --frozen-lockfile 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'); } diff --git a/packages/typescript/test/test.js b/packages/typescript/test/test.js index 27cb33a10..e746680c1 100644 --- a/packages/typescript/test/test.js +++ b/packages/typescript/test/test.js @@ -612,6 +612,24 @@ test.serial('should not emit null sourceContent', async (t) => { t.false(sourcemap.sourcesContent.includes(undefined)); }); +test.serial('should not emit sourceContent that references a non-existent file', async (t) => { + const bundle = await rollup({ + input: 'fixtures/basic/main.ts', + output: { + sourcemap: true + }, + plugins: [ + typescript({ + tsconfig: 'fixtures/basic/tsconfig.json' + }) + ], + onwarn + }); + const output = await getCode(bundle, { format: 'es', sourcemap: true }, true); + const sourcemap = output[0].map; + t.false(sourcemap.sourcesContent.includes('//# sourceMappingURL=main.js.map')); +}); + test.serial('should not fail if source maps are off', async (t) => { await t.notThrowsAsync( rollup({