- Status: Implemented in #2936; CI covers Linux, macOS, and Windows on Node.js 22, 24, and 26
- Related:
vpxcommand, JavaScript runtime management, CLI bundling, Core binding resolution - Upstream: oxc-node at the revision in the upstream pins, vendored and compiled into the Vite+ native binding, as Rolldown is
- Prior art: tsx 4.23.15
vpx runs a script file directly:
vpx ./scripts/seed.ts --dry-runWhen the command names a script, vpx runs it on the project's managed Node.js with the oxc-node loader preloaded, instead of resolving a package binary:
vpx ./seed.ts args ──► node --require …/vite-plus/dist/script-preload.cjs
--import file:///…/vite-plus/dist/script-register.js ./seed.ts args
The loader's native half is compiled into the Vite+ binding; its JavaScript half ships in vite-plus/dist. TypeScript syntax that Node.js cannot strip (enums, namespaces, parameter properties, legacy decorators, JSX) works without a tsx dependency, as do tsconfig paths, .js → .ts imports, TypeScript dependencies, and ESM/CJS interop. Package-binary execution (vpx eslint .) is unchanged. A project-local vpx bin makes it work in package.json scripts without the global CLI.
Repositories use tsx to run scripts/*.ts. Vite+ manages the Node.js version and ships the rest of the toolchain, but running a TypeScript file meant adding tsx (esbuild, two processes), downloading it through vpx tsx, or settling for vp node and Node.js type stripping, which only erases syntax: no enums, decorators, JSX, tsconfig paths, or TypeScript in node_modules. VoidZero maintains oxc-node, an Oxc-based loader that this repository and Rolldown already use for their own scripts. Exposing it through vpx gives users a tsx equivalent with no extra dependency, on the project-pinned Node.js.
vpx <script>runs.ts .mts .cts .tsx .js .mjs .cjs .jsxfiles with full TypeScript syntax, tsconfigpaths,.js→.tsimports, and both module systems.- Scripts run on the Node.js that
vp nodewould select; the project-local bin runs them on the Node.js that started it. - On Unix, one process: exit codes, signals, stdio, and
process.ppidbehave as withnode. - Node.js options (
--watch,--inspect,--env-file=,--test,--import) are forwarded. #!/usr/bin/env vpxworks for files that keep a script extension.- The loader ships inside
vite-plus: no new npm package, no user dependency. vpx <script>works from a project-localvite-pluswithout the global CLI.- Package-binary behavior of the global
vpxis unchanged.
Type checking (vp check); a TypeScript REPL or TypeScript in -e/-p or --check; a programmatic API (see Future Enhancements); an on-disk transform cache; target downleveling; Bun and Deno. The public node --import vite-plus/register entry is specified in the preload RFC.
vpx [VPX_OPTIONS] [NODE_OPTIONS] <script> [args...]VPX_OPTIONS: the existingvpxoptions plus--tsconfig <path>and-v/--version.-p/--packageand-c/--shell-modeselect package mode, so combining them with a script is an error.-s/--silentis accepted; script mode prints no Vite+ output either way.NODE_OPTIONS: tokens starting with-between thevpxoptions and the script, forwarded to Node.js verbatim, except two thatvpxtakes out:--tsconfig(vpx --inspect --tsconfig x.json ./a.ts) and--watch(see Watch Mode).<script>and[args...]: passed to Node.js unchanged. Tokens after the script, including--, belong to the script.
vpx options are parsed first, so -p, -c, -h, and -v keep their vpx meaning; Node.js has the long forms, and vp node --version prints the Node.js version. vpx --version prints the same report as vp --version.
When the first positional token starts with - and no script follows, vpx forwards the arguments to Node.js with the loader: --eval, --print, --check ./a.ts, - (stdin), --inspect (REPL). The loader does not transform eval or REPL input, and Node.js reads a --check file without it, as with tsx. The help text lives in VPX_HELP in crates/vp_global_cli/src/commands/vpx.rs and the command_vpx_pnpm* snapshots.
--watch among the Node.js options runs oxc-node's watcher instead of Node.js' own watch mode (see Watch Mode). Its options are oxc-node's (--include, --exclude, --clear-screen, --kill-signal, --kill-timeout, --rerun-on-enter, --poll), which also accept tsx watch's --ignore and --no-cache and the Node.js watch mode options --watch-preserve-output and --watch-kill-signal, and vpx --watch --help prints them. They go among the Node.js options, and detection knows which of them take a value (watchOptionsWithValue in the shared table), so vpx --watch --exclude ./gen.ts ./main.ts runs main.ts. vpx watch stays package mode, so it still runs the npm package watch.
Detection runs before package-spec parsing, because script paths can contain @. It decides the mode and which token gets the missing-file check; it never rewrites the arguments except to remove --tsconfig and --watch.
after parsing vpx options, let T = positional[0]
if T starts with '-': # Node.js invocation; a leading option never named a package bin
script = first token after the Node.js options (the token after `--`, or `-` for stdin),
skipping the value of options that take one (every `--option=...` that
`node --help` lists on 22, 24, and 26: --import, --require, --env-file, -r, …,
and the watcher's --include, --exclude, --ignore, --kill-signal, --kill-timeout)
a bare --experimental-config-file takes the next token only when it ends in .json:
older releases take a separate config path, and 24.19, 26.1, and later read
the bare flag as node.config.json; a .json file cannot be the script
after -e, --eval, -p, -pe, --print, --run, or --test, no token is a script: Node.js
runs that code or package script, or takes test files and globs
option names match with `_` for `-` (--redirect_warnings), as Node.js accepts
script is a missing explicit path with a script extension → error
--watch or --watch-path among the options → the watcher (--watch removed)
otherwise → forward to Node.js as-is
elif is_script(T):
script = T
else:
package mode (existing lookup chain, unchanged)
is_script(token):
explicit = token starts with ./ ../ / (Windows: .\ ..\ X:\ \\)
ext = token ends with .ts .mts .cts .tsx .js .mjs .cjs .jsx
ext && cwd/token is a regular file → script
ext && (explicit || TS extension) → error (never a package)
explicit && cwd/token does not exist → error "Script not found"
explicit && regular file whose shebang line invokes vpx → script
otherwise → not a script
an error is "Script is a directory" when cwd/token is a directory, else "Script not found"
After Node.js options, only a missing explicit path is an error: a bare name may be the value of an option the skip list lacks, and that position never falls back to a package, so a wrong guess only moves the check to Node.js. Both CLIs declare the same lists and run the shared cases in crates/vp_global_cli/src/commands/vpx_script_cases.json.
| Invocation | Mode | Reason |
|---|---|---|
vpx ./scripts/seed.ts |
script | Explicit path with a script extension |
vpx scripts/seed.ts |
script | The file exists |
vpx seed.ts (no such file) |
error | TypeScript extension; never a package name |
vpx ./bin/missing (no such path) |
error | Explicit path, even without an extension |
vpx ./tools.ts (a directory) |
error | "Script is a directory" |
vpx highlight.js (no such file) |
package | Bare name with a JS extension and no file |
vpx ./@scope/tool.ts |
script | Detection runs before @version parsing |
vpx --import ./setup.ts ./main.ts |
script | ./setup.ts is the value of --import |
vpx --eval 'console.log(1)' |
node | No script token; forwarded with the loader |
vpx --eval '…' ./missing.ts |
node | After --eval, ./missing.ts is an argument |
vpx /abs/bin/tool (#!/usr/bin/env vpx) |
script | Shebang guard; otherwise vpx would exec itself in a loop |
vpx ./deploy.sh |
package | No script extension; runs as a program, without the loader |
vpx --watch ./server.ts |
watcher | --watch runs oxc-node's watcher, not Node.js' watch mode |
vpx watch ./server.ts |
package | watch is the npm package of that name |
vpx ./scripts/seed.ts --dry-run
├─ parse vpx options (--tsconfig, -s, -v, -h; -p/-c select package mode)
├─ detect script ── package ──► existing chain: node_modules/.bin → global → PATH → dlx
├─ resolve loader: <project vite-plus>/dist, else <global vite-plus>/dist
├─ env: prepend every node_modules/.bin (cwd → root); set or clear VP_SCRIPT_TSCONFIG
└─ core `node` shim dispatch (same runtime selection as `vp node`)
└─ execve: node --require <dist/script-preload.cjs> --import <file URL of dist/script-register.js>
[NODE_OPTIONS] ./scripts/seed.ts --dry-run
Script mode hands the argv to the core node shim path (crates/vp_global_cli/src/shim/dispatch.rs), which vp node also uses: project version resolution, VP_BYPASS, and inherited runtimes inside vp run. In system-first mode it first repeats the shell's PATH lookup, as vp node does, and runs the system Node.js found before any Vite+ shim.
On Unix, exec_tool replaces the vpx process with node through execve; no parent remains, so no IPC, signal relay, or exit-code translation is needed. On Windows, the vpx.exe trampoline starts vp.exe, which spawns node and waits, as for every shim; exit codes and Ctrl+C follow the existing node shim behavior.
Two entries in vite-plus/dist, passed together:
--require <dist/script-preload.cjs>(CommonJS, frompackages/cli/src/script-preload.ts). It runs before any user--requireor--import, so--require ./setup.tspreloads work. It checks the Node.js version and exits with a Vite+ error outside^22.18.0 || ^24.11.0 || >=26.0.0(theengines.noderange), loads the native binding throughpackages/cli/binding/index.cjs, callsinitializeLoader()andsetTransformDeps('typescript'), turns on source maps, installs the pirates CommonJS hook, and on Node.js 22.22.3+, 24.11.1+, and 26 registers the in-thread ESM hooks withmodule.registerHooks().--import <file URL of dist/script-register.js>(ESM). On older 22.x and 24.x it registers the off-thread hooks (dist/script-esm-hooks.js) withmodule.register(), which Node.js 22 cannot call while a--requireis loading. On every version, an--importalso routes the entry point through the ESM loader, where the hooks decide each file's module format.
The in-thread hooks start about twice as fast as a hooks thread, and Node.js 25.9+ deprecates module.register() (DEP0205). They need nodejs/node#59011 (22.19, 24.5) and nodejs/node#59929 (22.22.3, 24.11.1); tsx switches at the same releases. Upstream oxc-node waits for 26.2 for nodejs/node#62920, which only affects load hooks that return CommonJS source; these hooks do that only when another hook supplied it (see Known Limitations).
The contract is the two flags plus the VP_SCRIPT_TSCONFIG environment variable, and node <dist/script-watch.js> <watcher args> for --watch. The global vp may be newer or older than the project's vite-plus, so it stays stable: new behavior goes into the loader entries, not into new argv. A contract change gets new entry file names, so a vp that does not know them falls back to the global loader, as it does for a project too old to ship them. vpx_script.rs points readers here for this.
The loader is resolved from the project's vite-plus first (JsExecutor::resolve_local_vite_plus_package_dir), when its dist/ has both entries (all three for --watch), and from the global install second (JsExecutor::get_scripts_dir()), following the global CLI's JS-entry delegation. Teams and CI then run the loader and binding pinned in their lockfile. A project vite-plus from before the watcher keeps running vpx <script> itself and takes the watcher and its loader from the global install.
vpx --watch <script> never runs Node.js' own watch mode. Detection takes --watch out of the Node.js options and marks the invocation, and both CLIs then run dist/script-watch.js (from packages/cli/src/script-watch.ts) with the remaining arguments. It bundles oxc-node's watcher, runWatch from @oxc-node/cli/watch, from the vendored oxc-node/packages/cli/src/watch, and calls runWatch(process.argv.slice(2), { name: 'vpx --watch', loaderArgs, ignoreDirs }): loaderArgs are the two loader flags for the dist/ it sits in, so the watcher and the loader always come from one vite-plus, and ignoreDirs is that vite-plus package, whose loader files and binding show up in the module graph. The name labels the help, the errors, and the [vpx] log lines. Only the vpx side changes; oxc-node's watcher runs as published.
- The global
vpxrunsnode <dist>/script-watch.js <args>through the samenodeshim path as a script, so the watcher gets the Node.jsvp nodeselects and, on Unix, the PID ofvpx. The project-local bin imports the entry in its own process, after puttingnode_modules/.binfirst onPATH. Either way the watcher process starts the script withprocess.execPath, so there is one process above the script, as Node.js' watch mode had. --tsconfigworks as for a script: the CLIs set or clearVP_SCRIPT_TSCONFIGbefore the watcher starts, the runs inherit it, and the preload passes it toinitializeLoader(), which wins over aTS_NODE_PROJECTorOXC_TSCONFIG_PATHthat an--env-filesets. The loader reports the config it read, so the watcher reruns on an edit to it.--watch-path, which would start Node.js' watch mode, also selects the watcher, which rejects it with a hint to use--include. So do--test,--eval, and the other options that run no file.- The watcher sets
WATCH_REPORT_DEPENDENCIESand an IPC channel, so the loader sends its reports, and its own folder watcher sees files created later on every platform and Node.js version. It ownsSIGINT,SIGTERM,SIGHUP, stdin (Return reruns), and the IPC channel until it stops, and exits with the script's code. - Ctrl+C from a terminal reaches the script through the process group, so the watcher does not forward it. When the watcher is not the terminal's foreground job (a pipe,
vp run, a tool), it forwards aSIGINTunless the script acks one within 50 ms on theOXNODE_SIGNAL_ACKsocket, which the preload'sinstallSignalAck()does while the script listens forSIGINTitself. ASIGINTsent to the watcher's PID alone still reaches the script.
- Every
node_modules/.binfrom the cwd up is prepended toPATH(prepend_node_modules_bin_to_path), as for local binaries, so scripts can spawn project tools by name. --tsconfig <path>is resolved against the cwd and must exist.vpxpasses it asVP_SCRIPT_TSCONFIGand clears an inherited value when the flag is absent. The loader selects the first nonempty value fromVP_SCRIPT_TSCONFIG,TSX_TSCONFIG_PATH,TS_NODE_PROJECT, andOXC_TSCONFIG_PATH, in that order. An explicit selection applies to every file; otherwise each file uses the nearest tsconfig that includes it, as tsc does. Selection is captured independently in each application thread; later environment changes do not replace it. See the configuration contract for registration and freezing. A missing environment-selected file, or a tsconfig that fails to parse, prints a warning instead of being skipped silently. The guide lists the defaults when no tsconfig applies.- The loader goes in argv, not
NODE_OPTIONS:process.execArgvcarries it intochild_process.fork('./worker.ts')andnew Worker('./worker.ts'), while unrelated processes the script spawns (vp build,npm) do not load it. - Project
--loaderchains can compose with the public registration entry under the custom-loader contract. Competing TypeScript loaders remain unsupported: aNODE_OPTIONS=--import tsxor user--import tsxregisters another transformer, and the result depends on which one claims each file.
vite-plus ships "vpx": "./bin/vpx" next to vp and vpr (packages/cli/src/vpx-bin.ts, vpx-script.ts). Package managers and vp run put node_modules/.bin first on PATH, so this bin runs in package.json scripts. Without it, "seed": "vpx ./scripts/seed.ts" would work on a developer machine and fail in CI that only runs npm i -D vite-plus; tsx has no such gap, and vp migrate can only rewrite tsx to vpx if the result works wherever tsx did.
- Script mode: the same detection rules, then Node.js with
['--require', preload, '--import', registerUrl, ...nodeArgs]. On Unix, the bin execs it in place withprocess.execve(), as the globalvpxdoes, so the PID its caller holds, every signal sent to it, and the exit status belong to the script. The new process starts as a spawned child would: the bin restores the defaultSIGPIPEandSIGXFSZdispositions, which Node.js ignores, and blocking stdio, whichprocess.execve()leaves non-blocking once Node.js has opened a pipe (nodejs/node#66824). - On Windows, and when the bin itself has an IPC channel, as when a tool
fork()s it, the bin spawns the script instead, since exec would close the channel. It ignoresSIGINT, which reaches the child through the process group, forwardsSIGTERMandSIGHUP, and exits the way the child did (re-raising its signal on Unix, so callers see128 + signal). With an IPC channel, it opens one to the script and relays messages both ways, as tsx does, and exits with the script's code once the script has exited and the channel has closed, whichever side closed it. The globalvpxpasses the channel on through exec. On Windows, only afork()of the bin file carries a channel; a.cmdshim cannot. - Package mode never hands off to the global
vpx, so delegation stays one-directional: the global CLI delegates to the project'svite-plus, never the reverse. An earlier design forwarded to the globalvpxonPATH, and two copies of the local bin onPATHspawned each other forever. - The nearest
node_modules/.bin/<name>from the cwd up runs directly, with everynode_modules/.binfirst onPATH, like the global CLI. On Unix, the bin execs it in place: directly when it is a native binary or a script whose#!interpreter is one, and otherwise through/bin/sh -c 'exec "$0" "$@"', because a failedprocess.execve()aborts most supported Node.js versions and sh reports a file it cannot run as a terminal does. On Windows,cross-spawnruns it, including.cmdshims. So does an explicit path to an existing executable file (./deploy.sh). It does not usevp exec, which needs apackage.jsonabove the cwd and installs the project's runtime first. pkg@version,--package,--shell-mode, and a package directory go to this package'svp dlxin-process, by importingdist/bin.jswith the argv rewritten, asvprdoes. Only that path loads the CLI bundle and the native binding.- Global packages and
PATHare never searched. A binary that is not installed is an error with a hint (add it todevDependencies, or runvp dlx), never a download. An installed binary without an executable bit is an error with a hint to reinstall. - In both CLIs, an explicit path to a non-executable file, or to a directory without a
package.json, is an error (check_explicit_program,checkExplicitProgram) instead of avp dlxfailure. --helpprints the local bin's own help;--versionprintsvite-plus v<version>.- Both CLIs run the shared case table
vpx_script_cases.json: detectioncases,packageSpecs, andexplicitPrograms. A unit test checks that their extension, value-taking-option, and no-entry-option lists are identical.
For a script, the local bin and the global shim resolve the same loader and Node.js; the difference is the local bin's own Node.js startup before it execs the script, about 23–30 ms against the global shim's 5–10 ms (Performance).
vp migrate rewrites tsx commands to vpx as an optional migration, like Prettier and tsup: always on a fresh project, and with --full on one already using Vite+ (packages/cli/src/migration/migrator/tsx.ts; behavior in Migration Rules).
The preload RFC extends this with a direct
replacement of node --import tsx and literal NODE_OPTIONS imports. These keep
Node.js as the executable and replace the preload with vite-plus/register.
The vpx command restrictions below apply to CLI migrations, not that preload path.
- It reads commands with the same literal-command parser as the other script rewrites and finds the script the way
vpxdoes, with the shared value-taking option lists. Commands it cannot read, and formsvpxcannot run (eval,--check, the REPL,--testwithout files or in watch mode, an entry without an extension), keep tsx with a warning. - It has no Node.js check of its own:
vpxneeds theengines.noderange ofvite-plus(SUPPORTED_NODE_RANGEinscript-hooks.ts, which a unit test keeps equal), and migration already upgrades incompatible runtime pins to that range for Vite+ itself. - The
tsxdevDependency goes only when no scripts, imports (including build output andpackage.json#importsaliases), shebangs, tool settings such as--import=tsx, CI workflows, git hooks, or shell scripts use tsx anymore, including in nested packages that can resolve it. A package that lists tsx independencies,optionalDependencies, orpeerDependencieskeeps it, sincevpxcomes from a devDependency. - It reads the scripts a command runs, and its local preloads, and keeps tsx when one does not exist yet, as when an earlier command generates it, and when
vpxwould fail on one: arequire()of./a.jsthat only tsx resolves toa.ts, a.ctsfile withimportorexport, and a file that mixesimportwith__dirname,__filename,require(), ormodule.exportsin a package without"type": "module". tsx compiles the last two to CommonJS;vpxrejects the first of them and runs the second as an ES module. These checks are exact and local. The migration skips globs and scripts after a shell state change, and does not look for differences that need module-graph or tsconfig analysis (imports of the named files, standard decorators, tsconfigpathsinrequire(), a tsconfigmoduleofnode16ornodenext);vpxreports those when the script runs.
oxc-node is vendored the way Rolldown is:
packages/tools/.upstream-versions.jsonpins the oxc-node commit, including the worker loader isolation from oxc-node#888. The dailyupgrade-depsworkflow advances it to stable tags that contain the pinned commit.sync-remoteclones it into the gitignoredoxc-node/and runspackages/tools/src/patch-oxc-node.ts. CI checks it out in the shared clone action and the security workflow and runs the script before any cargo command, becauseCargo.lockrecords the rewritten manifest.patch-oxc-node.tspoints oxc-node'soxcdependency at the workspace version and adapts an AST predicate, so the binding compiles against one copy of oxc. Upstream exposes the frozen tsconfig APIs to embedders while keeping their NAPI registration disabled.- The root
Cargo.tomladdsoxc-node = { path = "./oxc-node", default-features = false, features = ["yarn_pnp"] }and excludesoxc-node/from the workspace lints.yarn_pnpmatches theoxc_resolverfeature the workspace enables, which changes oxc-node's file system signature. Without itsnapifeature, oxc-node links as a plain library with no NAPI exports and no global allocator, so nothing collides with thetransformexport thatrolldown_bindinglinks. - The binding's
oxc-nodefeature compilespackages/cli/binding/src/oxc_node.rs;build.tsenablesrolldown,oxc-nodefor every build, so dev builds compile it too, at no extra crate cost.
oxc_node.rs forwards what the loader uses under an oxcNode namespace: createResolve, load, OxcTransformer (returning a plain { source, sourceMap }), initializeLoader, freezeTsconfig, freezeTransformDeps, setTsconfigPath, setTransformDeps, transformsDep, and the watch reporting, enableWatchReport and takeWatchDependencies. Its module_exports hook calls init_tracing() (so OXC_LOG works; the subscriber stays off otherwise and never replaces VP_LOG's) and detect_runtime_syntax() (so using stays native on Node.js 24+), which oxc-node's own module hooks do when its napi feature is on. An upstream signature change is a compile error in the forwarders.
Issues found during this work were fixed upstream: in v0.1.5 to v0.1.7, including the napi feature, setTsconfigPath(), setTransformDeps("typescript"), and single-transform CommonJS loading, and on main since, all the ones found in end-to-end testing against tsx (oxc-node#835, #837, #839 to #846, and #856), and the one from the final round, #862 (a parent URL ending in /, the working directory Node.js resolves the entry point and --import against, was resolved as a file). The public preload consumes oxc-node#888 for independent worker configurations. Two oxc transformer issues found in that testing are still open; see Known Limitations.
Files: packages/cli/src/script-preload.ts, script-register.ts, script-esm-hooks.ts, script-hooks.ts.
- The entries are adapted from oxc-node's
register.mjsandesm.mjs, usingoxcNodefrom the binding.script-preload.tshas its own tsdown block: one CommonJS file withimport.meta.urlshimmed and the binding never bundled.piratesis a devDependency bundled intodist. The off-thread hooksrequire()the binding; importing it would make the hooks thread translate the CommonJS binding for ESM (5–13 ms). - Helper mapping. Lowered code imports runtime helpers. The loader passes oxc-node its own helper module name,
vite-plus:oxc-node, so it redirects only helpers these hooks emitted, and mapsvite-plus:oxc-node/helpers/<name>to@oxc-project/runtime/helpers/<name>, resolved fromvite-plusitself:nextResolve(helper, { parentURL: <vite-plus dist URL> }).@oxc-project/runtimeis a dependency ofvite-plus, so it resolves under strict layouts such as pnpm;upgrade-depskeeps its catalog pin at the latest oxc release, never older than the oxc version the binding transforms with, so every helper the transformer emits exists. - CommonJS
requireof helpers. Output withoutimport/exportloads helpers withrequire("vite-plus:oxc-node/helpers/…"), which never reaches the off-thread hooks, while theregisterHooks()resolve hook passes everyrequire()on unchanged to Node.js' CommonJS resolution, which resolves from the requiring file and ignores aparentURL. The preload wrapsModule._resolveFilename, which both go through, to resolve those specifiers fromvite-plus, as upstream'sregister.mjsdoes, so a project without@oxc-project/runtime(pnpm, or a script outside any project) still finds them. require()requests (noimportAttributesin the context) stay on Node.js resolution and the pirates hook. The in-thread load hook returns a null source for a CommonJS file oxc-node left to the CommonJS loader, sorequire()inside it works on every runtime.- The CommonJS hook gives oxc-node's error for
require()of an ES module with top-level await Node.js'sERR_REQUIRE_ASYNC_MODULEcode, which the binding cannot set, as upstream'sregister.mjsdoes. setTransformDeps('typescript')transforms.ts .mts .cts .tsxundernode_modules, which Node.js refuses to strip, and leaves other dependencies as published;transformsDep()gives the pirates matcher the same answer.OXC_TRANSFORM_ALLhas no effect undervpx.- Source maps are on for
node_modulestoo (setSourceMapsSupport(true, { nodeModules: true, generatedCode: true })), as tsx and upstream do, so stack traces in transformed dependencies point at their source. Node.js then reads the.mapof every dependency that has one. - Watch reports. Under a watcher (
WATCH_REPORT_DEPENDENCIESand an IPC channel, which the watcher sets up), the preload callsenableWatchReport()before the first transform or resolve, and each hook and the pirates transform send what the binding recorded, the tsconfig files read and the paths a failed resolve looked for, as{ "watch:import": [url] }, the message oxc-node's watcher and Node.js' read. The sender and the relay are oxc-node's@oxc-node/core/watch-report, bundled from the vendored source. The preload and the--importentry are separate bundles, so they share the thread's sink through a global symbol. The off-thread hooks have no IPC channel;script-register.tspasses them a port, as upstream'sregister.mjsdoes, and relays what they post. The preload also installs@oxc-node/core/signal-ack, the app side of the watcher's Ctrl+C handshake, a no-op withoutOXNODE_SIGNAL_ACK.
| Capability | tsx 4.23 | vpx |
Node.js type stripping |
|---|---|---|---|
.tsx / .jsx |
✓ (classic runtime by default) | ✓ (automatic runtime by default; classic via tsconfig or pragma) | ✗ |
| Enums, namespaces, param props | ✓ | ✓ | ✗ |
| Legacy decorators | ✓ | ✓, plus emitDecoratorMetadata |
✗ |
TC39 decorators, accessor |
✓ (esbuild lowers) | ✗ (decorators: clear error) | ✗ |
SIGINT / SIGTERM |
Exit code 130 / 143, exit handlers run |
The signal ends the process, as in Node.js | Same as vpx |
tsconfig paths |
✓ | ✓ for import; not for require() |
✗ |
| tsconfig selection | One per process, from the cwd; paths for every file |
Nearest config that includes the file (tsc rules); a file no config includes gets default options and the nearest config's paths |
n/a |
.js → .ts, extensionless |
✓ | ✓ for import; not for require() |
✗ |
require() of .ts, interop |
✓ (compiles ESM to CJS if needed) | ✓ (.cts with ESM syntax is an error) |
Partial |
TypeScript in node_modules |
✓ | ✓ | ✗ |
Class fields, using |
Lowered to target |
Native unless [[Set]] fields or legacy decorators; using lowered on 22.x |
Native |
| Watch | tsx watch (chokidar) |
vpx --watch: oxc-node's watcher, also tsconfig edits and created files |
--watch |
TypeScript REPL / -e |
✓ | ✗ | Erasable syntax only |
| Transform cache | On disk, about 8 days | None (Performance) | n/a |
require()uses Node.js' CommonJS resolution, as upstream: it applies no tsconfigpathsand does not map.jsto.ts. tsx does both.- A
.tsor.jsfile withimport,export, orimport.metain a package without"type"runs as an ES module, as in Node.js, so__filename,__dirname, andrequireare undefined. tsx compiles it to CommonJS. SIGINTandSIGTERMend the script as they end Node.js. tsx turns them into exit codes 130 and 143 and runsexithandlers first.- On the off-thread releases (22.18 to 22.22.2, 24.11.0), a
--requirepreload also runs in themodule.register()hooks thread, so it runs twice. tsx has the same behavior. - On the off-thread releases, starting the hooks thread makes Node.js open stdout and stderr, which sets a pipe non-blocking, so
fs.writeSync(1, …)to a slow reader can fail withEAGAIN.process.stdout.write()is not affected. tsx has the same behavior. - A
--requireor--importinNODE_OPTIONSalso runs in the local bin's own Node.js before it execs the script, so it runs twice, as under thetsxCLI. The globalvpxruns it once. - A bare
--experimental-config-filetakes the next argument in detection only when it ends in.json, the same on every Node.js release: older releases take a separate config path, and 24.19, 26.1, and later read the bare flag asnode.config.json. On an older release, a separate config path that does not end in.jsonis taken for the script, so--watchand--tsconfigafter it are not vpx's;--experimental-config-file=<path>works on every release. vpx --watchputs its Ctrl+C ack socket inTMPDIR. When that path would pass 100 bytes (thesun_pathlimit), the watcher runs without the ack, so a Ctrl+C while it is not the terminal's foreground job reaches a script that handlesSIGINTtwice, as it would without the loader's ack.- On in-thread releases without nodejs/node#62920 (22.22.3+, 24.11.1 to 24.17, 26.0, 26.1),
require()inside a CommonJS module whose source another load hook supplied can fail. The tested asynchronous--loaderchains do not establish compatibility with every hook composition, particularly additional synchronous hooks. See the custom-loader contract. - When a tool
fork()s the local bin, the bin spawns the script and ignoresSIGINT, sokill -INT <bin pid>does not stop the script; Ctrl+C does, through the process group. Forwarding it would deliver Ctrl+C twice; tsx avoids that with its own IPC channel. - On Windows, the local bin runs a
.cmdbinary fromnode_modules/.binthroughcmd.exe, so Ctrl+C there can end with the "Terminate batch job (Y/N)?" prompt. The globalvpxavoids it by running the binary's.ps1sibling, when one exists and stdin is a terminal. - A tsconfig
moduleofnode16,node18, ornodenextmakes.tsand.tsxfiles ES modules even without"type": "module", as upstream does;tscand tsx followpackage.json"type". - A
.ctsfile withimport/exportfails with one error on every load path, suggesting.mtsorimport x = require()/export =. tsc and tsx compile it to CommonJS, which needs an ESM-to-CommonJS transform oxc lacks. - An extensionless
#!/usr/bin/env vpxfile runs as JavaScript, because oxc-node picks the parser by extension; its syntax decides its module kind, as in Node.js. Shebang scripts keep their.tsextension. Options in a shebang need#!/usr/bin/env -S vpx --tsconfig ….
These oxc transformer issues found in end-to-end testing against tsx are still open:
| Issue | Effect under vpx |
|---|---|
| oxc#27741 | accessor fields are not lowered, so Node.js rejects them |
| oxc#27742 | Legacy decorators on static members run before those on later instance members, unlike tsc |
$ vpx ./scripts/missing.ts
error: vpx: Script not found: ./scripts/missing.ts
$ vpx -p cowsay ./a.ts
error: vpx: --package cannot be used when running a script
$ vpx --tsconfig x.json eslint .
error: vpx: --tsconfig can only be used when running a script
$ vpx ./a.ts # engines.node pins 20.18.0
error: Running scripts with vpx requires Node.js ^22.18.0 || ^24.11.0 || >=26.0.0 (current: v20.18.0)Other errors, including transform errors, come from Node.js and oxc-node unchanged; source maps point stack traces at the TypeScript source.
- Extend
vpx; leavevp nodeas plain Node.js.vpx ./a.tsreads likenpx tsx ./a.ts, the shebang is short and already onPATH, andvp nodestays the escape hatch for exact Node.js semantics. - oxc-node covers the syntax and resolution scripts rely on, shares Oxc with the rest of the toolchain, and is maintained in the same organization. See Alternatives.
- Exec Node.js in place. The global shim is native, so it can
execveafter runtime resolution:node's exact exit codes, signals, and TTY handling, no IPC, one Node.js startup saved. The local bin execs too on Unix (process.execve()), so a caller holding its PID holds the script's; it spawns only on Windows and when it has an IPC channel to relay. - Vite+-owned loader entries instead of
--import @oxc-node/core/register: one place for the version check, helper mapping, and binding loading; the oxc-node version follows the pinnedvite-plus; the hooks can change without changing the CLI contract; and the entries can later become a publicnode --import vite-plus/register. Why two entries: Loader Entries. - Loader in argv, not
NODE_OPTIONS, sofork()and workers inherit it and unrelated processes do not; tsx does the same. - Explicit paths and bare TypeScript names never download.
vpx ./sed.tsmust report a missing file, not run remote code under an unexpected name. - Loader from the project first, global second, as the global CLI already delegates JS entries; teams run the pinned
vite-plus, at the cost of the version-skew contract. - A project-local
vpxbin, sopackage.jsonscripts work without the global CLI (Project-LocalvpxBin). - Compile oxc-node into the binding rather than depend on
@oxc-node/core. The binding already links the same crates throughrolldown_binding(oxc-node is about 3,600 lines of glue), so no new platform packages and one oxc version for the whole toolchain. Cost: a new oxc-node tag must compile against the workspace's oxc, and a forwarded signature change needs a matching change inoxc_node.rs; either fails the build loudly, and a tag that needs a newer oxc than Rolldown's keeps the daily upgrade PR failing until Rolldown catches up. - Script mode requires the
engines.noderange, not everything withmodule.register(); Node.js 20 is end of life. - JavaScript files get the loader too, so
.jscan import.ts. - No experimental label. The vendored copy is pinned to a known commit and covered by Vite+'s own tests.
| Alternative | Why not |
|---|---|
| Node.js type stripping only | No enums, decorators, JSX, paths, or .js → .ts; adds nothing over vp node |
| Bundle tsx | esbuild as a second transformer in an Oxc toolchain; two processes and a signal relay; runs on whatever Node.js starts it |
| Pre-bundle with Rolldown | Changes import.meta.url and __dirname, breaks computed dynamic imports, writes temp files |
Depend on @oxc-node/core from npm |
A second native addon with its own 17-target matrix (about 4 MB each); helper mapping still needed; oxc version floats independently |
Use the oxnode CLI |
Spawns node from PATH, ignoring the managed runtime, and stays as a parent process that relays signals |
| Reimplement the hooks in TypeScript on the binding | Reimplements format detection, ESM-in-CommonJS re-parse, JSON modules, and Windows file URLs that oxc-node tests; more NAPI calls per file |
- Unit tests in
vpx_script.rs,vpx.rs, andpackages/cli/src/__tests__/vpx-script.spec.tsrun the shared case table, check that the Rust and TypeScript lists match, and cover the local bin's package-mode decision and which binaries it execs without/bin/sh(canExecDirectly), the loader fallback to the global install and its real path, the Node.js range (equal toengines.node), the sync-hooks cutoff, and the helper mapping.patch-oxc-node.spec.ts,sync-remote-deps.spec.ts, andtoolchain.spec.tscover the vendoring. - Snapshot fixtures under
crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/run in both flavors, except one local-only case for a binary that is not installed, and the global shim and the local bin record identical snapshots.command_vpx_scriptpins Node.js 22.18.0 (themodule.register()path) and covers syntax, resolution and--tsconfig, arguments and Node.js options, errors, module formats withfork(),Worker, and--test, TypeScript dependencies, tsconfig-driven transforms and JSX, shebangs,--watch(an import edit, a tsconfig edit, a created file, both--tsconfigpositions with an env file naming another config, the tsconfig edit on 24.12.0 for theregisterHooks()path, its help and errors, and Ctrl+C to the process group, acked once), a bare--experimental-config-fileon 26.12.0 and a separate.jsonconfig path on 22.18.0 (a script argument named--watch, then--tsconfigand the watcher after the flag or its path), IPC, and signals sent to the PID ofvpx(Unix), file names with#and%, and package mode.command_vpx_script_node22(22.23.2),_node24(24.12.0), and_node26(26.5.0) cover theregisterHooks()path, including CommonJS output that requires runtime helpers the project cannot resolve;_old_node(20.18.0) covers the version error.shim_system_first_fallbackchecks that script mode followsvp nodein system-first mode. Windows runs every case except watch mode, shebangs, IPC, and signals, which a.cmdshim cannot carry, and runs its own installed-binary case with a.cmdbinary.
Startup against tsx 4.23.15 on an Apple M4 Pro, median of 20 runs; bench/vpx-script.ts --vpx <path> generates the scenarios and the numbers. Scenarios: hello (one erasable .ts file), esm-app and cjs-app (an entry importing 300 modules with an enum, a class field, and a parameter property, in a "type": "module" package and in one without "type"), large-cjs and large-esm (one 1.8 MB .ts file in each package kind). "No cache" sets TSX_DISABLE_CACHE=1.
Each cell is vpx / tsx with a warm cache / tsx without a cache, in ms. The global vpx runs as one process, so it is compared with node --import tsx:
| Scenario | Node.js 22.18 | Node.js 24.12 | Node.js 26.5 |
|---|---|---|---|
hello |
51 / 68 / 75 | 34 / 46 / 63 | 37 / 38 / 61 |
esm-app |
94 / 124 / 141 | 75 / 94 / 217 | 77 / 92 / 216 |
cjs-app |
94 / 143 / 289 | 75 / 116 / 261 | 77 / 113 / 257 |
large-cjs |
121 / 122 / 229 | 100 / 90 / 273 | 93 / 76 / 258 |
large-esm |
103 / 107 / 200 | 84 / 75 / 177 | 86 / 69 / 173 |
The project-local vpx, which package.json scripts run, starts its own Node.js before it execs the script, as the tsx CLI starts a parent process, so it is compared with the tsx CLI:
| Scenario | Node.js 22.18 | Node.js 24.12 | Node.js 26.5 |
|---|---|---|---|
hello |
66 / 103 / 110 | 52 / 83 / 96 | 57 / 72 / 94 |
esm-app |
113 / 165 / 177 | 93 / 134 / 250 | 98 / 134 / 249 |
cjs-app |
112 / 184 / 327 | 93 / 155 / 296 | 99 / 155 / 291 |
large-cjs |
139 / 155 / 265 | 118 / 122 / 305 | 113 / 111 / 294 |
large-esm |
122 / 139 / 232 | 103 / 108 / 210 | 107 / 104 / 206 |
- The global shim's startup, Node.js resolution, and loader lookup take 5–10 ms, usually 8. The local bin's own Node.js startup adds 23–30 ms before it execs the script, against 32–42 ms for the
tsxCLI's parent process. Exec in place keeps startup within 2 ms of spawning the script; it saves the second process, not time. - On
hello,esm-app, andcjs-app,vpxbeats tsx's warm cache on every version: by 4–36% through the global shim and 22–40% through the local bin. - Without tsx's cache,
vpxtakes 33–71% less time everywhere. - tsx's cache wins only on the 1.8 MB files through the global shim on 24.12 and 26.5, by 9–17 ms, because
vpxtransforms them on every run; a persistent transform cache would only help such files. Against thetsxCLI, the local bin is faster or level. - On
hello, the loader alone beats plainnodetype stripping on every version (26–41 against 44–48 ms). With the shim, the globalvpxis 3 ms slower on 22.18 and 10–11 ms faster on 24.12 and 26.5. - Compiling oxc-node into the binding adds about 150 KB (0.3%) to the release
libvite_plus_cli.dylibon macOS arm64, against about 4.2 MB for a separate@oxc-node/coreplatform package; its load cost is within the noise above.
- No remote fallback for files: explicit paths, and bare names with TypeScript extensions, never reach
vp dlx. - Trusted loader: the hooks are compiled into the
vite-plusbinding and itsdist; runtime helpers resolve fromvite-plus's own@oxc-project/runtime, never from the project'snode_modules. - Shebang recursion guard for extensionless
#!/usr/bin/env vpxfiles. - Project code provides the loader, and every
node_modules/.binis prepended toPATH: the trust modelvpalready uses when it delegates to a project-localvite-plus. - Explicit configuration: the CLI sets
VP_SCRIPT_TSCONFIGonly with--tsconfig(and clears it otherwise). The public preload also accepts it directly and acceptsTSX_TSCONFIG_PATHas a fallback. These reach oxc-node throughinitializeLoader()without modifying the environment variables that other tools read.
Package mode through the global vpx is unchanged. What changes:
vpx <existing file with a script extension>runs the file. Previously an executable file with a shebang was exec'd through thePATHlookup, and a non-executable file fell through tovp dlx, which failed. A bare name matching both a file and a package (vpx highlight.jswith./highlight.jspresent) runs the file.- A first token starting with
-runs Node.js. Previously it reachedvp dlxas the package name and never ran a package;vpx --versionprinted the package manager's version. - An explicit path to a non-executable file, or to a directory without a
package.json, fails with avpxerror instead of a package manager error fromvp dlx. vite-plusgains avpxbin. A project with a differentvpxinnode_modules/.bin(the npmvpxpackage is a 0.0.1 placeholder without a bin) would see a bin conflict warning.- In
package.jsonscripts andvp run, that bin shadows the global shim:vpx <name>runs only binaries innode_modules/.bin. A name found only in global packages or onPATHfails with a hint, and a name found nowhere fails instead of being downloaded;pkg@version,--package, and--shell-modestill download.vpx --versionthere printsvite-plus v<version>. vite-plusgains@oxc-project/runtime(pure JavaScript) as a dependency;piratesis bundled. No new platform packages.
- Windows Ctrl+C through the
vp.exespawn-and-wait path:vp.exehandles Ctrl+C and Ctrl+Break while it waits for the child (vp_command::ConsoleCtrlGuardinspawn_tool,run_command, andexecute_with_terminal_guard, as thevpx.exetrampoline andTerminalStateGuardon Unix do), so the globalvpxandvp runexit after the script's own cleanup.vp_run_vpx_script_ctrl_c_cleanupchecks that the global vpx andvp runexit after a 300 msSIGINTcleanup, with the script's code. It runs the script as avp runtask because the snapshot runner starts steps with Ctrl+C ignored, which only vite-task clears.
vp migraterules for other runners:esnoandjitiremain unsupported. Migration handles compatibletsx,oxnode, and transpile-onlyts-nodecommands; see the migration rules.- TypeScript eval and REPL, once oxc-node transforms eval input.
- Opt-in transform cache, keyed like tsx's.
- Programmatic API: a
tsImport()equivalent exported fromvite-plus.
- tsx source (v4.23.15): https://github.com/privatenumber/tsx/tree/v4.23.15/src; docs: https://tsx.is
- oxc-node source: https://github.com/oxc-project/oxc-node (
packages/core/register.mjs,packages/core/esm.mjs,src/lib.rs); docs: https://oxc.rs/docs/guide/usage/oxc-node.html - Rolldown vendoring in this repository:
packages/tools/src/sync-remote-deps.ts,packages/tools/.upstream-versions.json,packages/cli/BUNDLING.md - Node.js TypeScript support: https://nodejs.org/api/typescript.html; module customization hooks: https://nodejs.org/api/module.html#customization-hooks