vite-plus 0.1.24 → 0.2.1

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 (174) hide show
  1. package/LICENSE +30 -0
  2. package/README.md +8 -6
  3. package/bin/oxfmt +5 -2
  4. package/bin/oxlint +12 -2
  5. package/binding/index.cjs +84 -67
  6. package/binding/index.d.cts +155 -4
  7. package/dist/{agent-Nuk-9l77.js → agent--cKmgD_n.js} +941 -70
  8. package/dist/bin.js +22 -30
  9. package/dist/{compat-DXZgnEyq.js → compat-Cql3K40m.js} +1 -1
  10. package/dist/config/bin.js +30 -14
  11. package/dist/constants-CrfJQIUX.js +66 -0
  12. package/dist/create/bin.d.ts +6 -0
  13. package/dist/create/bin.js +508 -232
  14. package/dist/define-config-2tfJoXr1.d.ts +305 -0
  15. package/dist/define-config-BGSjF6Xp.cjs +488 -0
  16. package/dist/define-config-DJUehepE.js +445 -0
  17. package/dist/define-config.cjs +8 -1
  18. package/dist/define-config.d.ts +2 -2
  19. package/dist/define-config.js +2 -2
  20. package/dist/dist-DRJUd9bL.js +3 -0
  21. package/dist/{dist-BgQuvbtq.js → dist-Oxo16Y0q.js} +4 -4
  22. package/dist/index.cjs +9 -4
  23. package/dist/index.d.ts +3 -3
  24. package/dist/index.js +3 -3
  25. package/dist/{main-DpJl3LoU.js → json-Dn87fvjk.js} +137 -1
  26. package/dist/migration/bin.js +292 -76
  27. package/dist/{oxlint-plugin-config-B89iKTKN.js → oxlint-plugin-config-q8a5PFch.js} +1 -1
  28. package/dist/oxlint-plugin.js +11 -3
  29. package/dist/pack-bin.js +44 -15
  30. package/dist/{package-PmBUZ-ve.js → package-BHirM1_v.js} +3 -138
  31. package/dist/{report-DgSBQUdz.js → report-BHSkWqRR.js} +2 -0
  32. package/dist/{resolve-vite-config-TTvhycU1.js → resolve-vite-config-CmdsfQzS.js} +13 -4
  33. package/dist/staged/bin.js +5 -5
  34. package/dist/test/_at-vitest-browser/context.d.ts +2 -0
  35. package/dist/test/_at-vitest-browser.d.ts +2 -0
  36. package/dist/test/browser/context.d.ts +2 -2
  37. package/dist/test/browser/context.js +1 -1
  38. package/dist/test/browser/providers/playwright/context.d.ts +1 -0
  39. package/dist/test/browser/providers/playwright/context.js +1 -0
  40. package/dist/test/browser/providers/playwright.d.ts +124 -2
  41. package/dist/test/browser/providers/playwright.js +1 -1
  42. package/dist/test/browser/providers/preview/context.d.ts +1 -0
  43. package/dist/test/browser/providers/preview/context.js +1 -0
  44. package/dist/test/browser/providers/preview.d.ts +32 -2
  45. package/dist/test/browser/providers/preview.js +1 -1
  46. package/dist/test/browser/providers/webdriverio/context.d.ts +1 -0
  47. package/dist/test/browser/providers/webdriverio/context.js +1 -0
  48. package/dist/test/browser/providers/webdriverio.d.ts +77 -2
  49. package/dist/test/browser/providers/webdriverio.js +1 -1
  50. package/dist/test/browser-compat.d.ts +2 -0
  51. package/dist/test/browser-compat.js +1 -1
  52. package/dist/test/browser-playwright/context.d.ts +1 -0
  53. package/dist/test/browser-playwright/context.js +1 -0
  54. package/dist/test/browser-playwright.d.ts +124 -2
  55. package/dist/test/browser-playwright.js +1 -1
  56. package/dist/test/browser-preview/context.d.ts +1 -0
  57. package/dist/test/browser-preview/context.js +1 -0
  58. package/dist/test/browser-preview.d.ts +32 -2
  59. package/dist/test/browser-preview.js +1 -1
  60. package/dist/test/browser-webdriverio/context.d.ts +1 -0
  61. package/dist/test/browser-webdriverio/context.js +1 -0
  62. package/dist/test/browser-webdriverio.d.ts +77 -2
  63. package/dist/test/browser-webdriverio.js +1 -1
  64. package/dist/test/browser.d.ts +2 -2
  65. package/dist/test/browser.js +1 -1
  66. package/dist/test/client.js +1 -1
  67. package/dist/test/config.cjs +1 -1
  68. package/dist/test/config.d.ts +2 -2
  69. package/dist/test/config.js +1 -1
  70. package/dist/test/context.d.ts +942 -2
  71. package/dist/test/context.js +1 -1
  72. package/dist/test/coverage.d.ts +2 -2
  73. package/dist/test/coverage.js +1 -1
  74. package/dist/test/environments.d.ts +2 -2
  75. package/dist/test/environments.js +1 -1
  76. package/dist/test/globals.d.ts +2 -2
  77. package/dist/test/import-meta.d.ts +2 -2
  78. package/dist/test/importMeta.d.ts +2 -2
  79. package/dist/test/index.cjs +1 -1
  80. package/dist/test/index.d.cts +2 -2
  81. package/dist/test/index.d.ts +2 -2
  82. package/dist/test/index.js +1 -1
  83. package/dist/test/internal/browser.d.ts +2 -2
  84. package/dist/test/internal/browser.js +1 -1
  85. package/dist/test/jsdom.d.ts +2 -2
  86. package/dist/test/locators.d.ts +294 -0
  87. package/dist/test/locators.js +1 -1
  88. package/dist/test/matchers.d.ts +29 -0
  89. package/dist/test/matchers.js +1 -1
  90. package/dist/test/node.d.ts +2 -2
  91. package/dist/test/node.js +1 -1
  92. package/dist/test/optional-runtime-types.js.d.ts +2 -2
  93. package/dist/test/optional-types.js.d.ts +2 -2
  94. package/dist/test/plugins/browser-client.js +1 -1
  95. package/dist/test/plugins/browser-context.js +1 -1
  96. package/dist/test/plugins/browser-locators.js +1 -1
  97. package/dist/test/plugins/browser-playwright.js +1 -1
  98. package/dist/test/plugins/browser-preview.js +1 -1
  99. package/dist/test/plugins/browser-webdriverio.js +1 -1
  100. package/dist/test/plugins/browser.js +1 -1
  101. package/dist/test/plugins/expect.js +1 -1
  102. package/dist/test/plugins/mocker-automock.js +1 -1
  103. package/dist/test/plugins/mocker-browser.js +1 -1
  104. package/dist/test/plugins/mocker-node.js +1 -1
  105. package/dist/test/plugins/mocker-redirect.js +1 -1
  106. package/dist/test/plugins/mocker-register.js +1 -1
  107. package/dist/test/plugins/mocker-transforms.js +1 -1
  108. package/dist/test/plugins/mocker.js +1 -1
  109. package/dist/test/plugins/pretty-format.js +1 -1
  110. package/dist/test/plugins/runner-types.js +1 -1
  111. package/dist/test/plugins/runner-utils.js +1 -1
  112. package/dist/test/plugins/runner.js +1 -1
  113. package/dist/test/plugins/snapshot-environment.js +1 -1
  114. package/dist/test/plugins/snapshot-manager.js +1 -1
  115. package/dist/test/plugins/snapshot.js +1 -1
  116. package/dist/test/plugins/spy.js +1 -1
  117. package/dist/test/plugins/utils-constants.js +1 -1
  118. package/dist/test/plugins/utils-diff.js +1 -1
  119. package/dist/test/plugins/utils-display.js +1 -1
  120. package/dist/test/plugins/utils-error.js +1 -1
  121. package/dist/test/plugins/utils-helpers.js +1 -1
  122. package/dist/test/plugins/utils-offset.js +1 -1
  123. package/dist/test/plugins/utils-resolver.js +1 -1
  124. package/dist/test/plugins/utils-serialize.js +1 -1
  125. package/dist/test/plugins/utils-source-map-node.js +1 -1
  126. package/dist/test/plugins/utils-source-map.js +1 -1
  127. package/dist/test/plugins/utils-timers.js +1 -1
  128. package/dist/test/plugins/utils.js +1 -1
  129. package/dist/test/reporters.d.ts +2 -2
  130. package/dist/test/reporters.js +1 -1
  131. package/dist/test/runners.d.ts +2 -2
  132. package/dist/test/runners.js +1 -1
  133. package/dist/test/runtime.d.ts +2 -2
  134. package/dist/test/runtime.js +1 -1
  135. package/dist/test/snapshot.d.ts +2 -2
  136. package/dist/test/snapshot.js +1 -1
  137. package/dist/test/suite.d.ts +2 -2
  138. package/dist/test/suite.js +1 -1
  139. package/dist/test/utils.js +1 -1
  140. package/dist/test/worker.d.ts +2 -2
  141. package/dist/test/worker.js +1 -1
  142. package/dist/{tsconfig-DFb5BKyT.js → tsconfig-BWQPmGKz.js} +565 -231
  143. package/dist/tsgolint-path-B-yOos8p.js +32 -0
  144. package/dist/tsgolint-path.d.ts +8 -0
  145. package/dist/tsgolint-path.js +2 -0
  146. package/dist/version.js +3 -3
  147. package/dist/versions.d.ts +1 -1
  148. package/dist/versions.js +6 -6
  149. package/dist/{workspace-NL-m9wgM.js → workspace-D0AVy4fu.js} +11 -9
  150. package/docs/_data/team.ts +2 -1
  151. package/docs/config/create.md +36 -1
  152. package/docs/config/index.md +7 -5
  153. package/docs/guide/commit-hooks.md +9 -0
  154. package/docs/guide/create.md +106 -2
  155. package/docs/guide/env.md +33 -5
  156. package/docs/guide/index.md +5 -3
  157. package/docs/guide/install.md +31 -12
  158. package/docs/guide/migrate.md +13 -3
  159. package/docs/guide/troubleshooting.md +2 -2
  160. package/docs/guide/upgrade.md +26 -7
  161. package/docs/package.json +3 -3
  162. package/docs/pnpm-lock.yaml +298 -395
  163. package/package.json +103 -55
  164. package/templates/generator/bin/index.ts +6 -3
  165. package/templates/generator/package.json +2 -3
  166. package/templates/generator/src/template.ts +0 -2
  167. package/templates/monorepo/package.json +1 -1
  168. package/dist/constants-DCBWlNrn.js +0 -33
  169. package/dist/define-config-BR1Y88zz.cjs +0 -84
  170. package/dist/define-config-BRC7qPNE.js +0 -21
  171. package/dist/define-config-COdn-tsn.d.ts +0 -177
  172. package/dist/dist-Bapm49IR.js +0 -3
  173. package/dist/test/plugins/utils-highlight.js +0 -1
  174. /package/dist/{chunk-DnnnRqeS.js → rolldown-runtime-DnnnRqeS.js} +0 -0
package/LICENSE CHANGED
@@ -868,6 +868,36 @@ Repository: https://github.com/tinylibs/tinyexec
868
868
 
869
869
  ---------------------------------------
870
870
 
871
+ ## tsdown
872
+ License: MIT
873
+ By: Kevin Deng <sxzz@sxzz.moe>
874
+ Repository: https://github.com/rolldown/tsdown
875
+
876
+ > The MIT License (MIT)
877
+ >
878
+ > Copyright (c) 2025-present VoidZero Inc. & Contributors
879
+ > Copyright (c) 2024 Kevin Deng (https://github.com/sxzz)
880
+ >
881
+ > Permission is hereby granted, free of charge, to any person obtaining a copy
882
+ > of this software and associated documentation files (the "Software"), to deal
883
+ > in the Software without restriction, including without limitation the rights
884
+ > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
885
+ > copies of the Software, and to permit persons to whom the Software is
886
+ > furnished to do so, subject to the following conditions:
887
+ >
888
+ > The above copyright notice and this permission notice shall be included in all
889
+ > copies or substantial portions of the Software.
890
+ >
891
+ > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
892
+ > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
893
+ > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
894
+ > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
895
+ > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
896
+ > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
897
+ > SOFTWARE.
898
+
899
+ ---------------------------------------
900
+
871
901
  ## validate-npm-package-name
872
902
  License: ISC
873
903
  By: GitHub Inc.
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  **The Unified Toolchain for the Web**
4
4
  _runtime and package management, create, dev, check, test, build, pack, and monorepo task caching in a single dependency_
5
5
 
6
- This package provides the project-local version of Vite+. The global `vite` command automatically delegates to this package for all project-specific tasks.
6
+ This package provides the project-local version of Vite+. The global `vp` command automatically delegates to this package for all project-specific tasks.
7
7
 
8
8
  ---
9
9
 
@@ -111,6 +111,7 @@ Use `vp migrate` to migrate to Vite+. It merges tool-specific config files such
111
111
 
112
112
  - **run** - Run monorepo tasks
113
113
  - **exec** - Execute a command from local `node_modules/.bin`
114
+ - **node** - Run a Node.js script with the resolved Vite+ environment
114
115
  - **dlx** - Execute a package binary without installing it as a dependency
115
116
  - **cache** - Manage the task cache
116
117
 
@@ -122,7 +123,7 @@ Use `vp migrate` to migrate to Vite+. It merges tool-specific config files such
122
123
 
123
124
  #### Manage Dependencies
124
125
 
125
- Vite+ automatically wraps your package manager (pnpm, npm, or Yarn) based on `packageManager` and lockfiles:
126
+ Vite+ automatically wraps your package manager (pnpm, npm, Yarn, or Bun) based on `packageManager` and lockfiles:
126
127
 
127
128
  - **add** - Add packages to dependencies
128
129
  - **remove** (`rm`, `un`, `uninstall`) - Remove packages from dependencies
@@ -133,6 +134,7 @@ Vite+ automatically wraps your package manager (pnpm, npm, or Yarn) based on `pa
133
134
  - **why** (`explain`) - Show why a package is installed
134
135
  - **info** (`view`, `show`) - View package metadata from the registry
135
136
  - **link** (`ln`) / **unlink** - Manage local package links
137
+ - **rebuild** - Rebuild native modules
136
138
  - **pm** - Forward a command to the package manager
137
139
 
138
140
  #### Maintain
@@ -187,12 +189,12 @@ If you are manually migrating a project to Vite+, install these dev dependencies
187
189
  npm install -D vite-plus @voidzero-dev/vite-plus-core@latest
188
190
  ```
189
191
 
190
- You need to add overrides to your package manager for `vite` and `vitest` so that other packages depending on Vite and Vitest will use the Vite+ versions:
192
+ 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):
191
193
 
192
194
  ```json
193
195
  "overrides": {
194
196
  "vite": "npm:@voidzero-dev/vite-plus-core@latest",
195
- "vitest": "npm:@voidzero-dev/vite-plus-test@latest"
197
+ "vitest": "4.1.9"
196
198
  }
197
199
  ```
198
200
 
@@ -201,7 +203,7 @@ If you are using `pnpm`, add this to your `pnpm-workspace.yaml`:
201
203
  ```yaml
202
204
  overrides:
203
205
  vite: npm:@voidzero-dev/vite-plus-core@latest
204
- vitest: npm:@voidzero-dev/vite-plus-test@latest
206
+ vitest: 4.1.9
205
207
  ```
206
208
 
207
209
  Or, if you are using Yarn:
@@ -209,7 +211,7 @@ Or, if you are using Yarn:
209
211
  ```json
210
212
  "resolutions": {
211
213
  "vite": "npm:@voidzero-dev/vite-plus-core@latest",
212
- "vitest": "npm:@voidzero-dev/vite-plus-test@latest"
214
+ "vitest": "4.1.9"
213
215
  }
214
216
  ```
215
217
 
package/bin/oxfmt CHANGED
@@ -21,7 +21,10 @@ const require = createRequire(import.meta.url);
21
21
  const oxfmtMainPath = require.resolve('oxfmt');
22
22
  const oxfmtBin = join(dirname(dirname(oxfmtMainPath)), 'bin', 'oxfmt');
23
23
 
24
- // This allows oxfmt to load vite.config.ts
25
- // For `vp check` and `vp fmt`, it is injected by `merge_resolved_envs_with_version()` in `cli.rs`
24
+ // This allows oxfmt to load vite.config.ts.
25
+ // For `vp check` and `vp fmt`, VP_VERSION is injected by
26
+ // `merge_resolved_envs_with_version()` in `cli.rs`, and VP_COMMAND is injected
27
+ // by `SubcommandResolver::resolve()`.
26
28
  process.env.VP_VERSION = pkg.version;
29
+ process.env.VP_COMMAND ??= 'fmt';
27
30
  await import(pathToFileURL(oxfmtBin).href);
package/bin/oxlint CHANGED
@@ -13,13 +13,23 @@ if (!process.argv.includes('--lsp')) {
13
13
  import { createRequire } from 'node:module';
14
14
  import { dirname, join } from 'node:path';
15
15
  import { pathToFileURL } from 'node:url';
16
+ import { resolveTsgolintExecutable } from '../dist/tsgolint-path.js';
16
17
  import pkg from '../package.json' with { type: 'json' };
17
18
 
18
19
  const require = createRequire(import.meta.url);
19
20
  const oxlintMainPath = require.resolve('oxlint');
20
21
  const oxlintBin = join(dirname(dirname(oxlintMainPath)), 'bin', 'oxlint');
22
+ const tsgolintPackageJsonPath = require.resolve('oxlint-tsgolint/package.json');
23
+ const tsgolintBin = resolveTsgolintExecutable(
24
+ join(dirname(tsgolintPackageJsonPath), 'bin', 'tsgolint.js'),
25
+ import.meta.url,
26
+ );
21
27
 
22
- // This allows oxlint to load vite.config.ts
23
- // For `vp check` and `vp lint`, it is injected by `merge_resolved_envs_with_version()` in `cli.rs`
28
+ // This allows oxlint to load vite.config.ts.
29
+ // For `vp check` and `vp lint`, VP_VERSION is injected by
30
+ // `merge_resolved_envs_with_version()` in `cli.rs`, and VP_COMMAND is injected
31
+ // by `SubcommandResolver::resolve()`.
24
32
  process.env.VP_VERSION = pkg.version;
33
+ process.env.VP_COMMAND ??= 'lint';
34
+ process.env.OXLINT_TSGOLINT_PATH ??= tsgolintBin;
25
35
  await import(pathToFileURL(oxlintBin).href);
package/binding/index.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
  // @ts-nocheck
4
4
  /* auto-generated by NAPI-RS */
5
5
 
6
- const { readFileSync } = require('node:fs')
6
+ const { readFileSync } = require('fs')
7
7
  let nativeBinding = null;
8
8
  const loadErrors = [];
9
9
 
@@ -33,7 +33,7 @@ const isMuslFromFilesystem = () => {
33
33
 
34
34
  const isMuslFromReport = () => {
35
35
  let report = null;
36
- if (typeof process.report?.getReport === 'function') {
36
+ if (process.report && typeof process.report.getReport === 'function') {
37
37
  process.report.excludeNetwork = true;
38
38
  report = process.report.getReport();
39
39
  }
@@ -81,12 +81,12 @@ function requireNative() {
81
81
  const bindingPackageVersion =
82
82
  require('@voidzero-dev/vite-plus-android-arm64/package.json').version;
83
83
  if (
84
- bindingPackageVersion !== '0.1.24' &&
84
+ bindingPackageVersion !== '0.2.1' &&
85
85
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
86
86
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
87
87
  ) {
88
88
  throw new Error(
89
- `Native binding package version mismatch, expected 0.1.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
89
+ `Native binding package version mismatch, expected 0.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
90
90
  );
91
91
  }
92
92
  return binding;
@@ -104,12 +104,12 @@ function requireNative() {
104
104
  const bindingPackageVersion =
105
105
  require('@voidzero-dev/vite-plus-android-arm-eabi/package.json').version;
106
106
  if (
107
- bindingPackageVersion !== '0.1.24' &&
107
+ bindingPackageVersion !== '0.2.1' &&
108
108
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
109
109
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
110
110
  ) {
111
111
  throw new Error(
112
- `Native binding package version mismatch, expected 0.1.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
112
+ `Native binding package version mismatch, expected 0.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
113
113
  );
114
114
  }
115
115
  return binding;
@@ -122,8 +122,12 @@ function requireNative() {
122
122
  } else if (process.platform === 'win32') {
123
123
  if (process.arch === 'x64') {
124
124
  if (
125
- process.config?.variables?.shlib_suffix === 'dll.a' ||
126
- process.config?.variables?.node_target_type === 'shared_library'
125
+ (process.config &&
126
+ process.config.variables &&
127
+ process.config.variables.shlib_suffix === 'dll.a') ||
128
+ (process.config &&
129
+ process.config.variables &&
130
+ process.config.variables.node_target_type === 'shared_library')
127
131
  ) {
128
132
  try {
129
133
  return require('./vite-plus.win32-x64-gnu.node');
@@ -135,12 +139,12 @@ function requireNative() {
135
139
  const bindingPackageVersion =
136
140
  require('@voidzero-dev/vite-plus-win32-x64-gnu/package.json').version;
137
141
  if (
138
- bindingPackageVersion !== '0.1.24' &&
142
+ bindingPackageVersion !== '0.2.1' &&
139
143
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
140
144
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
141
145
  ) {
142
146
  throw new Error(
143
- `Native binding package version mismatch, expected 0.1.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
147
+ `Native binding package version mismatch, expected 0.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
144
148
  );
145
149
  }
146
150
  return binding;
@@ -158,12 +162,12 @@ function requireNative() {
158
162
  const bindingPackageVersion =
159
163
  require('@voidzero-dev/vite-plus-win32-x64-msvc/package.json').version;
160
164
  if (
161
- bindingPackageVersion !== '0.1.24' &&
165
+ bindingPackageVersion !== '0.2.1' &&
162
166
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
163
167
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
164
168
  ) {
165
169
  throw new Error(
166
- `Native binding package version mismatch, expected 0.1.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
170
+ `Native binding package version mismatch, expected 0.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
167
171
  );
168
172
  }
169
173
  return binding;
@@ -182,12 +186,12 @@ function requireNative() {
182
186
  const bindingPackageVersion =
183
187
  require('@voidzero-dev/vite-plus-win32-ia32-msvc/package.json').version;
184
188
  if (
185
- bindingPackageVersion !== '0.1.24' &&
189
+ bindingPackageVersion !== '0.2.1' &&
186
190
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
187
191
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
188
192
  ) {
189
193
  throw new Error(
190
- `Native binding package version mismatch, expected 0.1.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
194
+ `Native binding package version mismatch, expected 0.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
191
195
  );
192
196
  }
193
197
  return binding;
@@ -205,12 +209,12 @@ function requireNative() {
205
209
  const bindingPackageVersion =
206
210
  require('@voidzero-dev/vite-plus-win32-arm64-msvc/package.json').version;
207
211
  if (
208
- bindingPackageVersion !== '0.1.24' &&
212
+ bindingPackageVersion !== '0.2.1' &&
209
213
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
210
214
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
211
215
  ) {
212
216
  throw new Error(
213
- `Native binding package version mismatch, expected 0.1.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
217
+ `Native binding package version mismatch, expected 0.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
214
218
  );
215
219
  }
216
220
  return binding;
@@ -231,12 +235,12 @@ function requireNative() {
231
235
  const bindingPackageVersion =
232
236
  require('@voidzero-dev/vite-plus-darwin-universal/package.json').version;
233
237
  if (
234
- bindingPackageVersion !== '0.1.24' &&
238
+ bindingPackageVersion !== '0.2.1' &&
235
239
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
236
240
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
237
241
  ) {
238
242
  throw new Error(
239
- `Native binding package version mismatch, expected 0.1.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
243
+ `Native binding package version mismatch, expected 0.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
240
244
  );
241
245
  }
242
246
  return binding;
@@ -254,12 +258,12 @@ function requireNative() {
254
258
  const bindingPackageVersion =
255
259
  require('@voidzero-dev/vite-plus-darwin-x64/package.json').version;
256
260
  if (
257
- bindingPackageVersion !== '0.1.24' &&
261
+ bindingPackageVersion !== '0.2.1' &&
258
262
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
259
263
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
260
264
  ) {
261
265
  throw new Error(
262
- `Native binding package version mismatch, expected 0.1.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
266
+ `Native binding package version mismatch, expected 0.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
263
267
  );
264
268
  }
265
269
  return binding;
@@ -277,12 +281,12 @@ function requireNative() {
277
281
  const bindingPackageVersion =
278
282
  require('@voidzero-dev/vite-plus-darwin-arm64/package.json').version;
279
283
  if (
280
- bindingPackageVersion !== '0.1.24' &&
284
+ bindingPackageVersion !== '0.2.1' &&
281
285
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
282
286
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
283
287
  ) {
284
288
  throw new Error(
285
- `Native binding package version mismatch, expected 0.1.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
289
+ `Native binding package version mismatch, expected 0.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
286
290
  );
287
291
  }
288
292
  return binding;
@@ -304,12 +308,12 @@ function requireNative() {
304
308
  const bindingPackageVersion =
305
309
  require('@voidzero-dev/vite-plus-freebsd-x64/package.json').version;
306
310
  if (
307
- bindingPackageVersion !== '0.1.24' &&
311
+ bindingPackageVersion !== '0.2.1' &&
308
312
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
309
313
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
310
314
  ) {
311
315
  throw new Error(
312
- `Native binding package version mismatch, expected 0.1.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
316
+ `Native binding package version mismatch, expected 0.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
313
317
  );
314
318
  }
315
319
  return binding;
@@ -327,12 +331,12 @@ function requireNative() {
327
331
  const bindingPackageVersion =
328
332
  require('@voidzero-dev/vite-plus-freebsd-arm64/package.json').version;
329
333
  if (
330
- bindingPackageVersion !== '0.1.24' &&
334
+ bindingPackageVersion !== '0.2.1' &&
331
335
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
332
336
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
333
337
  ) {
334
338
  throw new Error(
335
- `Native binding package version mismatch, expected 0.1.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
339
+ `Native binding package version mismatch, expected 0.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
336
340
  );
337
341
  }
338
342
  return binding;
@@ -355,12 +359,12 @@ function requireNative() {
355
359
  const bindingPackageVersion =
356
360
  require('@voidzero-dev/vite-plus-linux-x64-musl/package.json').version;
357
361
  if (
358
- bindingPackageVersion !== '0.1.24' &&
362
+ bindingPackageVersion !== '0.2.1' &&
359
363
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
360
364
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
361
365
  ) {
362
366
  throw new Error(
363
- `Native binding package version mismatch, expected 0.1.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
367
+ `Native binding package version mismatch, expected 0.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
364
368
  );
365
369
  }
366
370
  return binding;
@@ -378,12 +382,12 @@ function requireNative() {
378
382
  const bindingPackageVersion =
379
383
  require('@voidzero-dev/vite-plus-linux-x64-gnu/package.json').version;
380
384
  if (
381
- bindingPackageVersion !== '0.1.24' &&
385
+ bindingPackageVersion !== '0.2.1' &&
382
386
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
383
387
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
384
388
  ) {
385
389
  throw new Error(
386
- `Native binding package version mismatch, expected 0.1.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
390
+ `Native binding package version mismatch, expected 0.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
387
391
  );
388
392
  }
389
393
  return binding;
@@ -403,12 +407,12 @@ function requireNative() {
403
407
  const bindingPackageVersion =
404
408
  require('@voidzero-dev/vite-plus-linux-arm64-musl/package.json').version;
405
409
  if (
406
- bindingPackageVersion !== '0.1.24' &&
410
+ bindingPackageVersion !== '0.2.1' &&
407
411
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
408
412
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
409
413
  ) {
410
414
  throw new Error(
411
- `Native binding package version mismatch, expected 0.1.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
415
+ `Native binding package version mismatch, expected 0.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
412
416
  );
413
417
  }
414
418
  return binding;
@@ -426,12 +430,12 @@ function requireNative() {
426
430
  const bindingPackageVersion =
427
431
  require('@voidzero-dev/vite-plus-linux-arm64-gnu/package.json').version;
428
432
  if (
429
- bindingPackageVersion !== '0.1.24' &&
433
+ bindingPackageVersion !== '0.2.1' &&
430
434
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
431
435
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
432
436
  ) {
433
437
  throw new Error(
434
- `Native binding package version mismatch, expected 0.1.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
438
+ `Native binding package version mismatch, expected 0.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
435
439
  );
436
440
  }
437
441
  return binding;
@@ -451,12 +455,12 @@ function requireNative() {
451
455
  const bindingPackageVersion =
452
456
  require('@voidzero-dev/vite-plus-linux-arm-musleabihf/package.json').version;
453
457
  if (
454
- bindingPackageVersion !== '0.1.24' &&
458
+ bindingPackageVersion !== '0.2.1' &&
455
459
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
456
460
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
457
461
  ) {
458
462
  throw new Error(
459
- `Native binding package version mismatch, expected 0.1.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
463
+ `Native binding package version mismatch, expected 0.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
460
464
  );
461
465
  }
462
466
  return binding;
@@ -474,12 +478,12 @@ function requireNative() {
474
478
  const bindingPackageVersion =
475
479
  require('@voidzero-dev/vite-plus-linux-arm-gnueabihf/package.json').version;
476
480
  if (
477
- bindingPackageVersion !== '0.1.24' &&
481
+ bindingPackageVersion !== '0.2.1' &&
478
482
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
479
483
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
480
484
  ) {
481
485
  throw new Error(
482
- `Native binding package version mismatch, expected 0.1.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
486
+ `Native binding package version mismatch, expected 0.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
483
487
  );
484
488
  }
485
489
  return binding;
@@ -499,12 +503,12 @@ function requireNative() {
499
503
  const bindingPackageVersion =
500
504
  require('@voidzero-dev/vite-plus-linux-loong64-musl/package.json').version;
501
505
  if (
502
- bindingPackageVersion !== '0.1.24' &&
506
+ bindingPackageVersion !== '0.2.1' &&
503
507
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
504
508
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
505
509
  ) {
506
510
  throw new Error(
507
- `Native binding package version mismatch, expected 0.1.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
511
+ `Native binding package version mismatch, expected 0.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
508
512
  );
509
513
  }
510
514
  return binding;
@@ -522,12 +526,12 @@ function requireNative() {
522
526
  const bindingPackageVersion =
523
527
  require('@voidzero-dev/vite-plus-linux-loong64-gnu/package.json').version;
524
528
  if (
525
- bindingPackageVersion !== '0.1.24' &&
529
+ bindingPackageVersion !== '0.2.1' &&
526
530
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
527
531
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
528
532
  ) {
529
533
  throw new Error(
530
- `Native binding package version mismatch, expected 0.1.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
534
+ `Native binding package version mismatch, expected 0.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
531
535
  );
532
536
  }
533
537
  return binding;
@@ -547,12 +551,12 @@ function requireNative() {
547
551
  const bindingPackageVersion =
548
552
  require('@voidzero-dev/vite-plus-linux-riscv64-musl/package.json').version;
549
553
  if (
550
- bindingPackageVersion !== '0.1.24' &&
554
+ bindingPackageVersion !== '0.2.1' &&
551
555
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
552
556
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
553
557
  ) {
554
558
  throw new Error(
555
- `Native binding package version mismatch, expected 0.1.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
559
+ `Native binding package version mismatch, expected 0.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
556
560
  );
557
561
  }
558
562
  return binding;
@@ -570,12 +574,12 @@ function requireNative() {
570
574
  const bindingPackageVersion =
571
575
  require('@voidzero-dev/vite-plus-linux-riscv64-gnu/package.json').version;
572
576
  if (
573
- bindingPackageVersion !== '0.1.24' &&
577
+ bindingPackageVersion !== '0.2.1' &&
574
578
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
575
579
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
576
580
  ) {
577
581
  throw new Error(
578
- `Native binding package version mismatch, expected 0.1.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
582
+ `Native binding package version mismatch, expected 0.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
579
583
  );
580
584
  }
581
585
  return binding;
@@ -594,12 +598,12 @@ function requireNative() {
594
598
  const bindingPackageVersion =
595
599
  require('@voidzero-dev/vite-plus-linux-ppc64-gnu/package.json').version;
596
600
  if (
597
- bindingPackageVersion !== '0.1.24' &&
601
+ bindingPackageVersion !== '0.2.1' &&
598
602
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
599
603
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
600
604
  ) {
601
605
  throw new Error(
602
- `Native binding package version mismatch, expected 0.1.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
606
+ `Native binding package version mismatch, expected 0.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
603
607
  );
604
608
  }
605
609
  return binding;
@@ -617,12 +621,12 @@ function requireNative() {
617
621
  const bindingPackageVersion =
618
622
  require('@voidzero-dev/vite-plus-linux-s390x-gnu/package.json').version;
619
623
  if (
620
- bindingPackageVersion !== '0.1.24' &&
624
+ bindingPackageVersion !== '0.2.1' &&
621
625
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
622
626
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
623
627
  ) {
624
628
  throw new Error(
625
- `Native binding package version mismatch, expected 0.1.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
629
+ `Native binding package version mismatch, expected 0.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
626
630
  );
627
631
  }
628
632
  return binding;
@@ -644,12 +648,12 @@ function requireNative() {
644
648
  const bindingPackageVersion =
645
649
  require('@voidzero-dev/vite-plus-openharmony-arm64/package.json').version;
646
650
  if (
647
- bindingPackageVersion !== '0.1.24' &&
651
+ bindingPackageVersion !== '0.2.1' &&
648
652
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
649
653
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
650
654
  ) {
651
655
  throw new Error(
652
- `Native binding package version mismatch, expected 0.1.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
656
+ `Native binding package version mismatch, expected 0.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
653
657
  );
654
658
  }
655
659
  return binding;
@@ -667,12 +671,12 @@ function requireNative() {
667
671
  const bindingPackageVersion =
668
672
  require('@voidzero-dev/vite-plus-openharmony-x64/package.json').version;
669
673
  if (
670
- bindingPackageVersion !== '0.1.24' &&
674
+ bindingPackageVersion !== '0.2.1' &&
671
675
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
672
676
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
673
677
  ) {
674
678
  throw new Error(
675
- `Native binding package version mismatch, expected 0.1.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
679
+ `Native binding package version mismatch, expected 0.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
676
680
  );
677
681
  }
678
682
  return binding;
@@ -690,12 +694,12 @@ function requireNative() {
690
694
  const bindingPackageVersion =
691
695
  require('@voidzero-dev/vite-plus-openharmony-arm/package.json').version;
692
696
  if (
693
- bindingPackageVersion !== '0.1.24' &&
697
+ bindingPackageVersion !== '0.2.1' &&
694
698
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
695
699
  process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
696
700
  ) {
697
701
  throw new Error(
698
- `Native binding package version mismatch, expected 0.1.24 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
702
+ `Native binding package version mismatch, expected 0.2.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
699
703
  );
700
704
  }
701
705
  return binding;
@@ -714,23 +718,33 @@ function requireNative() {
714
718
 
715
719
  nativeBinding = requireNative();
716
720
 
717
- if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
721
+ // NAPI_RS_FORCE_WASI is a tri-state flag:
722
+ // unset / any other value → native binding preferred, WASI is only a fallback
723
+ // 'true' → force WASI fallback even if native loaded
724
+ // 'error' → force WASI and throw if no WASI binding is found
725
+ // Treating any non-empty string as truthy (the historical behavior) meant
726
+ // NAPI_RS_FORCE_WASI=false, NAPI_RS_FORCE_WASI=0, etc. inadvertently triggered
727
+ // the WASI path, causing ENOENT for packages shipped without a .wasi.cjs file.
728
+ const forceWasi =
729
+ process.env.NAPI_RS_FORCE_WASI === 'true' || process.env.NAPI_RS_FORCE_WASI === 'error';
730
+
731
+ if (!nativeBinding || forceWasi) {
718
732
  let wasiBinding = null;
719
733
  let wasiBindingError = null;
720
734
  try {
721
735
  wasiBinding = require('./vite-plus.wasi.cjs');
722
736
  nativeBinding = wasiBinding;
723
737
  } catch (err) {
724
- if (process.env.NAPI_RS_FORCE_WASI) {
738
+ if (forceWasi) {
725
739
  wasiBindingError = err;
726
740
  }
727
741
  }
728
- if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
742
+ if (!nativeBinding || forceWasi) {
729
743
  try {
730
744
  wasiBinding = require('@voidzero-dev/vite-plus-wasm32-wasi');
731
745
  nativeBinding = wasiBinding;
732
746
  } catch (err) {
733
- if (process.env.NAPI_RS_FORCE_WASI) {
747
+ if (forceWasi) {
734
748
  if (!wasiBindingError) {
735
749
  wasiBindingError = err;
736
750
  } else {
@@ -749,17 +763,18 @@ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
749
763
 
750
764
  if (!nativeBinding) {
751
765
  if (loadErrors.length > 0) {
752
- throw new Error(
766
+ const error = new Error(
753
767
  `Cannot find native binding. ` +
754
768
  `npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
755
769
  'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
756
- {
757
- cause: loadErrors.reduce((err, cur) => {
758
- cur.cause = err;
759
- return cur;
760
- }),
761
- },
762
770
  );
771
+ // assign instead of the `new Error(message, { cause })` options form,
772
+ // which Node < 16.9 silently ignores
773
+ error.cause = loadErrors.reduce((err, cur) => {
774
+ cur.cause = err;
775
+ return cur;
776
+ });
777
+ throw error;
763
778
  }
764
779
  throw new Error(`Failed to load native binding`);
765
780
  }
@@ -844,4 +859,6 @@ module.exports.rewriteScripts = nativeBinding.rewriteScripts;
844
859
  module.exports.run = nativeBinding.run;
845
860
  module.exports.runCommand = nativeBinding.runCommand;
846
861
  module.exports.shouldPrintVitePlusHeader = nativeBinding.shouldPrintVitePlusHeader;
862
+ module.exports.upsertJsonConfig = nativeBinding.upsertJsonConfig;
847
863
  module.exports.vitePlusHeader = nativeBinding.vitePlusHeader;
864
+ module.exports.wrapLazyPlugins = nativeBinding.wrapLazyPlugins;