Skip to content

Call build:prepare hook on rebuild in watch mode #972

@Karibash

Description

@Karibash

Clear and concise description of the problem

When running in watch mode, tsdown currently only calls the build:done hook on each rebuild. The build:prepare hook is never invoked after the initial build.
This makes it difficult to adopt tsdown in projects that require code generation before building — for example, those using graphql-codegen. Since build:prepare is the natural place to trigger such pre-build steps, skipping it on rebuilds means generated code becomes stale during development.

Suggested solution

Invoke the build:prepare hook at the start of each rebuild cycle in watch mode, just as it is called before the initial build.

Alternative

Expose a dedicated watch-specific hook (e.g. watch:rebuild) that fires before each rebuild, so users can run pre-build tasks without relying on build:prepare semantics.

Additional context

Tools like graphql-codegen need to run before TypeScript compilation to produce up-to-date type definitions. Without build:prepare being called on each rebuild, developers lose the hot-reload experience that watch mode is meant to provide, and must resort to running a separate watcher process in parallel.

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Priority

    None yet

    Start date

    None yet

    Target date

    None yet

    Effort

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions