Skip to content

Commit b8a1bac

Browse files
committed
feat(migrate): migrate oxnode scripts to vpx
1 parent 102fe8e commit b8a1bac

21 files changed

Lines changed: 1667 additions & 725 deletions

File tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "@oxc-node/cli",
3+
"version": "1.0.0"
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "@oxc-node/core",
3+
"version": "1.0.0"
4+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "migration-oxnode",
3+
"type": "module",
4+
"scripts": {
5+
"dev": "oxnode watch --clear-screen=false ./scripts/seed.ts",
6+
"seed": "oxnode -C dev ./scripts/seed.ts",
7+
"loader": "node --import @oxc-node/core/register ./scripts/seed.ts"
8+
},
9+
"devDependencies": {
10+
"@oxc-node/cli": "file:.fixture/oxc-cli",
11+
"@oxc-node/core": "file:.fixture/oxc-core",
12+
"vite": "^7.0.0"
13+
}
14+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env oxnode
2+
const version: string = '1.0.0';
3+
console.log(version);
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
enum State {
2+
Ready = 'ready',
3+
}
4+
console.log(State.Ready);
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[[case]]
2+
name = "migration_oxnode_scripts"
3+
vp = "local"
4+
comment = "The oxc-node dependencies use local stub packages. Migrated scripts run the bundled loader."
5+
steps = [
6+
{ argv = ["vp", "migrate", "--no-interactive", "--no-hooks", "--no-agent", "--no-editor"], comment = "oxnode commands, loaders, and shebangs migrate to vpx" },
7+
["vpt", "print-file", "package.json"],
8+
["vpt", "print-file", "scripts/release.ts"],
9+
{ argv = ["vp", "run", "seed"], comment = "the migrated command runs TypeScript with Node conditions" },
10+
{ argv = ["vp", "run", "loader"], comment = "the migrated Node loader command runs without standalone oxc-node" },
11+
]
12+
13+
[[case]]
14+
name = "migration_oxnode_kept"
15+
vp = "local"
16+
steps = [
17+
{ argv = ["vpt", "json-edit", "package.json", "scripts.node-watch", "oxnode --watch ./scripts/seed.ts"], snapshot = false },
18+
{ argv = ["vpt", "write-file", "scripts/importer.ts", "import '@oxc-node/core/register';\n"], snapshot = false },
19+
{ argv = ["vp", "migrate", "--no-interactive", "--no-hooks", "--no-agent", "--no-editor"], comment = "Node watch mode and remaining loader imports keep the dependencies" },
20+
["vpt", "print-file", "package.json"],
21+
]
22+
23+
[[case]]
24+
name = "migration_oxnode_already_vite_plus"
25+
vp = "local"
26+
steps = [
27+
{ argv = ["vpt", "json-edit", "package.json", "devDependencies.vite-plus", "latest"], snapshot = false },
28+
{ argv = ["vp", "migrate", "--no-interactive"], comment = "a plain upgrade leaves oxnode migration to --full" },
29+
{ argv = ["vp", "migrate", "--no-interactive", "--full", "--no-hooks", "--no-agent", "--no-editor"], comment = "--full migrates oxnode on an existing Vite+ project" },
30+
["vpt", "print-file", "package.json"],
31+
["vp", "run", "seed"],
32+
]
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# migration_oxnode_already_vite_plus
2+
3+
## `vpt json-edit package.json devDependencies.vite-plus latest`
4+
5+
6+
## `vp migrate --no-interactive`
7+
8+
a plain upgrade leaves oxnode migration to --full
9+
10+
```
11+
VITE+ - The Unified Toolchain for the Web
12+
13+
◇ Updated . to Vite+ <version>
14+
• Node <version> pnpm <version>
15+
• Dependencies:
16+
vite-plus latest → <version>
17+
vite → <version>
18+
• Package manager settings configured
19+
• Skipped editor, hooks, and lint setup. Run `vp migrate --full` to apply them.
20+
```
21+
22+
## `vp migrate --no-interactive --full --no-hooks --no-agent --no-editor`
23+
24+
--full migrates oxnode on an existing Vite+ project
25+
26+
```
27+
VITE+ - The Unified Toolchain for the Web
28+
29+
▲ No package manager is declared in package.json; using pnpm for this migration without adding a pin. Run `vp env pin` to declare it explicitly.
30+
● oxnode scripts detected. Auto-migrating to vpx...
31+
◇ Updated . to Vite+ <version>
32+
• Node <version> pnpm <version>
33+
• Dependencies:
34+
vite → <version>
35+
• oxnode scripts migrated to `vpx`
36+
```
37+
38+
## `vpt print-file package.json`
39+
40+
```
41+
{
42+
"devDependencies": {
43+
"vite": "catalog:",
44+
"vite-plus": "catalog:"
45+
},
46+
"name": "migration-oxnode",
47+
"scripts": {
48+
"dev": "vpx --watch --clear-screen=false ./scripts/seed.ts",
49+
"loader": "vpx ./scripts/seed.ts",
50+
"seed": "vpx -C dev ./scripts/seed.ts"
51+
},
52+
"type": "module"
53+
}
54+
```
55+
56+
## `vp run seed`
57+
58+
```
59+
$ vpx -C dev ./scripts/seed.ts ⊘ cache disabled
60+
ready
61+
```
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# migration_oxnode_kept
2+
3+
## `vpt json-edit package.json scripts.node-watch 'oxnode --watch ./scripts/seed.ts'`
4+
5+
6+
## `vpt write-file scripts/importer.ts 'import '\''@oxc-node/core/register'\'';
7+
'`
8+
9+
10+
## `vp migrate --no-interactive --no-hooks --no-agent --no-editor`
11+
12+
Node watch mode and remaining loader imports keep the dependencies
13+
14+
```
15+
VITE+ - The Unified Toolchain for the Web
16+
17+
● oxnode scripts detected. Auto-migrating to vpx...
18+
◇ Migrated . to Vite+ <version>
19+
• Node <version> pnpm <version>
20+
• 1 config update applied
21+
• oxnode scripts migrated to `vpx`
22+
! Warnings:
23+
- Kept oxnode in package.json scripts "node-watch": oxnode --watch starts the Node.js watcher, while `vpx --watch` uses its own watcher; use oxnode watch to migrate it.
24+
- Kept the @oxc-node/cli / @oxc-node/core devDependency in package.json: `scripts` in package.json still uses oxnode.
25+
```
26+
27+
## `vpt print-file package.json`
28+
29+
```
30+
{
31+
"devDependencies": {
32+
"@oxc-node/cli": "file:.fixture/oxc-cli",
33+
"@oxc-node/core": "file:.fixture/oxc-core",
34+
"vite": "catalog:",
35+
"vite-plus": "catalog:"
36+
},
37+
"name": "migration-oxnode",
38+
"scripts": {
39+
"dev": "vpx --watch --clear-screen=false ./scripts/seed.ts",
40+
"loader": "vpx ./scripts/seed.ts",
41+
"node-watch": "oxnode --watch ./scripts/seed.ts",
42+
"seed": "vpx -C dev ./scripts/seed.ts"
43+
},
44+
"type": "module"
45+
}
46+
```
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# migration_oxnode_scripts
2+
3+
The oxc-node dependencies use local stub packages. Migrated scripts run the bundled loader.
4+
5+
## `vp migrate --no-interactive --no-hooks --no-agent --no-editor`
6+
7+
oxnode commands, loaders, and shebangs migrate to vpx
8+
9+
```
10+
VITE+ - The Unified Toolchain for the Web
11+
12+
● oxnode scripts detected. Auto-migrating to vpx...
13+
◇ Migrated . to Vite+ <version>
14+
• Node <version> pnpm <version>
15+
• 1 config update applied
16+
• oxnode scripts migrated to `vpx`
17+
```
18+
19+
## `vpt print-file package.json`
20+
21+
```
22+
{
23+
"name": "migration-oxnode",
24+
"type": "module",
25+
"scripts": {
26+
"dev": "vpx --watch --clear-screen=false ./scripts/seed.ts",
27+
"seed": "vpx -C dev ./scripts/seed.ts",
28+
"loader": "vpx ./scripts/seed.ts"
29+
},
30+
"devDependencies": {
31+
"vite": "catalog:",
32+
"vite-plus": "catalog:"
33+
}
34+
}
35+
```
36+
37+
## `vpt print-file scripts/release.ts`
38+
39+
```
40+
#!/usr/bin/env vpx
41+
const version: string = '1.0.0';
42+
console.log(version);
43+
```
44+
45+
## `vp run seed`
46+
47+
the migrated command runs TypeScript with Node conditions
48+
49+
```
50+
$ vpx -C dev ./scripts/seed.ts ⊘ cache disabled
51+
ready
52+
```
53+
54+
## `vp run loader`
55+
56+
the migrated Node loader command runs without standalone oxc-node
57+
58+
```
59+
$ vpx ./scripts/seed.ts ⊘ cache disabled
60+
ready
61+
```

