Skip to content

Empty copy options should not warn No files matched for copying #774

@askoufis

Description

@askoufis

Reproduction link or steps

https://stackblitz.com/edit/github-ggwk8zxw?file=tsdown.config.ts

Run pnpm build.

What is expected?

With copy.from: [], copy: [], or a function that returns an empty array, I'd expect the No files matched for copying warning not to show.

What is actually happening?

A No files matched for copying warning is logged, which subsequently fails on CI.

Any additional comments?

While it doesn't make sense to configure an literal empty array as in the example, if a copy function conditionally returns an empty array, I'd expect the warning not to be logged in that case.

Basically, I want to conditionally copy files if they are present, otherwise don't copy any files. My use case is in a monorepo with a top-level tsdown config shared by many packages which may or may not contain assets I want to copy. Statically declaring the copy config for each package ahead of time would work, but is quite tedious, so I'd prefer to glob for them ahead of time, and if any are found, tell tsdown to copy them to dist.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions