Skip to content

fix: copyPublicDir in watch mode#1331

Merged
egoist merged 1 commit intoegoist:mainfrom
geeee:fix-copypublicdir
May 16, 2025
Merged

fix: copyPublicDir in watch mode#1331
egoist merged 1 commit intoegoist:mainfrom
geeee:fix-copypublicdir

Conversation

@geeee
Copy link
Contributor

@geeee geeee commented Apr 24, 2025

This PR fixes #831 by moving the copyPublicDir call inside the buildAll function. As a result, files from the public directory are now also copied when debouncedBuildAll is triggered (e.g., in watch mode).

This introduces a potential breaking change:

Before:

  • if onSuccess was a function, it was always called before copyPublicDir was even invoked.
  • if onSuccess was a string, both the copy and the shell command were started simultaneously, leading to race conditions. In most cases, the copy finished first, but behavior was unreliable

After this change:

  • onSuccess is always called after copyPublicDir completes — ensuring the build (including public files) is fully ready before executing any post-build logic.

Potential improvements:

  • optimize by running copyPublicDir inside debouncedBuildAll only when options.clean is true. However, this may not be worth the added complexity: most public directories are probably small and debouncedBuildAll is already throttled. The current implementation is simpler and more predictable, which may outweigh this optimization.
  • tests (requires test for watch mode)

@codesandbox
Copy link

codesandbox bot commented Apr 24, 2025

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@vercel
Copy link

vercel bot commented Apr 24, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
tsup ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 24, 2025 8:11pm

@pkg-pr-new
Copy link

pkg-pr-new bot commented May 16, 2025

Open in StackBlitz

npm i https://pkg.pr.new/egoist/tsup@1331

commit: a50c6a2

@egoist egoist merged commit 7c1e13e into egoist:main May 16, 2025
12 checks passed
vaernion pushed a commit to Arbeidstilsynet/brevgen2 that referenced this pull request Dec 3, 2025
This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [tsup](https://tsup.egoist.dev/) ([source](https://github.com/egoist/tsup)) | [`8.4.0` -> `8.5.0`](https://renovatebot.com/diffs/npm/tsup/8.4.0/8.5.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/tsup/8.5.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/tsup/8.5.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/tsup/8.4.0/8.5.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/tsup/8.4.0/8.5.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>egoist/tsup (tsup)</summary>

### [`v8.5.0`](https://github.com/egoist/tsup/releases/tag/v8.5.0)

[Compare Source](egoist/tsup@v8.4.0...v8.5.0)

#####    🚀 Features

-   Use `fix-dts-default-cjs-exports` to transform CJS types  -  by [@&#8203;userquin](https://github.com/userquin) in egoist/tsup#1310 [<samp>(c654e)</samp>](egoist/tsup@c654e5f)
-   Allow passing custom swc configuration to swcPlugin  -  by [@&#8203;Romakita](https://github.com/Romakita) in egoist/tsup#1313 [<samp>(fdfd5)</samp>](egoist/tsup@fdfd59a)

#####    🐞 Bug Fixes

-   Make `removeNodeProtocol` work with `shims`  -  by [@&#8203;aryaemami59](https://github.com/aryaemami59) [<samp>(769aa)</samp>](egoist/tsup@769aa49)
-   CopyPublicDir in watch mode  -  by [@&#8203;geeee](https://github.com/geeee) in egoist/tsup#1331 [<samp>(7c1e1)</samp>](egoist/tsup@7c1e13e)

#####     [View changes on GitHub](egoist/tsup@v8.4.0...v8.5.0)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or PR is renamed to start with "rebase!".

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).

Related work items: #30372
This was referenced Feb 5, 2026
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.

--publicDir doesn't work in watch mode

2 participants