Skip to content

Comments

feat: add support for watching copy source files#721

Open
schplitt wants to merge 3 commits intorolldown:mainfrom
schplitt:feat/watch_copy_files
Open

feat: add support for watching copy source files#721
schplitt wants to merge 3 commits intorolldown:mainfrom
schplitt:feat/watch_copy_files

Conversation

@schplitt
Copy link

@schplitt schplitt commented Jan 20, 2026

  • This PR contains AI-generated code, but I have carefully reviewed it myself. Otherwise, my PR may be closed.

Description

Adds support for watching files specified in the copy configuration option. Now triggers a rebuild whenever a copied asset is changed.

Linked Issues

resolves #720

Additional context

I have manually tested this and confirmed that it works.
However, I have not found a good way to have an automated test for this.
What would be the best way forward regarding testing in this case?

@netlify
Copy link

netlify bot commented Jan 20, 2026

Deploy Preview for tsdown ready!

Name Link
🔨 Latest commit ecc0849
🔍 Latest deploy log https://app.netlify.com/projects/tsdown/deploys/6977a2bc85564100089ce306
😎 Deploy Preview https://deploy-preview-721--tsdown.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 20, 2026

Open in StackBlitz

npm i https://pkg.pr.new/tsdown@721
npm i https://pkg.pr.new/create-tsdown@721
npm i https://pkg.pr.new/tsdown-migrate@721

commit: ecc0849

Comment on lines 39 to 53
const copyOptions: CopyOptions =
typeof config.copy === 'function'
? await config.copy(config)
: config.copy

const copyFiles = (
await Promise.all(
toArray(copyOptions).map((entry) => {
if (typeof entry === 'string') {
return resolveFilePatterns(entry, config.cwd)
}
return resolveFilePatterns(entry.from, config.cwd)
}),
)
).flat()
Copy link
Member

Choose a reason for hiding this comment

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

Do not copy existing code, extract them instead.

* @param globOptions.expandDirectories - Expand directories (default: false)
* @returns Array of absolute file paths
*/
export async function resolveFilePatterns(
Copy link
Member

Choose a reason for hiding this comment

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

Remove this function. See src/features/copy.ts

@sxzz sxzz force-pushed the main branch 2 times, most recently from 2f6ea1c to dcaef07 Compare January 22, 2026 20:12
@schplitt
Copy link
Author

Thanks for the review
I refactored it

Please let me know if you would rather have a utility file for resolveCopyEntries

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Watch copied files in watch mode

2 participants