Skip to content

[8.5.1] Watch mode: include plugin-returned watchFiles in rebuild trigger set #1382

@ivmuratov

Description

@ivmuratov

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

  1. Create a library with vanilla-extract: a .css.ts file imports from tokens.ts
  2. Run tsup --watch
  3. Change tokens.ts — no rebuild
  4. Change .css.ts directly — 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions