Skip to content
GitHubBlueskydev.toRSS

02Set up the workspace

Move an existing workspace to vx

Bring your tasks over with one command. vx reads what you already have and writes a vx.config.ts for each package.

Terminal window
bunx @vzn/vx init --native
Read

Before

turbo.json
"build": {
"dependsOn": ["^build"],
"inputs": ["src/**"],
"outputs": ["dist/**"]
}
packages/ui/package.json
"build": "vite build"

After

packages/ui/vx.config.ts
build: {
exec: {
command: 'vite build',
},
dependsOn: ['^build'],
inputs: { files: ['src/**', 'package.json'] },
outputs: { files: ['dist/**'] },
cache: true,
},

Two files became one. The command, the order and the outputs stay. The inputs gain package.json, since the script lives there.

Already have .vx/workspace.ts from the Quickstart? bunx @vzn/vx-migrate turns your other scripts into tasks.

Find your starting point:

You have Read
turbo.json Turborepo
nx.json or lerna.json Nx
vite-plus in the root package.json Vite Task
only package.json scripts Scripts only
nothing yet the Quickstart
  1. Write the configs. Run bunx @vzn/vx init --native at the workspace root. It never overwrites a file unless you add --force.
  2. Fill the TODOs. Search for TODO(vx-migrate). Each one marks a choice vx could not make for you, such as which files a task reads.
  3. Run your build. vx run build --all builds every task once. Run it again and every task is up to date.
  4. Delete the old config. Once vx runs what turbo run build or nx run-many -t build did, delete turbo.json or nx.json.

You can now move a whole workspace in four steps, and know when the old config can go.

vx init installs @vzn/vx, then writes these files:

  • Directory.vx/
    • workspace.ts the plugins: your lockfile and others
    • projects.lock every task, as vx reads it on each run
    • dependencies.lock
    • .gitignore keeps .vx/cache and .vx/tmp out of git
  • Directorypackages/
    • Directoryui/
      • vx.config.ts one per package
      • vx.lock.json what vx lock read, for review
    • Directoryweb/
      • vx.config.ts
      • vx.lock.json
  • turbo.json delete it in step 4

Commit all of it. A teammate’s checkout then runs the same tasks.

Check yourself You edited packages/ui/vx.config.ts, then ran vx init --native again. Is your edit lost?

No. init never overwrites a file unless you pass --force. Run vx lock instead to record your edit.

You can now tell every file init writes apart, and know which ones to commit.

No Turborepo or Nx? Each package.json script becomes a task. --dry shows the plan and writes nothing:

Terminal window
bunx @vzn/vx-migrate --dry
Terminal window
vx-migrate 0.0.0
from package.json scripts
dry run nothing written
tasks 5 clean · 2 todo
todo @demo/ui#build, @demo/web#build:
cache: add `inputs: { files: ['**'] }, outputs: { files: ['dist/**'] }, cache: true` with this package's real outputs, and narrow the inputs to what it reads — without it the task always runs, and so does every task that depends on it; a block with EMPTY outputs would be a cached no-op, not an uncached task
files packages/ui/vx.config.ts
packages/web/vx.config.ts
.vx/workspace.ts
.vx/.gitignore
note each script became a task with its command verbatim; caching needs declared inputs and outputs, so no task got `cache: true`
next vx run build --all

Read the todo row: both build tasks wait for you. dev runs vite, so it became a persistent task.

You can now see every script as a task before one file is written.

A TODO(vx-migrate) sits above each task vx could not finish. Replace it with what the task reads and writes:

packages/web/vx.config.ts
// TODO(vx-migrate): cache: add `inputs: { files: ['**'] }, outputs: { files: ['dist/**'] }, cache: true` …
build: {
// inputs: { files: ['**'] }, outputs: { files: ['dist/**'] }, cache: true,
inputs: { files: ['src/**', 'index.html', 'vite.config.ts'] },
outputs: { files: ['dist/**'] },
cache: true,
exec: {
command: 'vite build',
},
dependsOn: ['^build'],
},

Then record the change and build twice:

Terminal window
vx lock
vx run build --all
vx run build --all
Terminal window
Summary vx 0.0.0
projects ▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰
2 in run · 2 total
tasks ▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰
2 success · 2 total
cache ▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰
local 2✓
info 4 workers · local cache · run 01a20a07-a344-75e4-9b14-2c18e759b5b2
time 36ms

Read the cache row: 2✓. Both builds are up to date, so nothing ran.

Check yourself Why does vx not guess which files vite build reads?

A guess can miss a file. Then an edit to it would not change the key, and vx would replay an old build. vx keys only what you list, so you decide.

You can now turn any migrated task into a cached one.

In a workspace with turbo.json (or turbo.jsonc), vx init --native writes a task for each Turbo task.

PatternsWhat init prints and writes

The samples here convert a small Turborepo workspace: packages/app depends on packages/lib, and npm keeps the lockfile.

Terminal window
bunx @vzn/vx init --native
Terminal window
vx-migrate 0.0.0
from turbo.json
ran npm install -D @vzn/vx-lockfile @vzn/vx-history
tasks 3 clean
files packages/app/vx.config.ts
packages/lib/vx.config.ts
.vx/workspace.ts
.vx/.gitignore
lock 2 project configs → .vx/projects.lock, .vx/dependencies.lock
note Turbo passes its builtin env (HOME, CI, PATH, VERCEL_* and the rest) to each task; vx passes the names a task lists — add the ones a task reads to exec.env.passThrough
no package has a file the outputs of build ("dist/**") match yet, so they were not checked: a vx run fails when it misses an output path or writes none of its outputs; a wildcard may match nothing beside one that matched (Turbo cached what was present) — keep only the outputs each command always writes
next vx run build --all

Read the note lines: a task sees only the environment variables it lists.

This is packages/lib/vx.config.ts, as written:

import type { ProjectConfig } from '@vzn/vx/config'
export default {
tasks: {
build: {
exec: {
command: 'mkdir -p dist && cp src/*.js dist/',
},
dependsOn: ['^build'],
inputs: {
files: ['src/**', 'package.json'],
},
outputs: {
files: ['dist/**'],
},
cache: true,
},
},
} satisfies ProjectConfig

And .vx/workspace.ts:

import type { WorkspaceConfig } from '@vzn/vx/config'
import { vxHistory } from '@vzn/vx-history'
import { npm } from '@vzn/vx-lockfile'
export default {
plugins: [
npm(),
vxHistory(),
],
} satisfies WorkspaceConfig

npm() reads your lockfile, so ^build builds a package’s dependencies first; a bun.lock gets bun(). vxHistory() uses past run times to start the slowest work first.

turbo.json’s global keys (globalDependencies, globalEnv) go onto no task. Each task gets a TODO instead, so you list what it reads.