‎docs/guide/migrate-rules.md‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ Migration rewrites commands provided by the Vite+ toolchain in `package.json` sc
262262
| `prettier` | `vp fmt`, when its optional migration runs |
263263
| `tsup` | `vp pack`, when its optional migration runs |
264264
| `tsx` | `vpx`, when its optional migration runs |
265+
| `oxnode` | `vpx`, when its optional migration runs |
265266

266267
For commands launched through `bunx`, migration preserves `bunx` and its `--bun` flag (keeping the user's chosen runtime) and rewrites only the managed command. tsx is the exception: `bunx tsx` becomes `vpx`, and `bunx --bun tsx` keeps tsx (see [tsx to `vpx`](#tsx-to-vpx)). This also works when `bunx` follows a command-launcher delimiter such as `run` or `--`:
267268

@@ -295,6 +296,21 @@ Migration removes the `tsx` devDependency only when nothing uses tsx anymore: no
295296

296297
See [Coming from tsx](/guide/vpx#coming-from-tsx) for the other differences.
297298

299+
### oxnode to `vpx`
300+
301+
Migration offers to replace `oxnode`, the command from `@oxc-node/cli`, with `vpx`. It rewrites `package.json` scripts, lint-staged tasks in `package.json` and JSON files, and `#!/usr/bin/env oxnode` shebangs. On a project that already uses Vite+, run `vp migrate --full` to include this migration.
302+
303+
| Before | After |
304+
| --------------------------------------------------------- | --------------------------------------------------- |
305+
| `oxnode ./scripts/seed.ts` | `vpx ./scripts/seed.ts` |
306+
| `oxnode -C dev ./build.ts` | `vpx -C dev ./build.ts` |
307+
| `oxnode watch --include "config/*.json" ./server.ts` | `vpx --watch --include "config/*.json" ./server.ts` |
308+
| `node --import @oxc-node/core/register ./scripts/seed.ts` | `vpx ./scripts/seed.ts` |
309+
310+
The migration keeps commands that need different runtime behavior. In particular, `oxnode --watch` uses Node.js's watcher, while `oxnode watch` and `vpx --watch` use oxc-node's watcher. Commands that explicitly set `OXC_TRANSFORM_ALL` to anything other than `typescript` also stay unchanged. Commands that read an environment file stay unchanged because it can select a different transform mode. Migration checks the named script and local preloads for standalone oxc-node API usage, which would configure a different loader after migration; it does not follow their imports.
311+
312+
The `@oxc-node/cli` and `@oxc-node/core` development dependencies are removed only when no remaining use needs them. Loader references, API imports, CI commands, hooks, and shell scripts can keep these dependencies installed. Runtime and peer dependencies stay in place.
313+
298314
## Continuous Integration Rules
299315

300316
Migration replaces exact `voidzero-dev/setup-vp@v1` references in GitHub Actions workflows and composite actions under `.github` with the latest exact `setup-vp` release known to that Vite+ version. The frozen `v1` tag does not receive new releases. Existing exact versions and commit SHAs are left unchanged.

0 commit comments

Comments
 (0)