-
-
Notifications
You must be signed in to change notification settings - Fork 269
Description
Describe the bug
In watch mode (--watch), tsup only triggers rebuilds when files from result.metafile.inputs change. It ignores watchFiles returned by esbuild plugins from their onLoad callbacks.
Plugins like @vanilla-extract/esbuild-plugin correctly return watchFiles with all dependencies (e.g. .css.ts imports like tokens.ts). Those files never appear in the main build's metafile.inputs because they're only loaded inside the plugin's internal compilation. As a result, changing a dependency of a .css.ts file does not trigger a rebuild.
Reproduction
- Create a library with vanilla-extract: a
.css.tsfile imports fromtokens.ts - Run
tsup --watch - Change
tokens.ts— no rebuild - Change
.css.tsdirectly — rebuild works
Expected behavior
When any file in watchFiles (returned by plugins) changes, tsup should trigger a rebuild.
Suggested solution
Add a plugin that wraps build.onLoad and collects watchFiles from plugin results, then merge them into buildDependencies (the set used when deciding whether to rebuild). Path normalization may be needed for cross-platform compatibility (relative vs absolute, slash vs backslash).
Environment
- tsup version: 8.5.1