PatternsYour Turborepo commands in vx
Turborepo vx
turbo run build vx run build --all
turbo run build --filter=@demo/* vx run build --filter "@demo/*"
turbo run build --affected vx run build --affected (turbo() takes TURBO_SCM_BASE, or GitHub Actions’ base, as Turbo does; a TURBO_SCM_HEAD other than the checked-out commit is a warning)
turbo run build --force, TURBO_FORCE=true vx run build --force; turbo() reads TURBO_FORCE too
turbo run build --continue=dependencies-successful vx run build: by default a failure skips only its dependents
turbo run build (stops at the first failure) vx run build --fail-fast, which also stops the tasks still running
TURBO_TOKEN remote cache turboCache() reads the same variables
PatternsCheck the mapping first

vx init --keep writes no configs. Its .vx/workspace.ts reads turbo.json through turbo(), so you can check that vx sees the same tasks. In the same workspace:

Terminal window
bunx @vzn/vx init --keep
import type { WorkspaceConfig } from '@vzn/vx/config'
import { vxHistory } from '@vzn/vx-history'
import { npm } from '@vzn/vx-lockfile'
import { turbo } from '@vzn/vx-migrate'
export default {
plugins: [
turbo(),
npm(),
vxHistory(),
],
} satisfies WorkspaceConfig
Terminal window
vx-migrate 0.0.0
from turbo.json, run by turbo() from @vzn/vx-migrate
ran npm install -D @vzn/vx-lockfile @vzn/vx-history
files .vx/workspace.ts
.vx/.gitignore
lock 0 project configs → .vx/projects.lock, .vx/dependencies.lock (and the tasks a plugin maps for app, lib)
note a temporary start: vx init --native writes native config
next vx run build --all

It is a check, not a way to keep running the old config. Then bunx @vzn/vx-migrate writes the configs and drops the plugin.

Where the workspace uses a Turbo remote cache, the file declares turboCache() too, and init says why:

turboCache(): .github/workflows/ci.yml sets TURBO_TOKEN, so vx shares that remote cache (token: the variable, else the OS keychain).

Detailsturbo.json, key by key
Turborepo (turbo.json) vx (vx.config.ts)
tasks / pipeline tasks
dependsOn dependsOn, the same 'build', '^build', 'pkg#build' syntax
inputs inputs.files; a glob that reaches a nested workspace package also in inputs.workspaceFiles
outputs outputs.files, plus the .tsbuildinfo a tsc -b writes outside them; a path, or every output of a task, that matches no file yet is named
env inputs.env and exec.env.passThrough
passThroughEnv exec.env.passThrough
cache: false leave out cache: the task runs every time
persistent: true exec.persistent: { … }
with dependsOn a persistent sidecar, started beside the task
interactive: true exec.interactive: true: the task gets the terminal, alone
interruptible nothing: vx watch keeps a persistent task up and restarts it only when its config changes or it dies
tags nothing: labels Turbo keeps out of the hash and the behaviour
experimentalCI nothing: Turbo reads it for external CI tooling and acts on nothing
outputLogs (Turbo 1: outputMode) "new-only" is the default; other values are the run’s --output-logs
dotEnv (Turbo 1), a .env input inputs.runtime: a probe that prints every .env file’s name and bytes, because a gitignored .env is invisible to a git glob (a written config names it at its top: dotenvFiles, dotenvFilesDeep, and dotenvRootFiles for the root globs); a task’s root one ($TURBO_ROOT$/.env) is inputs.workspaceRuntime, a probe of only the files its globs name
the root package.json’s engines, the root’s dependencies and Turbo’s own env, which Turbo hashes into every task nothing: vx keys a task on what it declares
an input path git ignores (config.local.json) inputs.workspaceRuntime: a probe that prints the file’s name and bytes, since core refuses a file input git ignores; a gitignored file a glob matches is not keyed
command (Turbo 2.11) exec.command (the argv, quoted); null or [] is no task
description description
extends nothing: a package task merges over the root’s, field by field
$TURBO_ROOT$/file inputs.workspaceFiles / outputs.workspaceFiles
globalDependencies / globalEnv / globalPassThroughEnv (and Turbo 1’s globalDotEnv) nothing: no task carries them, and each task with a command gets a TODO to list what it reads

The command itself comes from your package.json script, with its pre<name> / post<name> hooks added around it.

You can now turn a Turborepo workspace into vx configs and type the vx command for each Turbo one.

In a workspace with nx.json, vx init --native reads nx graph, so keep Nx installed while it runs. Lerna 6+ works the same way.

PatternsWhat init prints and writes

The samples here convert a small Nx workspace: packages/app depends on packages/lib, each build an nx:run-commands target, and npm keeps the lockfile.

Terminal window
bunx @vzn/vx init --native
Terminal window
vx-migrate 0.0.0
from nx graph
ran npm install -D @vzn/vx-lockfile @vzn/vx-history
tasks 2 clean
files packages/app/vx.config.ts
packages/lib/vx.config.ts
.vx/workspace.ts
.vx/.gitignore
lock 2 project configs → .vx/projects.lock, .vx/dependencies.lock
note migrating from the resolved project-graph snapshot — plugin-inferred targets are frozen as static config; `nx:run-commands` targets are their shell lines
Nx caches whichever of a target's outputs exist; vx fails a task when one of its literal output paths matches nothing ("outputs matched no files"; a wildcard may match nothing beside one that matched): 2 tasks declare literal outputs — remove each path its command never writes, or make it a wildcard
next vx run build --all

This is packages/lib/vx.config.ts, as written:

import type { ProjectConfig } from '@vzn/vx/config'
export default {
tasks: {
build: {
exec: {
command: 'mkdir -p dist && cp src/index.js dist/lib.js',
},
inputs: {
files: ['src/**/*'],
},
outputs: {
files: ['dist'],
},
cache: true,
},
},
} satisfies ProjectConfig

The note line says how each Nx target became a task:

  • a target an Nx plugin infers is written out as a plain task;
  • an nx:run-commands target becomes its shell line;
  • any other executor runs through nx-exec (below);
  • a target with .env files runs through nx-env.
PatternsCheck the mapping first

vx init --keep declares nx() instead of turbo(). In the same workspace:

Terminal window
bunx @vzn/vx init --keep
import type { WorkspaceConfig } from '@vzn/vx/config'
import { vxHistory } from '@vzn/vx-history'
import { npm } from '@vzn/vx-lockfile'
import { nx } from '@vzn/vx-migrate'
export default {
plugins: [
nx(),
npm(),
vxHistory(),
],
} satisfies WorkspaceConfig
Terminal window
vx-migrate 0.0.0
from nx.json, run by nx() from @vzn/vx-migrate
ran npm install -D @vzn/vx-lockfile @vzn/vx-history
files .vx/workspace.ts
.vx/.gitignore
lock 0 project configs → .vx/projects.lock, .vx/dependencies.lock (and the tasks a plugin maps for app, lib)
note a temporary start: vx init --native writes native config
next vx run build --all
PatternsExecutors and nx-exec

An executor target is written as an nx-exec line: the executor runs as itself through Nx’s runExecutor. Keep Nx and @vzn/vx-migrate installed until you rewrite it.

test: { exec: { command: `nx-exec @nx/jest:jest --project ui --target test --options '{"jestConfig":"packages/ui/jest.config.ts"}'` } }

To drop Nx, rewrite each one as the command it wraps:

test: { exec: { command: `nx-exec @nx/vite:test --project ui --target test` } }
test: { exec: { command: 'vitest run' } }

Generators and Nx Console have no vx equivalent; keep Nx for those. Module-boundary tags become run.rules.dependencies, checked by vx lock. Source imports stay your linter’s job.

PatternsYour Nx commands in vx
Nx vx
nx build @demo/web vx run @demo/web#build
nx run @demo/web:build:production vx run @demo/web#build:production
nx run-many -t build vx run build --all
nx affected -t test vx run test --affected (nx() takes NX_BASE or defaultBase as its base)
nx graph vx run build --all --dry --format json (tasks and their deps), and the graph explorer
nx reset vx cache clean clears it all; --older-than <age> trims it; there is no daemon
Nx Cloud cache nxCache() for a self-hosted Nx cache
DetailsNx, key by key
Nx vx
a project’s targets tasks
dependsOn (^build, @demo/web:build) dependsOn (^build, @demo/web#build)
configurations one task per configuration: build, build:ci
inputs / namedInputs inputs.files
{workspaceRoot}/file inputs.workspaceFiles
{ "env": "VAR" } inputs.env and exec.env.passThrough
{ "runtime": "<cmd>" } inputs.workspaceRuntime: it runs at the workspace root, as Nx’s does
{ "json": "<file>", "fields": … } the whole file in files / workspaceFiles: a superset of the fields
outputs outputs.files (or workspaceFiles for dist/<project>)

You can now turn an Nx workspace into vx configs, then drop Nx one executor at a time.

When the root package.json lists vite-plus, bunx @vzn/vx-migrate writes a config per package from run.tasks and the scripts.

PatternsFrom Vite Task
Terminal window
bunx @vzn/vx-migrate --from vite-task

--from vite-task matters only when turbo.json or Nx is there too. Vite Task traces the files a task touches; vx needs them listed.

A task with no cache.input and cache.output runs uncached until you fill its TODO(vx-migrate). The @vzn/vx-migrate page has the full mapping.

You can now bring every run.tasks entry and script over from Vite Task.

  • A project is missing. A project is a directory holding a vx.config.ts. vx-migrate writes one for every project, even an Nx project outside your workspace globs.
  • A task always runs. vx caches only a task with cache: true. A Turbo task with cache: false gets none.
  • A variable is missing in the command. List it in exec.env.passThrough. See Environment variables.
  • vx run build ran one package. Without --all, vx runs the package you are in.

You can now fix the four surprises a fresh migration can bring.

DetailsEvery option

bunx @vzn/vx-migrate takes these flags. vx init passes --dry, --format, --force, --mjs, --native and --keep through to it.

Flag What it does Default
--native writes a vx.config.ts per package asked in a terminal; native without one
--keep writes only .vx/workspace.ts, declaring turbo() or nx() off
--from <source> picks turbo, nx, vite-task or scripts when several are there found in that order, else scripts
--dry prints the files and the report; writes and installs nothing off
--format json with --dry, prints the plan as one JSON document pretty
--force overwrites a vx.config.* already there off
--mjs writes vx.config.mjs with no type import .ts
--no-install installs nothing and skips vx lock off
--help, -h prints the usage

The --keep plugins take these options:

Option What it does Default
turbo({ root }) the directory holding turbo.json the workspace root
nx({ root }) the directory holding nx.json the workspace root
nx({ graph }) a graph file from nx graph --file, read instead of running nx none
nx({ executors }) your own executors as commands, by executor name none: they run through nx-exec

turboCache() and nxCache() are on the Remote cache page.

NextTasks →Define and read the tasks the migration wrote.
Turborepo, Nx and other product names are trademarks of their owners. vx is not affiliated with or endorsed by them.