vite-plus 0.1.13 → 0.1.14-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +12 -0
- package/README.md +4 -0
- package/dist/global/{agent-BuEmv_K7.js → agent-DTz-Dh1r.js} +12 -30
- package/dist/global/{cli-truncate-BmIULUG7.js → cli-truncate-Da6Y8aM8.js} +2 -2
- package/dist/global/compat-Ch3iWOnQ.js +14 -0
- package/dist/global/config.js +3 -2
- package/dist/global/create.js +13 -4
- package/dist/global/{log-update-Beldo2tV.js → log-update-C8WCYCbc.js} +3 -3
- package/dist/global/migrate.js +22 -5
- package/dist/global/{package-D0VpX-8d.js → package-Y1UTfJnZ.js} +26 -1
- package/dist/global/report-C7xbSNED.js +28 -0
- package/dist/global/{slice-ansi-1i6Zdm-R.js → slice-ansi-Fap0ehe9.js} +1 -1
- package/dist/global/staged.js +62 -6
- package/dist/global/version.js +1 -1
- package/dist/global/{workspace-CVWspacc.js → workspace-BlrOxcHM.js} +3 -3
- package/dist/global/wrap-ansi-Ou9oAs-a.js +3 -0
- package/dist/global/{wrap-ansi-CnYUWev2.js → wrap-ansi-eywLlPVQ.js} +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/migration/migrator.js +26 -11
- package/dist/pack-bin.js +3 -1
- package/dist/resolve-vite-config.d.ts +9 -1
- package/dist/resolve-vite-config.js +78 -1
- package/dist/utils/constants.d.ts +6 -0
- package/dist/utils/constants.js +8 -0
- package/dist/utils/editor.js +1 -1
- package/dist/utils/package.d.ts +6 -0
- package/dist/utils/package.js +19 -0
- package/package.json +12 -12
- package/skills/vite-plus/docs/config/build.md +21 -0
- package/skills/vite-plus/docs/config/fmt.md +18 -0
- package/skills/vite-plus/docs/config/index.md +31 -0
- package/skills/vite-plus/docs/config/lint.md +24 -0
- package/skills/vite-plus/docs/config/pack.md +17 -0
- package/skills/vite-plus/docs/config/run.md +231 -0
- package/skills/vite-plus/docs/config/staged.md +15 -0
- package/skills/vite-plus/docs/config/test.md +18 -0
- package/skills/vite-plus/docs/guide/build.md +40 -0
- package/skills/vite-plus/docs/guide/cache.md +119 -0
- package/skills/vite-plus/docs/guide/check.md +41 -0
- package/skills/vite-plus/docs/guide/ci.md +64 -0
- package/skills/vite-plus/docs/guide/commit-hooks.md +51 -0
- package/skills/vite-plus/docs/guide/create.md +88 -0
- package/skills/vite-plus/docs/guide/dev.md +24 -0
- package/skills/vite-plus/docs/guide/env.md +84 -0
- package/skills/vite-plus/docs/guide/fmt.md +41 -0
- package/skills/vite-plus/docs/guide/ide-integration.md +36 -0
- package/skills/vite-plus/docs/guide/implode.md +23 -0
- package/skills/vite-plus/docs/guide/index.md +93 -0
- package/skills/vite-plus/docs/guide/install.md +130 -0
- package/skills/vite-plus/docs/guide/lint.md +50 -0
- package/skills/vite-plus/docs/guide/migrate.md +174 -0
- package/skills/vite-plus/docs/guide/pack.md +61 -0
- package/skills/vite-plus/docs/guide/run.md +292 -0
- package/skills/vite-plus/docs/guide/test.md +35 -0
- package/skills/vite-plus/docs/guide/troubleshooting.md +71 -0
- package/skills/vite-plus/docs/guide/upgrade.md +28 -0
- package/skills/vite-plus/docs/guide/vpx.md +66 -0
- package/skills/vite-plus/docs/guide/why.md +39 -0
- package/templates/monorepo/tsconfig.json +2 -2
- package/dist/global/wrap-ansi-DAqB-SZm.js +0 -3
- package/dist/oxfmt-config.d.ts +0 -1
- package/dist/oxfmt-config.js +0 -0
- /package/dist/global/{src-FkMgH-SM.js → src-B-pcmd0F.js} +0 -0
- /package/dist/global/{strip-ansi-DbamwI77.js → strip-ansi-CE-VDMdw.js} +0 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# Installing Dependencies
|
|
2
|
+
|
|
3
|
+
`vp install` installs dependencies using the current workspace's package manager.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Use Vite+ to manage dependencies across pnpm, npm, and Yarn. Instead of switching between `pnpm install`, `npm install`, and `yarn install`, you can keep using `vp install`, `vp add`, `vp remove`, and the rest of the Vite+ package-management commands.
|
|
8
|
+
|
|
9
|
+
Vite+ detects the package manager from the workspace root in this order:
|
|
10
|
+
|
|
11
|
+
1. `packageManager` in `package.json`
|
|
12
|
+
2. `pnpm-workspace.yaml`
|
|
13
|
+
3. `pnpm-lock.yaml`
|
|
14
|
+
4. `yarn.lock` or `.yarnrc.yml`
|
|
15
|
+
5. `package-lock.json`
|
|
16
|
+
6. `.pnpmfile.cjs` or `pnpmfile.cjs`
|
|
17
|
+
7. `yarn.config.cjs`
|
|
18
|
+
|
|
19
|
+
If none of those files are present, `vp` falls back to `pnpm` by default. Vite+ automatically downloads the matching package manager and uses it for the command you ran.
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
vp install
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Common install flows:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
vp install
|
|
31
|
+
vp install --frozen-lockfile
|
|
32
|
+
vp install --lockfile-only
|
|
33
|
+
vp install --filter web
|
|
34
|
+
vp install -w
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
`vp install` maps to the correct underlying install behavior for the detected package manager, including the right lockfile flags for pnpm, npm, and Yarn.
|
|
38
|
+
|
|
39
|
+
## Global Packages
|
|
40
|
+
|
|
41
|
+
Use the `-g` flag for installing, updating or removing globally installed packages:
|
|
42
|
+
|
|
43
|
+
- `vp install -g <pkg>` installs a package globally
|
|
44
|
+
- `vp uninstall -g <pkg>` removes a global package
|
|
45
|
+
- `vp update -g [pkg]` updates one global package or all of them
|
|
46
|
+
- `vp list -g [pkg]` lists global packages
|
|
47
|
+
|
|
48
|
+
## Managing Dependencies
|
|
49
|
+
|
|
50
|
+
Vite+ provides all the familiar package management commands:
|
|
51
|
+
|
|
52
|
+
- `vp install` installs the current dependency graph for the project
|
|
53
|
+
- `vp add <pkg>` adds packages to `dependencies`, use `-D` for `devDependencies`
|
|
54
|
+
- `vp remove <pkg>` removes packages
|
|
55
|
+
- `vp update` updates dependencies
|
|
56
|
+
- `vp dedupe` reduces duplicate dependency entries where the package manager supports it
|
|
57
|
+
- `vp outdated` shows available updates
|
|
58
|
+
- `vp list` shows installed packages
|
|
59
|
+
- `vp why <pkg>` explains why a package is present
|
|
60
|
+
- `vp info <pkg>` shows registry metadata for a package
|
|
61
|
+
- `vp link` and `vp unlink` manage local package links
|
|
62
|
+
- `vp dlx <pkg>` runs a package binary without adding it to the project
|
|
63
|
+
- `vp pm <command>` forwards a raw package-manager-specific command when you need behavior outside the normalized `vp` command set
|
|
64
|
+
|
|
65
|
+
### Command Guide
|
|
66
|
+
|
|
67
|
+
#### Install
|
|
68
|
+
|
|
69
|
+
Use `vp install` when you want to install exactly what the current `package.json` and lockfile describe.
|
|
70
|
+
|
|
71
|
+
- `vp install` is the standard install command
|
|
72
|
+
- `vp install --frozen-lockfile` fails if the lockfile would need changes
|
|
73
|
+
- `vp install --no-frozen-lockfile` allows lockfile updates explicitly
|
|
74
|
+
- `vp install --lockfile-only` updates the lockfile without performing a full install
|
|
75
|
+
- `vp install --prefer-offline` and `vp install --offline` prefer or require cached packages
|
|
76
|
+
- `vp install --ignore-scripts` skips lifecycle scripts
|
|
77
|
+
- `vp install --filter <pattern>` scopes install work in monorepos
|
|
78
|
+
- `vp install -w` installs in the workspace root
|
|
79
|
+
|
|
80
|
+
#### Global Install
|
|
81
|
+
|
|
82
|
+
Use these commands when you want package-manager-managed tools available outside a single project.
|
|
83
|
+
|
|
84
|
+
- `vp install -g typescript`
|
|
85
|
+
- `vp uninstall -g typescript`
|
|
86
|
+
- `vp update -g`
|
|
87
|
+
- `vp list -g`
|
|
88
|
+
|
|
89
|
+
#### Add and Remove
|
|
90
|
+
|
|
91
|
+
Use `vp add` and `vp remove` for day-to-day dependency edits instead of editing `package.json` by hand.
|
|
92
|
+
|
|
93
|
+
- `vp add react`
|
|
94
|
+
- `vp add -D typescript vitest`
|
|
95
|
+
- `vp add -O fsevents`
|
|
96
|
+
- `vp add --save-peer react`
|
|
97
|
+
- `vp remove react`
|
|
98
|
+
- `vp remove --filter web react`
|
|
99
|
+
|
|
100
|
+
#### Update, Dedupe, and Outdated
|
|
101
|
+
|
|
102
|
+
Use these commands to maintain the dependency graph over time.
|
|
103
|
+
|
|
104
|
+
- `vp update` refreshes packages to newer versions
|
|
105
|
+
- `vp outdated` shows which packages have newer versions available
|
|
106
|
+
- `vp dedupe` asks the package manager to collapse duplicates where possible
|
|
107
|
+
|
|
108
|
+
#### Inspect
|
|
109
|
+
|
|
110
|
+
Use these when you need to understand the current state of dependencies.
|
|
111
|
+
|
|
112
|
+
- `vp list` shows installed packages
|
|
113
|
+
- `vp why react` explains why `react` is installed
|
|
114
|
+
- `vp info react` shows registry metadata such as versions and dist-tags
|
|
115
|
+
|
|
116
|
+
#### Advanced
|
|
117
|
+
|
|
118
|
+
Use these when you need lower-level package-manager behavior.
|
|
119
|
+
|
|
120
|
+
- `vp link` and `vp unlink` manage local development links
|
|
121
|
+
- `vp dlx create-vite` runs a package binary without saving it as a dependency
|
|
122
|
+
- `vp pm <command>` forwards directly to the resolved package manager
|
|
123
|
+
|
|
124
|
+
Examples:
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
vp pm config get registry
|
|
128
|
+
vp pm cache clean --force
|
|
129
|
+
vp pm exec tsc --version
|
|
130
|
+
```
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Lint
|
|
2
|
+
|
|
3
|
+
`vp lint` lints code with Oxlint.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
`vp lint` is built on [Oxlint](https://oxc.rs/docs/guide/usage/linter.html), the Oxc linter. Oxlint is designed as a fast replacement for ESLint for most frontend projects and ships with built-in support for core ESLint rules and many popular community rules.
|
|
8
|
+
|
|
9
|
+
Use `vp lint` to lint your project, and `vp check` to format, lint and type-check all at once.
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
vp lint
|
|
15
|
+
vp lint --fix
|
|
16
|
+
vp lint --type-aware
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Configuration
|
|
20
|
+
|
|
21
|
+
Put lint configuration directly in the `lint` block in `vite.config.ts` so all your configuration stays in one place. We do not recommend using `oxlint.config.ts` or `.oxlintrc.json` with Vite+.
|
|
22
|
+
|
|
23
|
+
For the upstream rule set, options, and compatibility details, see the [Oxlint docs](https://oxc.rs/docs/guide/usage/linter.html).
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { defineConfig } from 'vite-plus';
|
|
27
|
+
|
|
28
|
+
export default defineConfig({
|
|
29
|
+
lint: {
|
|
30
|
+
ignorePatterns: ['dist/**'],
|
|
31
|
+
options: {
|
|
32
|
+
typeAware: true,
|
|
33
|
+
typeCheck: true,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Type-Aware Linting
|
|
40
|
+
|
|
41
|
+
We recommend enabling both `typeAware` and `typeCheck` in the `lint` block:
|
|
42
|
+
|
|
43
|
+
- `typeAware: true` enables rules that require TypeScript type information
|
|
44
|
+
- `typeCheck: true` enables full type checking during linting
|
|
45
|
+
|
|
46
|
+
This path is powered by [tsgolint](https://github.com/oxc-project/tsgolint) on top of the TypeScript Go toolchain. It gives Oxlint access to type information and allows type checking directly via `vp lint` and `vp check`.
|
|
47
|
+
|
|
48
|
+
## JS Plugins
|
|
49
|
+
|
|
50
|
+
If you are migrating from ESLint and still depend on a few critical JavaScript-based ESLint plugins, Oxlint has [JS plugin support](https://oxc.rs/docs/guide/usage/linter/js-plugins) that can help you keep those plugins running while you complete the migration.
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# Migrate to Vite+
|
|
2
|
+
|
|
3
|
+
`vp migrate` helps move existing projects onto Vite+.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This command is the starting point for consolidating separate Vite, Vitest, Oxlint, Oxfmt, ESLint, and Prettier setups into Vite+.
|
|
8
|
+
|
|
9
|
+
Use it when you want to take an existing project and move it onto the Vite+ defaults instead of wiring each tool by hand.
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
vp migrate
|
|
15
|
+
vp migrate <path>
|
|
16
|
+
vp migrate --no-interactive
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Target Path
|
|
20
|
+
|
|
21
|
+
The positional `PATH` argument is optional.
|
|
22
|
+
|
|
23
|
+
- If omitted, `vp migrate` migrates the current directory
|
|
24
|
+
- If provided, it migrates that target directory instead
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
vp migrate
|
|
28
|
+
vp migrate my-app
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Options
|
|
32
|
+
|
|
33
|
+
- `--agent <name>` writes agent instructions into the project
|
|
34
|
+
- `--no-agent` skips agent instruction setup
|
|
35
|
+
- `--editor <name>` writes editor config files into the project
|
|
36
|
+
- `--no-editor` skips editor config setup
|
|
37
|
+
- `--hooks` sets up pre-commit hooks
|
|
38
|
+
- `--no-hooks` skips hook setup
|
|
39
|
+
- `--no-interactive` runs the migration without prompts
|
|
40
|
+
|
|
41
|
+
## Migration Flow
|
|
42
|
+
|
|
43
|
+
The `migrate` command is designed to move existing projects onto Vite+ quickly. Here is what the command does:
|
|
44
|
+
|
|
45
|
+
- Updates project dependencies
|
|
46
|
+
- Rewrites imports where needed
|
|
47
|
+
- Merges tool-specific config into `vite.config.ts`
|
|
48
|
+
- Updates scripts to the Vite+ command surface
|
|
49
|
+
- Can set up commit hooks
|
|
50
|
+
- Can write agent and editor configuration files
|
|
51
|
+
|
|
52
|
+
Most projects will require further manual adjustments after running `vp migrate`.
|
|
53
|
+
|
|
54
|
+
## Recommended Workflow
|
|
55
|
+
|
|
56
|
+
Before running the migration:
|
|
57
|
+
|
|
58
|
+
- Upgrade to Vite 8+ and Vitest 4.1+ first
|
|
59
|
+
- Make sure you understand any existing lint, format, or test setup that should be preserved
|
|
60
|
+
|
|
61
|
+
After running the migration:
|
|
62
|
+
|
|
63
|
+
- Run `vp install`
|
|
64
|
+
- Run `vp check`
|
|
65
|
+
- Run `vp test`
|
|
66
|
+
- Run `vp build`
|
|
67
|
+
|
|
68
|
+
## Migration Prompt
|
|
69
|
+
|
|
70
|
+
If you want to hand this work to a coding agent (or the reader is a coding agent!), use this migration prompt:
|
|
71
|
+
|
|
72
|
+
```md
|
|
73
|
+
Migrate this project to Vite+. Vite+ replaces the current split tooling around runtime management, package management, dev/build/test commands, linting, formatting, and packaging. Run `vp help` to understand Vite+ capabilities and `vp help migrate` before making changes. Use `vp migrate --no-interactive` in the workspace root. Make sure the project is using Vite 8+ and Vitest 4.1+ before migrating.
|
|
74
|
+
|
|
75
|
+
After the migration:
|
|
76
|
+
|
|
77
|
+
- Confirm `vite` imports were rewritten to `vite-plus` where needed
|
|
78
|
+
- Confirm `vitest` imports were rewritten to `vite-plus/test` where needed
|
|
79
|
+
- Remove old `vite` and `vitest` dependencies only after those rewrites are confirmed
|
|
80
|
+
- Move remaining tool-specific config into the appropriate blocks in `vite.config.ts`
|
|
81
|
+
|
|
82
|
+
Command mapping to keep in mind:
|
|
83
|
+
|
|
84
|
+
- `vp run <script>` is the equivalent of `pnpm run <script>`
|
|
85
|
+
- `vp test` runs the built-in test command, while `vp run test` runs the `test` script from `package.json`
|
|
86
|
+
- `vp install`, `vp add`, and `vp remove` delegate through the package manager declared by `packageManager`
|
|
87
|
+
- `vp dev`, `vp build`, `vp preview`, `vp lint`, `vp fmt`, `vp check`, and `vp pack` replace the corresponding standalone tools
|
|
88
|
+
- Prefer `vp check` for validation loops
|
|
89
|
+
|
|
90
|
+
Finally, verify the migration by running: `vp install`, `vp check`, `vp test`, and `vp build`
|
|
91
|
+
|
|
92
|
+
Summarize the migration at the end and report any manual follow-up still required.
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Tool-Specific Migrations
|
|
96
|
+
|
|
97
|
+
### Vitest
|
|
98
|
+
|
|
99
|
+
Vitest is automatically migrated through `vp migrate`. If you are migrating manually, you have to update all the imports to `vite-plus/test` instead:
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
// before
|
|
103
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
104
|
+
|
|
105
|
+
const { page } = await import('@vitest/browser/context');
|
|
106
|
+
|
|
107
|
+
// after
|
|
108
|
+
import { describe, expect, it, vi } from 'vite-plus/test';
|
|
109
|
+
|
|
110
|
+
const { page } = await import('vite-plus/test/browser/context');
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### tsdown
|
|
114
|
+
|
|
115
|
+
If your project uses a `tsdown.config.ts`, move its options into the `pack` block in `vite.config.ts`:
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
// before — tsdown.config.ts
|
|
119
|
+
import { defineConfig } from 'tsdown';
|
|
120
|
+
|
|
121
|
+
export default defineConfig({
|
|
122
|
+
entry: ['src/index.ts'],
|
|
123
|
+
dts: true,
|
|
124
|
+
format: ['esm', 'cjs'],
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
// after — vite.config.ts
|
|
128
|
+
import { defineConfig } from 'vite-plus';
|
|
129
|
+
|
|
130
|
+
export default defineConfig({
|
|
131
|
+
pack: {
|
|
132
|
+
entry: ['src/index.ts'],
|
|
133
|
+
dts: true,
|
|
134
|
+
format: ['esm', 'cjs'],
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
After merging, delete `tsdown.config.ts`. See the [Pack guide](/guide/pack) for the full configuration reference.
|
|
140
|
+
|
|
141
|
+
### lint-staged
|
|
142
|
+
|
|
143
|
+
Vite+ replaces lint-staged with its own `staged` block in `vite.config.ts`. Only the `staged` config format is supported. Standalone `.lintstagedrc` in non-JSON format and `lint-staged.config.*` are not migrated automatically.
|
|
144
|
+
|
|
145
|
+
Move your lint-staged rules into the `staged` block:
|
|
146
|
+
|
|
147
|
+
```ts
|
|
148
|
+
// vite.config.ts
|
|
149
|
+
import { defineConfig } from 'vite-plus';
|
|
150
|
+
|
|
151
|
+
export default defineConfig({
|
|
152
|
+
staged: {
|
|
153
|
+
'*.{js,ts,tsx,vue,svelte}': 'vp check --fix',
|
|
154
|
+
},
|
|
155
|
+
});
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
After migrating, remove lint-staged from your dependencies and delete any lint-staged config files. See the [Commit hooks guide](/guide/commit-hooks) and [Staged config reference](/config/staged) for details.
|
|
159
|
+
|
|
160
|
+
## Examples
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
# Migrate the current project
|
|
164
|
+
vp migrate
|
|
165
|
+
|
|
166
|
+
# Migrate a specific directory
|
|
167
|
+
vp migrate my-app
|
|
168
|
+
|
|
169
|
+
# Run without prompts
|
|
170
|
+
vp migrate --no-interactive
|
|
171
|
+
|
|
172
|
+
# Write agent and editor setup during migration
|
|
173
|
+
vp migrate --agent claude --editor zed
|
|
174
|
+
```
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Pack
|
|
2
|
+
|
|
3
|
+
`vp pack` builds libraries for production with [tsdown](https://tsdown.dev/guide/).
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
`vp pack` builds libraries and standalone executables with tsdown. Use it for publishable packages and binary outputs. If you want to build a web application, use `vp build`. `vp pack` covers everything you need for building libraries out of the box, including declaration file generation, multiple output formats, source maps, and minification.
|
|
8
|
+
|
|
9
|
+
For more information about how tsdown works, see the official [tsdown guide](https://tsdown.dev/guide/).
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
vp pack
|
|
15
|
+
vp pack src/index.ts --dts
|
|
16
|
+
vp pack --watch
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Configuration
|
|
20
|
+
|
|
21
|
+
Put packaging configuration directly in the `pack` block in `vite.config.ts` so all your configuration stays in one place. We do not recommend using `tsdown.config.ts` with Vite+.
|
|
22
|
+
|
|
23
|
+
See the [tsdown guide](https://tsdown.dev/guide/) and the [tsdown config file docs](https://tsdown.dev/options/config-file) to learn more about how to use and configure `vp pack`.
|
|
24
|
+
|
|
25
|
+
Use it for:
|
|
26
|
+
|
|
27
|
+
- [declaration files (`dts`)](https://tsdown.dev/options/dts)
|
|
28
|
+
- [output formats](https://tsdown.dev/options/output-format)
|
|
29
|
+
- [watch mode](https://tsdown.dev/options/watch-mode)
|
|
30
|
+
- [standalone executables](https://tsdown.dev/options/exe#executable)
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
import { defineConfig } from 'vite-plus';
|
|
34
|
+
|
|
35
|
+
export default defineConfig({
|
|
36
|
+
pack: {
|
|
37
|
+
dts: true,
|
|
38
|
+
format: ['esm', 'cjs'],
|
|
39
|
+
sourcemap: true,
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Standalone Executables
|
|
45
|
+
|
|
46
|
+
`vp pack` can also build standalone executables through tsdown's experimental [`exe` option](https://tsdown.dev/options/exe#executable).
|
|
47
|
+
|
|
48
|
+
Use this when you want to ship a CLI or other Node-based tool as a native executable that runs without requiring Node.js to be installed separately.
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
import { defineConfig } from 'vite-plus';
|
|
52
|
+
|
|
53
|
+
export default defineConfig({
|
|
54
|
+
pack: {
|
|
55
|
+
entry: ['src/cli.ts'],
|
|
56
|
+
exe: true,
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
See the official [tsdown executable docs](https://tsdown.dev/options/exe#executable) for details about configuring custom file names, embedded assets, and cross-platform targets.
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
# Run
|
|
2
|
+
|
|
3
|
+
`vp run` runs `package.json` scripts and tasks defined in `vite.config.ts`. It works like `pnpm run`, with caching, dependency ordering, and workspace-aware execution built in.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Use `vp run` with existing `package.json` scripts:
|
|
8
|
+
|
|
9
|
+
```json [package.json]
|
|
10
|
+
{
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "node compile-legacy-app.js",
|
|
13
|
+
"test": "jest"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
`vp run build` executes the associated build script:
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
$ node compile-legacy-app.js
|
|
22
|
+
|
|
23
|
+
building legacy app for production...
|
|
24
|
+
|
|
25
|
+
✓ built in 69s
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Use `vp run` without a task name to use the interactive task runner:
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
Select a task (↑/↓, Enter to run, Esc to clear):
|
|
32
|
+
|
|
33
|
+
› build: node compile-legacy-app.js
|
|
34
|
+
test: jest
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Caching
|
|
38
|
+
|
|
39
|
+
`package.json` scripts are not cached by default. Use `--cache` to enable caching:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
vp run --cache build
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
$ node compile-legacy-app.js
|
|
47
|
+
✓ built in 69s
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
If nothing changes, the output is replayed from the cache on the next run:
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
$ node compile-legacy-app.js ✓ cache hit, replaying
|
|
54
|
+
✓ built in 69s
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
vp run: cache hit, 69s saved.
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
If an input changes, the task runs again:
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
$ node compile-legacy-app.js ✗ cache miss: 'legacy/index.js' modified, executing
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Task Definitions
|
|
67
|
+
|
|
68
|
+
Vite Task automatically tracks which files your command uses. You can define tasks directly in `vite.config.ts` to enable caching by default or control which files and environment variables affect cache behavior.
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
import { defineConfig } from 'vite-plus';
|
|
72
|
+
|
|
73
|
+
export default defineConfig({
|
|
74
|
+
run: {
|
|
75
|
+
tasks: {
|
|
76
|
+
build: {
|
|
77
|
+
command: 'vp build',
|
|
78
|
+
dependsOn: ['lint'],
|
|
79
|
+
env: ['NODE_ENV'],
|
|
80
|
+
},
|
|
81
|
+
deploy: {
|
|
82
|
+
command: 'deploy-script --prod',
|
|
83
|
+
cache: false,
|
|
84
|
+
dependsOn: ['build', 'test'],
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
If you want to run an existing `package.json` script as-is, use `vp run <script>`. If you want task-level caching, dependencies, or environment/input controls, define a task with an explicit `command`. A task name can come from `vite.config.ts` or `package.json`, but not both.
|
|
92
|
+
|
|
93
|
+
::: info
|
|
94
|
+
Tasks defined in `vite.config.ts` are cached by default. `package.json` scripts are not. See [When Is Caching Enabled?](/guide/cache#when-is-caching-enabled) for the full resolution order.
|
|
95
|
+
:::
|
|
96
|
+
|
|
97
|
+
See [Run Config](/config/run) for the full `run` block reference.
|
|
98
|
+
|
|
99
|
+
## Task Dependencies
|
|
100
|
+
|
|
101
|
+
Use [`dependsOn`](#depends-on) to run tasks in the right order. Running `vp run deploy` with the config above runs `build` and `test` first. Dependencies can also target other packages in the same project with the `package#task` notation:
|
|
102
|
+
|
|
103
|
+
```ts
|
|
104
|
+
dependsOn: ['@my/core#build', '@my/utils#lint'];
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Running in a Workspace
|
|
108
|
+
|
|
109
|
+
With no package-selection flags, `vp run` runs the task in the package in your current working directory:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
cd packages/app
|
|
113
|
+
vp run build
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
You can also target a package explicitly from anywhere:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
vp run @my/app#build
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Workspace package ordering is based on the normal monorepo dependency graph declared in each package's `package.json`. In other words, when Vite+ talks about package dependencies, it means the regular `dependencies` relationships between workspace packages, not a separate task-runner-specific graph.
|
|
123
|
+
|
|
124
|
+
### Recursive (`-r`)
|
|
125
|
+
|
|
126
|
+
Run the task in every workspace package, in dependency order:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
vp run -r build
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
That dependency order comes from the workspace packages referenced through `package.json` dependencies.
|
|
133
|
+
|
|
134
|
+
### Transitive (`-t`)
|
|
135
|
+
|
|
136
|
+
Run the task in one package and all of its dependencies:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
vp run -t @my/app#build
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
If `@my/app` depends on `@my/utils`, which depends on `@my/core`, this runs all three in order. Vite+ resolves that chain from the normal workspace package dependencies declared in `package.json`.
|
|
143
|
+
|
|
144
|
+
### Filter (`--filter`)
|
|
145
|
+
|
|
146
|
+
Select packages by name, directory, or glob pattern. The syntax matches pnpm's `--filter`:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
# By name
|
|
150
|
+
vp run --filter @my/app build
|
|
151
|
+
|
|
152
|
+
# By glob
|
|
153
|
+
vp run --filter "@my/*" build
|
|
154
|
+
|
|
155
|
+
# By directory
|
|
156
|
+
vp run --filter ./packages/app build
|
|
157
|
+
|
|
158
|
+
# Include dependencies
|
|
159
|
+
vp run --filter "@my/app..." build
|
|
160
|
+
|
|
161
|
+
# Include dependents
|
|
162
|
+
vp run --filter "...@my/core" build
|
|
163
|
+
|
|
164
|
+
# Exclude packages
|
|
165
|
+
vp run --filter "@my/*" --filter "!@my/utils" build
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Multiple `--filter` flags are combined as a union. Exclusion filters are applied after all inclusions.
|
|
169
|
+
|
|
170
|
+
### Workspace Root (`-w`)
|
|
171
|
+
|
|
172
|
+
Explicitly run the task in the workspace root package:
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
vp run -w build
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Compound Commands
|
|
179
|
+
|
|
180
|
+
Commands joined with `&&` are split into independent sub-tasks. Each sub-task is cached separately when [caching is enabled](/guide/cache#when-is-caching-enabled). This works for both `vite.config.ts` tasks and `package.json` scripts:
|
|
181
|
+
|
|
182
|
+
```json [package.json]
|
|
183
|
+
{
|
|
184
|
+
"scripts": {
|
|
185
|
+
"check": "vp lint && vp build"
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Now, run `vp run --cache check`:
|
|
191
|
+
|
|
192
|
+
```
|
|
193
|
+
$ vp lint
|
|
194
|
+
Found 0 warnings and 0 errors.
|
|
195
|
+
|
|
196
|
+
$ vp build
|
|
197
|
+
✓ built in 28ms
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
vp run: 0/2 cache hit (0%).
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Each sub-task has its own cache entry. If only `.ts` files changed but lint still passes, only `vp build` runs again the next time `vp run --cache check` is called:
|
|
204
|
+
|
|
205
|
+
```
|
|
206
|
+
$ vp lint ✓ cache hit, replaying
|
|
207
|
+
$ vp build ✗ cache miss: 'src/index.ts' modified, executing
|
|
208
|
+
✓ built in 30ms
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
vp run: 1/2 cache hit (50%), 120ms saved.
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Nested `vp run`
|
|
215
|
+
|
|
216
|
+
When a command contains `vp run`, Vite Task inlines it as separate tasks instead of spawning a nested process. Each sub-task is cached independently and output stays flat:
|
|
217
|
+
|
|
218
|
+
```json [package.json]
|
|
219
|
+
{
|
|
220
|
+
"scripts": {
|
|
221
|
+
"ci": "vp run lint && vp run test && vp run build"
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
Running `vp run ci` expands into three tasks:
|
|
227
|
+
|
|
228
|
+
```mermaid
|
|
229
|
+
graph LR
|
|
230
|
+
lint --> test --> build
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
Flags also work inside nested scripts. For example, `vp run -r build` inside a script expands into individual build tasks for every package.
|
|
234
|
+
|
|
235
|
+
::: info
|
|
236
|
+
A common monorepo pattern is a root script that runs a task recursively:
|
|
237
|
+
|
|
238
|
+
```json [package.json (root)]
|
|
239
|
+
{
|
|
240
|
+
"scripts": {
|
|
241
|
+
"build": "vp run -r build"
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
This creates a potential recursion: root's `build` -> `vp run -r build` -> includes root's `build` -> ...
|
|
247
|
+
|
|
248
|
+
Vite Task detects this and prunes the self-reference automatically, so other packages build normally.
|
|
249
|
+
:::
|
|
250
|
+
|
|
251
|
+
## Execution Summary
|
|
252
|
+
|
|
253
|
+
Use `-v` to show a detailed execution summary:
|
|
254
|
+
|
|
255
|
+
```bash
|
|
256
|
+
vp run -r -v build
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
```
|
|
260
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
261
|
+
Vite+ Task Runner • Execution Summary
|
|
262
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
263
|
+
|
|
264
|
+
Statistics: 3 tasks • 3 cache hits • 0 cache misses
|
|
265
|
+
Performance: 100% cache hit rate, 468ms saved in total
|
|
266
|
+
|
|
267
|
+
Task Details:
|
|
268
|
+
────────────────────────────────────────────────
|
|
269
|
+
[1] @my/core#build: ~/packages/core$ vp build ✓
|
|
270
|
+
→ Cache hit - output replayed - 200ms saved
|
|
271
|
+
·······················································
|
|
272
|
+
[2] @my/utils#build: ~/packages/utils$ vp build ✓
|
|
273
|
+
→ Cache hit - output replayed - 150ms saved
|
|
274
|
+
·······················································
|
|
275
|
+
[3] @my/app#build: ~/packages/app$ vp build ✓
|
|
276
|
+
→ Cache hit - output replayed - 118ms saved
|
|
277
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
Use `--last-details` to show the summary from the last run without running tasks again:
|
|
281
|
+
|
|
282
|
+
```bash
|
|
283
|
+
vp run --last-details
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
## Additional Arguments
|
|
287
|
+
|
|
288
|
+
Arguments after the task name are passed through to the task command:
|
|
289
|
+
|
|
290
|
+
```bash
|
|
291
|
+
vp run test --reporter verbose
|
|
292
|
+
```
|