vite-plus 0.3.1 → 0.3.3

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.
Files changed (63) hide show
  1. package/README.md +1 -1
  2. package/bin/vp +1 -1
  3. package/binding/index.cjs +137 -56
  4. package/binding/index.d.cts +52 -0
  5. package/dist/{agent-C5jMYVfB.js → agent-Cu6-tXIP.js} +2 -2
  6. package/dist/bin.js +6 -5
  7. package/dist/config/bin.js +2 -2
  8. package/dist/{constants-0IAVgpox.js → constants-C2dTOTe-.js} +2 -2
  9. package/dist/create/bin.js +97 -68
  10. package/dist/{define-config-DIE9de46.cjs → define-config-D0mevyb3.cjs} +1 -1
  11. package/dist/{define-config-U3_xg7i-.js → define-config-IgzmnvvV.js} +2 -2
  12. package/dist/define-config.cjs +1 -1
  13. package/dist/define-config.js +1 -1
  14. package/dist/{editor-B5-lvRaU.js → editor-4sjlHmUh.js} +154 -36
  15. package/dist/index.cjs +1 -1
  16. package/dist/index.js +1 -1
  17. package/dist/lint-plugins-dev.d.ts +3 -0
  18. package/dist/lint-plugins-dev.js +2 -0
  19. package/dist/lint-plugins.cjs +21 -0
  20. package/dist/lint-plugins.d.ts +3 -0
  21. package/dist/lint-plugins.js +2 -0
  22. package/dist/migration/bin.js +7 -7
  23. package/dist/{oxlint-plugin-config-Drdl67Xp.js → oxlint-plugin-config-BVqEe9KY.js} +1 -1
  24. package/dist/oxlint-plugin.js +93 -32
  25. package/dist/pack-bin.js +1 -1
  26. package/dist/{package-BZz2Ij68.js → package-CHH8jWan.js} +1 -1
  27. package/dist/{prompts-CtzEgFY-.js → prompts-k14KgthC.js} +1 -1
  28. package/dist/{resolve-vite-config-CGks1xR7.js → resolve-vite-config-BqvS2P98.js} +2 -2
  29. package/dist/{resolve-vite-config-Dnmc-lBc.js → resolve-vite-config-CTOTuqTi.js} +1 -1
  30. package/dist/staged/bin.js +1 -1
  31. package/dist/toolchain.js +8 -8
  32. package/dist/toolchain.json +8 -8
  33. package/dist/{tsconfig-CUggNuJR.js → tsconfig-C3h9CVTA.js} +2 -2
  34. package/dist/{tsconfig-VAbm4ZzJ.js → tsconfig-euB-GmIE.js} +1 -1
  35. package/dist/version.js +2 -2
  36. package/dist/versions.js +4 -4
  37. package/docs/config/fmt.md +4 -2
  38. package/docs/config/lint.md +4 -2
  39. package/docs/config/staged.md +1 -2
  40. package/docs/guide/ci.md +28 -31
  41. package/docs/guide/commit-hooks.md +11 -34
  42. package/docs/guide/create.md +1 -2
  43. package/docs/guide/docker.md +20 -68
  44. package/docs/guide/env.md +56 -22
  45. package/docs/guide/fmt.md +3 -1
  46. package/docs/guide/global-cli.md +426 -0
  47. package/docs/guide/ide-integration.md +1 -2
  48. package/docs/guide/implode.md +14 -1
  49. package/docs/guide/index.md +37 -34
  50. package/docs/guide/install.md +18 -19
  51. package/docs/guide/lint.md +52 -1
  52. package/docs/guide/local-cli.md +123 -0
  53. package/docs/guide/migrate-rules.md +108 -267
  54. package/docs/guide/migrate.md +6 -49
  55. package/docs/guide/monorepo.md +2 -0
  56. package/docs/guide/run.md +1 -1
  57. package/docs/guide/troubleshooting.md +17 -8
  58. package/docs/guide/upgrade-project.md +61 -0
  59. package/docs/guide/upgrade.md +17 -62
  60. package/package.json +26 -17
  61. package/templates/generator/README.md +14 -0
  62. package/templates/generator/bin/index.ts +54 -5
  63. package/docs/guide/installer-env-vars.md +0 -252
@@ -1,6 +1,6 @@
1
- # Installing Dependencies
1
+ # Package Management
2
2
 
3
- `vp install` installs dependencies using the current workspace's package manager.
3
+ `vp` detects and runs the current workspace's package manager. These commands are available from both the [global CLI](/guide/global-cli) and the [project-local CLI](/guide/local-cli).
4
4
 
5
5
  ## Overview
6
6
 
@@ -21,8 +21,6 @@ Vite+ detects the package manager from the workspace root in this order:
21
21
 
22
22
  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, but package-manager detection never rewrites `package.json`. Use `vp env pin <package-manager>@<version>` when the project should declare an exact version explicitly.
23
23
 
24
- After selecting the package manager, Vite+ forwards the command without separately validating whether `package.json` exists. Missing-manifest behavior therefore matches the selected package manager.
25
-
26
24
  The [`devEngines.packageManager`](https://docs.npmjs.com/cli/v11/configuring-npm/package-json#devengines) field accepts a single object or an array of objects, and its `version` may be a semver range:
27
25
 
28
26
  ```json
@@ -41,13 +39,6 @@ A range resolves to an already-downloaded satisfying version when possible, othe
41
39
 
42
40
  Vite+ currently downloads the declared package manager (the `onFail: "download"` behavior); the other `onFail` values are accepted but not yet differentiated.
43
41
 
44
- A `packageManager` pin can carry an integrity hash (`yarn@4.17.1+sha512.…`). `corepack use` writes that hash. Vite+ hashes the same artifact as Corepack:
45
-
46
- - the extracted CLI binary (`bin/yarn.js`) for Yarn 2 and later
47
- - the npm package tarball for npm, pnpm, and Yarn Classic
48
-
49
- Vite+ hashes the CLI once, when it installs Yarn, and records the pin it verified. A later command compares its own pin against that record. A pin that does not match the record fails the check, and the command stops. Corepack keeps the same kind of record for its own cache.
50
-
51
42
  The explicit `packageManager` field (or the `devEngines.packageManager` declaration) also affects matching package-manager shims. If a project has `packageManager: "npm@10.9.4"`, `npm` and `npx` use npm 10.9.4. Other generated alias pairs behave the same way: `pnpm`/`pnpx`, `yarn`/`yarnpkg`, and `bun`/`bunx`. Mismatched tools are not translated; `npm` in a `pnpm` project still resolves as npm.
52
43
 
53
44
  ## Usage
@@ -83,8 +74,7 @@ Updates keep the version spec a package was installed with: a package installed
83
74
  ::: warning
84
75
  These commands do **NOT** interact with the underlying package manager's global installation directory.
85
76
 
86
- Instead, Vite+ stores its global packages in `packages/` under the resolved data
87
- directory. These packages remain available across different Node.js versions.
77
+ Instead, Vite+ stores its global packages in `packages/` under the resolved data directory. These packages remain available across different Node.js versions.
88
78
 
89
79
  As a result, commands such as `vp link` do not affect Vite+'s global packages and will not appear in `vp list -g`.
90
80
  :::
@@ -122,6 +112,10 @@ Use `vp install` when you want to install exactly what the current `package.json
122
112
  - `vp install --filter <pattern>` scopes install work in monorepos
123
113
  - `vp install -w` installs in the workspace root
124
114
 
115
+ ##### Git and remote tarball dependencies (npm v12+)
116
+
117
+ npm v12 stops resolving git dependencies (`github:`, `git+https:`) and remote tarball URLs by default; such installs fail with `EALLOWGIT` / `EALLOWREMOTE`. Opt back in per project with npm's `allow-git` / `allow-remote` config.
118
+
125
119
  #### Global Install
126
120
 
127
121
  Use these commands when you want package-manager-managed tools available outside a single project.
@@ -140,6 +134,7 @@ Use `vp add` and `vp remove` for day-to-day dependency edits instead of editing
140
134
  - `vp add -D typescript vitest`
141
135
  - `vp add -O fsevents`
142
136
  - `vp add --save-peer react`
137
+ - `vp add react --ignore-scripts`
143
138
  - `vp remove react`
144
139
  - `vp remove --filter web react`
145
140
 
@@ -159,10 +154,7 @@ Use these when you need to understand the current state of dependencies.
159
154
  - `vp why react` explains why `react` is installed
160
155
  - `vp info react` shows registry metadata such as versions and dist-tags
161
156
 
162
- These commands show the packages that the package manager installed. They do
163
- not show tools that Vite+ bundles or compiles. Run `vp toolchain [tool]` to show
164
- these tools, including Vite, Rolldown, and Oxc. For readable output, `vp why`
165
- shows a hint when Vite+ also provides the package.
157
+ These commands show the packages that the package manager installed. They do not show tools that Vite+ bundles or compiles. Run `vp toolchain [tool]` to show these tools, including Vite, Rolldown, and Oxc. For readable output, `vp why` shows a hint when Vite+ also provides the package.
166
158
 
167
159
  #### Rebuild
168
160
 
@@ -193,8 +185,6 @@ npm v12 skips dependency install scripts (`preinstall` / `install` / `postinstal
193
185
 
194
186
  Approval only records the allowlist: scripts an earlier install skipped do not run until you run `vp rebuild <pkg>`. With npm 11.16 - 11.x the same commands work, but npm treats the allowlist as advisory and still runs scripts.
195
187
 
196
- npm v12 also stops resolving git dependencies (`github:`, `git+https:`) and remote tarball URLs by default; such installs fail with `EALLOWGIT` / `EALLOWREMOTE`. Opt back in per project with npm's `allow-git` / `allow-remote` config.
197
-
198
188
  #### Advanced
199
189
 
200
190
  Use these when you need lower-level package-manager behavior.
@@ -227,3 +217,12 @@ vp pm stage reject <stage-id> # discard a staged version (2FA)
227
217
  - pnpm (`pnpm stage`, requires pnpm ≥ 11.3) and npm (`npm stage`, requires npm ≥ 11.15 and Node ≥ 22.14) pass through directly.
228
218
  - yarn (Berry) uses its npm plugin (`yarn npm publish --staged`, `yarn npm stage …`); `view`/`download` fall back to npm.
229
219
  - yarn Classic and bun have no staged-publishing support and fall back to `npm stage`.
220
+
221
+ ## Package-Manager Integrity Verification
222
+
223
+ A `packageManager` pin can carry an integrity hash (`yarn@4.17.1+sha512.…`). `corepack use` writes that hash. Vite+ hashes the same artifact as Corepack:
224
+
225
+ - the extracted CLI binary (`bin/yarn.js`) for Yarn 2 and later
226
+ - the npm package tarball for npm, pnpm, and Yarn Classic
227
+
228
+ Vite+ hashes the CLI once, when it installs Yarn, and records the pin it verified. A later command compares its own pin against that record. A pin that does not match the record fails the check, and the command stops. Corepack keeps the same kind of record for its own cache.
@@ -18,7 +18,9 @@ vp lint --type-aware
18
18
 
19
19
  ## Configuration
20
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+.
21
+ Put lint configuration directly in the `lint` block in the root `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
+ Vite+ does not currently support nested lint configuration. For now, use [`lint.overrides`](/guide/monorepo#root-config-with-overrides) in the root `vite.config.ts` for file- or package-specific rules. The long-term behavior is open for discussion; [share your use case and expectations](/guide/troubleshooting#nested-lint-or-format-config-is-not-applied) to help shape it.
22
24
 
23
25
  For the upstream rule set, options, and compatibility details, see the [Oxlint docs](https://oxc.rs/docs/guide/usage/linter.html).
24
26
 
@@ -50,3 +52,52 @@ This path is powered by [tsgolint](https://github.com/oxc-project/tsgolint) on t
50
52
  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.
51
53
 
52
54
  JS Plugins also enable [writing your own custom rules](https://oxc.rs/docs/guide/usage/linter/writing-js-plugins.html) for Oxlint.
55
+
56
+ ### Writing Your Own Rules
57
+
58
+ Import the plugin authoring API from `vite-plus/lint/plugins`:
59
+
60
+ ```js [lint/my-plugin.js]
61
+ import { definePlugin, defineRule } from 'vite-plus/lint/plugins';
62
+
63
+ const noFoo = defineRule({
64
+ meta: { messages: { noFoo: 'Do not name things "foo".' } },
65
+ create(context) {
66
+ return {
67
+ Identifier(node) {
68
+ if (node.name === 'foo') {
69
+ context.report({ node, messageId: 'noFoo' });
70
+ }
71
+ },
72
+ };
73
+ },
74
+ });
75
+
76
+ export default definePlugin({
77
+ meta: { name: 'my' },
78
+ rules: { 'no-foo': noFoo },
79
+ });
80
+ ```
81
+
82
+ Register it under `lint.jsPlugins` and enable its rules:
83
+
84
+ ```ts [vite.config.ts]
85
+ import { defineConfig } from 'vite-plus';
86
+
87
+ export default defineConfig({
88
+ lint: {
89
+ jsPlugins: ['./lint/my-plugin.js'],
90
+ rules: {
91
+ 'my/no-foo': 'error',
92
+ },
93
+ },
94
+ });
95
+ ```
96
+
97
+ For rule tests, `RuleTester` is available from `vite-plus/lint/plugins-dev`.
98
+
99
+ Both entrypoints re-export the copy that ships with Vite+. The API therefore always matches the bundled Oxlint.
100
+
101
+ Use them instead of adding `@oxlint/plugins` or `oxlint` as a direct dependency. A separately pinned copy can drift from the linter that loads your plugin. It also does not resolve from a plugin file under pnpm's strict layout, unless every package that holds a plugin declares it.
102
+
103
+ `vp migrate` rewrites existing `oxlint` and `@oxlint/plugins` imports for you. See [Oxlint JS Plugin Imports](/guide/migrate-rules#oxlint-js-plugin-imports). The `vite-plus/prefer-vite-plus-imports` rule reports any that come back.
@@ -0,0 +1,123 @@
1
+ # Project-local CLI
2
+
3
+ Different from [global `vp` cli](/guide/global-cli), the `vite-plus` is a npm package which contains the project-local `vp` CLI and the integrated frontend toolchain. Install it as a development dependency when you want the toolchain version recorded in the project's manifest and lockfile, or when you do not want to install the standalone global CLI.
4
+
5
+ The local package includes Vite, Rolldown, Vitest, Oxlint, Oxfmt, tsdown, the Vite+ task runner, and package-manager commands. It requires an existing Node.js runtime and package manager.
6
+
7
+ ## Install
8
+
9
+ For most of use cases, we recommend to use Vite+ cli to install in a project or create a new project. Learn more in [Creating a Project](/guide/create) and [Migrate to Vite+](/guide/migrate).
10
+
11
+ ::: code-group
12
+
13
+ ```bash [pnpm]
14
+ pnpm dlx --package=vite-plus vp create
15
+ ```
16
+
17
+ ```bash [npm]
18
+ npx --package=vite-plus vp create
19
+ ```
20
+
21
+ ```bash [Yarn]
22
+ yarn dlx --package vite-plus vp create
23
+ ```
24
+
25
+ ```bash [Bun]
26
+ bunx --package vite-plus vp create
27
+ ```
28
+
29
+ :::
30
+
31
+ Run its binary through your package manager. For example:
32
+
33
+ ```bash
34
+ ./node_modules/.bin/vp migrate --help
35
+ ./node_modules/.bin/vp check
36
+ ```
37
+
38
+ The documentation uses bare `vp` commands for readability. Without the global CLI, prefix interactive commands with your package manager's local-binary executor, such as `pnpm exec`.
39
+
40
+ ### Manual Installation
41
+
42
+ If you are manually migrating a project to Vite+, install these dev dependencies first:
43
+
44
+ ```bash
45
+ vp install -D vite-plus
46
+ ```
47
+
48
+ You need to add overrides to your package manager so that other packages resolve the Vite+ versions: alias `vite` to `@voidzero-dev/vite-plus-core`, and pin `vitest` to the version Vite+ bundles (run `vp --version`) so the whole project shares a single Vitest copy with `vp test`. Without the `vitest` pin, a dependency or workspace package can pull a different Vitest than the bundled runner, splitting Vitest's internals (mocks, `expect`, runner state):
49
+
50
+ ::: code-group
51
+
52
+ ```yaml [pnpm-workspace.yaml]
53
+ overrides:
54
+ vite: npm:@voidzero-dev/vite-plus-core@latest
55
+ vitest: 4.1.11
56
+ ```
57
+
58
+ ```json [npm / Bun package.json]
59
+ "overrides": {
60
+ "vite": "npm:@voidzero-dev/vite-plus-core@latest",
61
+ "vitest": "4.1.11"
62
+ }
63
+ ```
64
+
65
+ ```json [Yarn package.json]
66
+ "resolutions": {
67
+ "vite": "npm:@voidzero-dev/vite-plus-core@latest",
68
+ "vitest": "4.1.11"
69
+ }
70
+ ```
71
+
72
+ :::
73
+
74
+ ::: details Why are these settings needed?
75
+
76
+ Dependencies and plugins can import `vite` or `vitest` directly, even when your own code imports from `vite-plus`. These overrides align their dependencies with the toolchain Vite+ uses:
77
+
78
+ - The `vite` alias directs those imports to Vite+'s core package. Separate Vite instances can break runtime identity checks: [issue #1391](https://github.com/voidzero-dev/vite-plus/issues/1391) reported TanStack Start returning 404s because an `instanceof` check crossed two copies. [PR #2617](https://github.com/voidzero-dev/vite-plus/pull/2617) addresses the CLI side by sharing Vite through the same alias.
79
+ - The exact `vitest` pin keeps dependencies and `vp test` on the same Vitest version, avoiding separate mocks, `expect` instances, and runner state. [PR #2365](https://github.com/voidzero-dev/vite-plus/pull/2365) documents this requirement for manual installation.
80
+
81
+ Keep the core alias aligned with your installed `vite-plus` version and update the Vitest pin to match its bundled version when upgrading. [Issue #2356](https://github.com/voidzero-dev/vite-plus/issues/2356) describes how dependency bots can update these packages independently and leave incompatible versions installed together.
82
+
83
+ :::
84
+
85
+ ## Best Practices
86
+
87
+ We recommend using the [global CLI](/guide/global-cli) together with the project-local CLI. The global CLI makes `vp` available directly in your terminal and delegates development commands such as `vp dev`, `vp build`, and `vp test` to the project's installed `vite-plus` package. This gives you convenient access to the toolchain while keeping its version controlled by the project. You can also use only the project-local CLI if you prefer.
88
+
89
+ For open-source projects or any project with collaborators, we recommend adding `package.json` scripts that call `vp`, whether you use both CLIs or only the project-local CLI. Inside scripts, `vp` resolves automatically from `node_modules/.bin`:
90
+
91
+ ```json [package.json]
92
+ {
93
+ "scripts": {
94
+ "dev": "vp dev",
95
+ "check": "vp check",
96
+ "test": "vp test",
97
+ "build": "vp build"
98
+ }
99
+ }
100
+ ```
101
+
102
+ After installing the project's dependencies, contributors can run these scripts through their package manager, such as `pnpm run dev` or `npm run dev`, without being required to install the global CLI.
103
+
104
+ ## What It Includes
105
+
106
+ The project-local CLI can be used independently for:
107
+
108
+ - [`vp dev`](/guide/dev), [`vp build`](/guide/build), and [`vp preview`](/guide/build) with Vite and Rolldown
109
+ - [`vp check`](/guide/check), [`vp lint`](/guide/lint), and [`vp fmt`](/guide/fmt) with Oxc
110
+ - [`vp test`](/guide/test) with Vitest
111
+ - [`vp pack`](/guide/pack) with tsdown
112
+ - [`vp toolchain`](/guide/upgrade#show-the-toolchain) for inspecting the versions bundled with the project-local package
113
+ - [`vp run`](/guide/run) and task caching across workspaces
114
+ - [package-manager commands](/guide/install) using the Node.js runtime already active in your shell
115
+ - [`vp create`](/guide/create), [`vp migrate`](/guide/migrate), and project configuration commands
116
+
117
+ The local package cannot manage the machine-level Vite+ installation. The `vp env`, `vp upgrade`, and `vp implode` commands require the [global CLI](/guide/global-cli). Upgrade or remove a local-only installation through your package manager.
118
+
119
+ ## Add the Global CLI Later
120
+
121
+ You can install the global CLI at any time without changing the project's dependency. Commands such as `vp dev`, `vp build`, and `vp test` will continue to use the project's installed `vite-plus` version.
122
+
123
+ See [Use Both CLIs Together](/guide/global-cli#use-both-clis-together) for the selection rules.