Skip to content

Commit

Permalink
fix: ignore non js/ts files in --dts build, closes #554
Browse files Browse the repository at this point in the history
  • Loading branch information
egoist committed Jan 30, 2022
1 parent e600984 commit 20fb72b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/rollup.ts
Expand Up @@ -126,7 +126,7 @@ const getRollupConfig = async (
const ignoreFiles: Plugin = {
name: 'tsup:ignore-files',
load(id) {
if (/\.(css|vue|svelte)$/.test(id)) {
if (!/\.(js|cjs|mjs|jsx|ts|tsx|mts|json)$/.test(id)) {
return ''
}
},
Expand Down
27 changes: 27 additions & 0 deletions test/index.test.ts
Expand Up @@ -779,3 +779,30 @@ test('multiple targets', async () => {
expect(output).toMatchSnapshot()
expect(outFiles).toEqual(['input.js'])
})

test('dts only: ignore files', async () => {
const { outFiles } = await run(
getTestName(),
{
'input.ts': `
import './style.scss'
export const a = 1
`,
'style.scss': `
@keyframes gallery-loading-spinner {
0% {}
}
`,
},
{
entry: ['input.ts'],
flags: ['--dts-only'],
}
)
expect(outFiles).toMatchInlineSnapshot(`
[
"input.d.ts",
]
`)
})

1 comment on commit 20fb72b

@vercel
Copy link

@vercel vercel bot commented on 20fb72b Jan 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.