Skip to content

Expose the oxnode watch watcher as an entry an embedder can run with its own loader #871

Closed

Description

@fengmk2

Vite+ vendors oxc-node and runs scripts with vpx <script> through its own loader: a --require preload and an --import, built on the binding's createResolve and load. We would like vpx watch to run the watcher from #861 instead of writing another, by bundling packages/cli/src/watch. Two things stop that today.

  1. runWatch(argv) hardcodes oxc-node's loader and name.

    • registerURL = import.meta.resolve("@oxc-node/core/register") is the child's loader (--enable-source-maps --import registerURL …) and the directory left out of the watch.
    • "oxnode watch" is in the errors, the usage line, and the help.

    An options argument would cover it, for example runWatch(argv, { loaderArgs, ignoreDirs, name }), exported from an entry that does not start the oxnode CLI (such as @oxc-node/cli/watch), so a bundler can take the watcher alone.

  2. The child's side lives in @oxc-node/core. register.mjs and esm.mjs call installSignalAck() for OXNODE_SIGNAL_ACK, and watchSink(), withFlush(), and enableWatchReport() for WATCH_REPORT_DEPENDENCIES. An embedder with its own hooks needs the same. watch-report.mjs imports takeWatchDependencies from @oxc-node/core's own binding, while an embedder forwards it from its binding. Either of these would let it reuse them:

    • Export signal-ack.mjs and watch-report.mjs as public entries that take the binding's functions as arguments.
    • Document the watch:import message and the ack socket as a stable protocol, so an embedder can implement its side.

With both, vpx watch and oxnode watch would share the watcher, and fixes to it would reach both.

Activity

  1. added a commit that references this issue on Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions