Skip to content

Commit a8ee127

Browse files
authored
Merge branch 'main' into fix/bundle-tsdown-exe-css
2 parents 9cda4c3 + 2c96a03 commit a8ee127

51 files changed

Lines changed: 510 additions & 112 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/test-vp-create.yml

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,6 @@ jobs:
195195
# `YN0016 ... are quarantined`. The migrate tool is version-pinned to the
196196
# bundled oxlint, so disable the gate for this test (no-op for npm/pnpm/bun).
197197
YARN_NPM_MINIMAL_AGE_GATE: '0'
198-
# pnpm 11's default `minimumReleaseAge` (~24h) makes the bundled vitest's
199-
# auto-installed `vite` peer resolve to the previous upstream release,
200-
# which can predate vite's `@voidzero-dev/vite-task-client` integration and
201-
# surface a false `vp test` cache miss in "Verify cache". Force 0 so the
202-
# latest vite (with the integration) is used. pnpm-only (no-op elsewhere).
203-
# Temporary band-aid; real fix tracked in voidzero-dev/vite-plus#1932.
204-
PNPM_CONFIG_MINIMUM_RELEASE_AGE: '0'
205198
steps:
206199
- uses: taiki-e/checkout-action@7d1e50e93dc4fb3bba58f85018fadf77898aee8b # v1.4.2
207200

@@ -300,6 +293,47 @@ jobs:
300293
esac
301294
fi
302295
296+
- name: Verify single dependency instances (pnpm only)
297+
if: matrix.package-manager == 'pnpm'
298+
working-directory: ${{ runner.temp }}/test-project
299+
run: |
300+
# The `vite` override must dedupe vite-plus / vite / vitest to a single
301+
# instance each. When a peer variation splits the graph (e.g. an upstream
302+
# `vite` auto-installed to satisfy vitest's peer in a package without a
303+
# direct `vite` dep), `vp why` reports multiple instances. Detection:
304+
# - vite-plus / vitest: a split prints "Found 1 version, N instances of <pkg>".
305+
# - vite: it is overridden to @voidzero-dev/vite-plus-core, so a clean tree
306+
# only summarises that package; a standalone upstream copy adds a
307+
# "Found <n> version(s) of vite" line.
308+
# Regression guard for voidzero-dev/vite-plus#1932 (the pnpm dedupe fix).
309+
# `-r` checks every workspace package, not just the root importer, so a
310+
# duplicate confined to a sub-package (apps/website, packages/utils) is
311+
# still caught.
312+
fail=0
313+
check() {
314+
pkg="$1"; pattern="$2"
315+
out=$(vp why -r "$pkg" 2>&1)
316+
found=$(echo "$out" | grep '^Found' || true)
317+
echo "[$pkg]"; echo "$found"
318+
if echo "$found" | grep -qE "$pattern"; then
319+
echo "✗ $pkg is not a single instance (override did not dedupe under pnpm)"
320+
echo "----- full \`vp why -r $pkg\` output -----"
321+
echo "$out"
322+
echo "---------------------------------------"
323+
fail=1
324+
else
325+
echo "✓ $pkg single instance"
326+
fi
327+
}
328+
check vite-plus 'instances of vite-plus'
329+
check vitest 'instances of vitest'
330+
check vite 'of vite$'
331+
if [ "$fail" -ne 0 ]; then
332+
echo "Expected vite-plus, vite, and vitest to each resolve to a single instance."
333+
exit 1
334+
fi
335+
echo "✓ vite-plus, vite, vitest are all single instances"
336+
303337
- name: Verify local tgz packages installed
304338
working-directory: ${{ runner.temp }}/test-project
305339
run: |

docs/guide/install.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ Examples:
177177

178178
```bash
179179
vp pm config get registry
180-
vp pm cache clean --force
181-
vp pm exec tsc --version
180+
vp pm cache clean -- --force
181+
vp pm audit --json
182182
```
183183

184184
#### Staged publishing

docs/guide/troubleshooting.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export default defineConfig({
6969

7070
When `vite.config.ts` imports plugins at the top level, they are evaluated for every command, including `vp lint`, `vp fmt`, editor integrations, and long-lived background processes. This can make config loading slow and may trigger plugin setup side effects, such as reading files, starting watchers, or connecting to services.
7171

72-
Use `lazyPlugins` to load plugins only when the Vite pipeline actually runs (`dev`, `build`, `test`, `preview`):
72+
Use `lazyPlugins` to skip the plugin factory when vite-plus loads your config only to read a metadata block (`lint`, `fmt`, `check`, `staged`, `pack`, `create`, the `run`/`cache` task lookup, and editor tooling). The plugins still load whenever Vite actually runs, `dev`, `build`, `test`, `preview`, and any build your own scripts spawn (a `vp run` task, `vp exec`):
7373

7474
```ts [vite.config.ts]
7575
import { defineConfig, lazyPlugins } from 'vite-plus';

packages/cli/bin/oxfmt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,11 @@ const oxfmtBin = join(dirname(dirname(oxfmtMainPath)), 'bin', 'oxfmt');
2323

2424
// This allows oxfmt to load vite.config.ts.
2525
// 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+
// `merge_resolved_envs_with_version()` in `cli.rs`.
2827
process.env.VP_VERSION = pkg.version;
29-
process.env.VP_COMMAND ??= 'fmt';
28+
// oxfmt reads vite.config.ts only for the `fmt` block, so skip the user's
29+
// Vite plugin factory (lazyPlugins) while the config evaluates.
30+
// Literal kept in sync with CONFIG_METADATA_ENV in src/utils/constants.ts
31+
// (this plain-JS bin can't import the bundled constant).
32+
process.env.VP_RESOLVING_CONFIG_METADATA ??= '1';
3033
await import(pathToFileURL(oxfmtBin).href);

packages/cli/bin/oxlint

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,12 @@ const tsgolintBin = resolveTsgolintExecutable(
2727

2828
// This allows oxlint to load vite.config.ts.
2929
// 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()`.
30+
// `merge_resolved_envs_with_version()` in `cli.rs`.
3231
process.env.VP_VERSION = pkg.version;
33-
process.env.VP_COMMAND ??= 'lint';
32+
// oxlint reads vite.config.ts only for the `lint` block, so skip the user's
33+
// Vite plugin factory (lazyPlugins) while the config evaluates.
34+
// Literal kept in sync with CONFIG_METADATA_ENV in src/utils/constants.ts
35+
// (this plain-JS bin can't import the bundled constant).
36+
process.env.VP_RESOLVING_CONFIG_METADATA ??= '1';
3437
process.env.OXLINT_TSGOLINT_PATH ??= tsgolintBin;
3538
await import(pathToFileURL(oxlintBin).href);

packages/cli/binding/src/cli/resolver.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,7 @@ impl SubcommandResolver {
6868
resolved_vite_config: Option<&ResolvedUniversalViteConfig>,
6969
envs: &Arc<FxHashMap<Arc<OsStr>, Arc<OsStr>>>,
7070
) -> anyhow::Result<ResolvedSubcommand> {
71-
let command_name = subcommand.command_name();
72-
let mut resolved = self.resolve_inner(subcommand, resolved_vite_config, envs).await?;
73-
// Inject VP_COMMAND so that defineConfig's plugin factory knows which command is running,
74-
// even when the subcommand is synthesized inside `vp run`.
75-
let envs = Arc::make_mut(&mut resolved.envs);
76-
envs.insert(Arc::from(OsStr::new("VP_COMMAND")), Arc::from(OsStr::new(command_name)));
77-
Ok(resolved)
71+
self.resolve_inner(subcommand, resolved_vite_config, envs).await
7872
}
7973

8074
async fn resolve_inner(

packages/cli/binding/src/cli/types.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -96,23 +96,6 @@ pub enum SynthesizableSubcommand {
9696
},
9797
}
9898

99-
impl SynthesizableSubcommand {
100-
/// Return the command name string for use in `VP_COMMAND` env var.
101-
pub(super) fn command_name(&self) -> &'static str {
102-
match self {
103-
Self::Lint { .. } => "lint",
104-
Self::Fmt { .. } => "fmt",
105-
Self::Build { .. } => "build",
106-
Self::Test { .. } => "test",
107-
Self::Pack { .. } => "pack",
108-
Self::Dev { .. } => "dev",
109-
Self::Preview { .. } => "preview",
110-
Self::Doc { .. } => "doc",
111-
Self::Check { .. } => "check",
112-
}
113-
}
114-
}
115-
11699
/// Top-level CLI argument parser for vite-plus.
117100
#[derive(Debug, Parser)]
118101
#[command(name = "vp", disable_help_subcommand = true)]

packages/cli/snap-tests-global/migration-auto-create-vite-config/snap.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export default defineConfig({
4040
> cat package.json # check package.json
4141
{
4242
"devDependencies": {
43+
"vite": "catalog:",
4344
"vite-plus": "catalog:"
4445
},
4546
"devEngines": {

packages/cli/snap-tests-global/migration-baseurl-tsconfig/snap.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export default defineConfig({
4343
> cat package.json # check package.json
4444
{
4545
"devDependencies": {
46+
"vite": "catalog:",
4647
"vite-plus": "catalog:"
4748
},
4849
"devEngines": {

packages/cli/snap-tests-global/migration-lintstagedrc-json/snap.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ Documentation: https://viteplus.dev/guide/migrate
8383
{
8484
"name": "migration-lintstagedrc",
8585
"devDependencies": {
86+
"vite": "catalog:",
8687
"vite-plus": "catalog:"
8788
},
8889
"devEngines": {

0 commit comments

Comments
 (0)