这是indexloc提供的服务,不要输入任何密码
Skip to content

fix: copyPublicDir in watch mode #1331

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 16, 2025
Merged

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)

Copy link

codesandbox bot commented Apr 24, 2025

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

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

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
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