From d1334af5777beb62043f571127a07bbe2bb56287 Mon Sep 17 00:00:00 2001 From: MK Date: Mon, 3 Aug 2026 15:44:53 +0800 Subject: [PATCH 1/7] feat(cli): per-command defaultPackage defaultPackage now also accepts an object mapping the four app commands individually ({ dev: './apps/web', pack: './packages/ui' }), so one repo can pack a library while dev targets an app (#2031 review). A string keeps meaning one directory for all four commands, and a command absent from the object falls through to the picker/listing resolution. Values stay static string literals read without executing the config. --- .../per_command/frontend/index.html | 6 ++++ .../per_command/frontend/package.json | 1 + .../per_command/lib/package.json | 1 + .../per_command/lib/src/index.ts | 1 + .../per_command/package.json | 1 + .../per_command/vite.config.ts | 3 ++ .../per_command_fallthrough/index.html | 6 ++++ .../per_command_fallthrough/lib/package.json | 1 + .../per_command_fallthrough/lib/src/index.ts | 1 + .../per_command_fallthrough/package.json | 1 + .../per_command_fallthrough/vite.config.ts | 3 ++ .../app_root_default_package/snapshots.toml | 23 ++++++++++++++ .../default_package_per_command.global.md | 31 +++++++++++++++++++ .../default_package_per_command.local.md | 27 ++++++++++++++++ ..._package_per_command_fallthrough.global.md | 17 ++++++++++ ...t_package_per_command_fallthrough.local.md | 15 +++++++++ docs/config/index.md | 2 +- docs/guide/monorepo.md | 8 +++++ packages/cli/binding/src/cli/app_target.rs | 24 ++++++++++++-- packages/cli/src/define-config.ts | 15 ++++++--- rfcs/cwd-flag.md | 2 +- 21 files changed, 180 insertions(+), 9 deletions(-) create mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/frontend/index.html create mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/frontend/package.json create mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/lib/package.json create mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/lib/src/index.ts create mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/package.json create mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/vite.config.ts create mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/index.html create mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/lib/package.json create mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/lib/src/index.ts create mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/package.json create mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/vite.config.ts create mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command.global.md create mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command.local.md create mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command_fallthrough.global.md create mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command_fallthrough.local.md diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/frontend/index.html b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/frontend/index.html new file mode 100644 index 0000000000..af5534a716 --- /dev/null +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/frontend/index.html @@ -0,0 +1,6 @@ + + + +

frontend

+ + diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/frontend/package.json b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/frontend/package.json new file mode 100644 index 0000000000..8314f0679b --- /dev/null +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/frontend/package.json @@ -0,0 +1 @@ +{ "name": "frontend", "private": true } diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/lib/package.json b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/lib/package.json new file mode 100644 index 0000000000..cc2149de27 --- /dev/null +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/lib/package.json @@ -0,0 +1 @@ +{ "name": "lib", "private": true } diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/lib/src/index.ts b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/lib/src/index.ts new file mode 100644 index 0000000000..da7d8c9665 --- /dev/null +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/lib/src/index.ts @@ -0,0 +1 @@ +export const lib = 'lib'; diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/package.json b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/package.json new file mode 100644 index 0000000000..7d435299d4 --- /dev/null +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/package.json @@ -0,0 +1 @@ +{ "name": "per-command-config", "private": true } diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/vite.config.ts b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/vite.config.ts new file mode 100644 index 0000000000..13eec31456 --- /dev/null +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/vite.config.ts @@ -0,0 +1,3 @@ +export default { + defaultPackage: { build: './frontend', pack: './lib' }, +}; diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/index.html b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/index.html new file mode 100644 index 0000000000..31acf91c54 --- /dev/null +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/index.html @@ -0,0 +1,6 @@ + + + +

root app

+ + diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/lib/package.json b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/lib/package.json new file mode 100644 index 0000000000..cc2149de27 --- /dev/null +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/lib/package.json @@ -0,0 +1 @@ +{ "name": "lib", "private": true } diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/lib/src/index.ts b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/lib/src/index.ts new file mode 100644 index 0000000000..da7d8c9665 --- /dev/null +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/lib/src/index.ts @@ -0,0 +1 @@ +export const lib = 'lib'; diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/package.json b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/package.json new file mode 100644 index 0000000000..08deaafa1c --- /dev/null +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/package.json @@ -0,0 +1 @@ +{ "name": "per-command-fallthrough", "private": true } diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/vite.config.ts b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/vite.config.ts new file mode 100644 index 0000000000..19d1c8f913 --- /dev/null +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/vite.config.ts @@ -0,0 +1,3 @@ +export default { + defaultPackage: { pack: './lib' }, +}; diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots.toml b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots.toml index b8e0be78a5..250c622983 100644 --- a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots.toml +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots.toml @@ -59,3 +59,26 @@ defaultPackage inside `defineConfig({ ... } satisfies UserConfig)` is also honored: the wrapper on the defineConfig argument is unwrapped too. """ steps = [{ argv = ["vp", "build"], cwd = "dc_wrapper" }] + +[[case]] +name = "default_package_per_command" +vp = ["local", "global"] +comment = """ +The object form maps commands individually: `vp build` targets ./frontend +while `vp pack` targets ./lib, so one repo can dev an app and pack a +library (rfcs/cwd-flag.md). +""" +steps = [ + { argv = ["vp", "build"], cwd = "per_command" }, + { argv = ["vp", "pack"], cwd = "per_command" }, +] + +[[case]] +name = "default_package_per_command_fallthrough" +vp = ["local", "global"] +comment = """ +A command absent from the defaultPackage object falls through to the +normal resolution: the map only declares `pack`, so bare `vp build` runs +in place at the (runnable) root with no note. +""" +steps = [{ argv = ["vp", "build"], cwd = "per_command_fallthrough" }] diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command.global.md b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command.global.md new file mode 100644 index 0000000000..9659d08d87 --- /dev/null +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command.global.md @@ -0,0 +1,31 @@ +# default_package_per_command + +The object form maps commands individually: `vp build` targets ./frontend +while `vp pack` targets ./lib, so one repo can dev an app and pack a +library (rfcs/cwd-flag.md). + +## `cd per_command && vp build` + +``` +VITE+ - The Unified Toolchain for the Web + +note: vp build: using ./frontend (defaultPackage in vite.config.ts) +✓ 2 modules transformed. +computing gzip size... +dist/index.html kB │ gzip: kB + +✓ built in +``` + +## `cd per_command && vp pack` + +``` +VITE+ - The Unified Toolchain for the Web + +note: vp pack: using ./lib (defaultPackage in vite.config.ts) +ℹ entry: src/index.ts +ℹ Build start +ℹ dist/index.mjs kB │ gzip: kB +ℹ 1 files, total: kB +✔ Build complete in +``` diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command.local.md b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command.local.md new file mode 100644 index 0000000000..3271a5e885 --- /dev/null +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command.local.md @@ -0,0 +1,27 @@ +# default_package_per_command + +The object form maps commands individually: `vp build` targets ./frontend +while `vp pack` targets ./lib, so one repo can dev an app and pack a +library (rfcs/cwd-flag.md). + +## `cd per_command && vp build` + +``` +note: vp build: using ./frontend (defaultPackage in vite.config.ts) +✓ 2 modules transformed. +computing gzip size... +dist/index.html kB │ gzip: kB + +✓ built in +``` + +## `cd per_command && vp pack` + +``` +note: vp pack: using ./lib (defaultPackage in vite.config.ts) +ℹ entry: src/index.ts +ℹ Build start +ℹ dist/index.mjs kB │ gzip: kB +ℹ 1 files, total: kB +✔ Build complete in +``` diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command_fallthrough.global.md b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command_fallthrough.global.md new file mode 100644 index 0000000000..8c8b9baa06 --- /dev/null +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command_fallthrough.global.md @@ -0,0 +1,17 @@ +# default_package_per_command_fallthrough + +A command absent from the defaultPackage object falls through to the +normal resolution: the map only declares `pack`, so bare `vp build` runs +in place at the (runnable) root with no note. + +## `cd per_command_fallthrough && vp build` + +``` +VITE+ - The Unified Toolchain for the Web + +✓ 2 modules transformed. +computing gzip size... +dist/index.html kB │ gzip: kB + +✓ built in +``` diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command_fallthrough.local.md b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command_fallthrough.local.md new file mode 100644 index 0000000000..0172f1f529 --- /dev/null +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command_fallthrough.local.md @@ -0,0 +1,15 @@ +# default_package_per_command_fallthrough + +A command absent from the defaultPackage object falls through to the +normal resolution: the map only declares `pack`, so bare `vp build` runs +in place at the (runnable) root with no note. + +## `cd per_command_fallthrough && vp build` + +``` +✓ 2 modules transformed. +computing gzip size... +dist/index.html kB │ gzip: kB + +✓ built in +``` diff --git a/docs/config/index.md b/docs/config/index.md index 97e51c8ef9..bfab9ef6c5 100644 --- a/docs/config/index.md +++ b/docs/config/index.md @@ -45,4 +45,4 @@ export default { }; ``` -vp reads the value without executing the config, so `defaultPackage` also works at repository roots with no vite-plus dependency (for example a Laravel or Rails repo whose Vite app lives in `frontend/`, with vite-plus installed only there). That static read is why the value must stay a plain string literal rather than an expression. An explicit `-C` or positional target always wins over the config. +vp reads the values without executing the config, so `defaultPackage` also works at repository roots with no vite-plus dependency (for example a Laravel or Rails repo whose Vite app lives in `frontend/`, with vite-plus installed only there). That static read is why the values must stay plain string literals rather than expressions. An explicit `-C` or positional target always wins over the config. diff --git a/docs/guide/monorepo.md b/docs/guide/monorepo.md index e040d32d8f..60caef9ae8 100644 --- a/docs/guide/monorepo.md +++ b/docs/guide/monorepo.md @@ -232,6 +232,14 @@ note: vp dev: using ./apps/web (defaultPackage in vite.config.ts) This is the right choice for framework monorepos that are not JavaScript workspaces, such as a Laravel or Rails app with a `frontend/` directory: there is no package list to resolve, so `defaultPackage` points vp straight at the app. Because vp reads it without executing the config, it works even when `vite-plus` is installed only inside that subdirectory. +An object form maps commands individually, so `vp pack` can target a library while `vp dev` targets an app; a command absent from the object falls through to the resolution above: + +```ts [vite.config.ts] +export default { + defaultPackage: { dev: './apps/web', pack: './packages/ui' }, +}; +``` + ### Package scripts and workspace-wide tasks Keep package-specific scripts in each package when the command differs per app: diff --git a/packages/cli/binding/src/cli/app_target.rs b/packages/cli/binding/src/cli/app_target.rs index 283f7582df..ff361f45a4 100644 --- a/packages/cli/binding/src/cli/app_target.rs +++ b/packages/cli/binding/src/cli/app_target.rs @@ -332,6 +332,24 @@ enum Elicitation { WorkspaceRoot(vite_workspace::WorkspaceRoot), } +/// Applies a `defaultPackage` declaration to one command. A string covers +/// all four app commands; an object maps commands individually +/// (`{ dev: './apps/web', pack: './packages/ui' }`), and a command absent +/// from the object falls through to the picker/listing resolution. Every +/// other shape (a non-string, a non-static value) passes through for +/// [`resolve_default_package`] to report. +fn default_package_for_command( + command: &str, + value: vite_static_config::FieldValue, +) -> Option { + match value { + vite_static_config::FieldValue::Json(serde_json::Value::Object(map)) => { + map.get(command).cloned().map(vite_static_config::FieldValue::Json) + } + other => Some(other), + } +} + /// The RFC's resolution order, written once for both entry points: bare app /// command, then `defaultPackage` at the invocation root, then the workspace /// root itself. `defaultPackage` is a root-pointer concept: it applies where @@ -356,8 +374,10 @@ fn classify(subcommand: &SynthesizableSubcommand, cwd: &AbsolutePath) -> Classif // Resolved once and reused by `root_looks_runnable` below, so a bare // command at a root reads and parses the config a single time. let root_config = at_invocation_root.then(|| vite_static_config::resolve_static_config(cwd)); - if let Some(value) = - root_config.as_ref().and_then(|config| config.get_declared("defaultPackage")) + if let Some(value) = root_config + .as_ref() + .and_then(|config| config.get_declared("defaultPackage")) + .and_then(|value| default_package_for_command(command, value)) { return Classification::Elicit(command, Elicitation::DefaultPackage(value)); } diff --git a/packages/cli/src/define-config.ts b/packages/cli/src/define-config.ts index dada43d187..caa60db112 100644 --- a/packages/cli/src/define-config.ts +++ b/packages/cli/src/define-config.ts @@ -56,12 +56,17 @@ declare module '@voidzero-dev/vite-plus-core' { /** * Default target directory for `vp dev` / `build` / `preview` / `pack` * when invoked bare in the directory containing this config (an implicit - * `vp -C `). Relative to the config file's directory. vp reads the - * value without executing the config, so it also works at roots with no - * vite-plus dependency; the static read is why it must stay a plain - * string literal. + * `vp -C `). A string targets all four commands; an object maps + * commands individually, and a command absent from the object falls + * through to the normal picker/listing resolution. Paths are relative to + * the config file's directory. vp reads them without executing the + * config, so this also works at roots with no vite-plus dependency; the + * static read is why the values must stay plain string literals. */ - defaultPackage?: string; + */ + defaultPackage?: + | string + | { dev?: string; build?: string; preview?: string; pack?: string }; run?: RunConfig; diff --git a/rfcs/cwd-flag.md b/rfcs/cwd-flag.md index 1fc784137e..6b9faaeabf 100644 --- a/rfcs/cwd-flag.md +++ b/rfcs/cwd-flag.md @@ -309,7 +309,7 @@ export default defineConfig({ }); ``` -- Type: `string`, a single directory. A per-command map can come later if real demand appears. +- Type: `string` (one directory for all four commands) or a per-command object (`{ dev: './apps/web', pack: './packages/ui' }`, added on review demand). A command absent from the object falls through to the picker/listing resolution. - Consulted when a bare app command runs in the directory containing the root config: a workspace root, or a non-workspace repo root. The non-workspace shape has no package list, so `defaultPackage` is the only mechanism that covers it. An explicit `-C` always wins. - A missing directory errors: `defaultPackage points to a missing directory: ./frontend`. - Read via static extraction (`vite_static_config` + the loader in `packages/cli/binding/src/cli/handler.rs`), like `run` config. At a non-workspace root there is no install to execute the config, so the file must work unexecuted: a plain default-export object with a static string value. From 3e155b26f10f8601406e225a986d8791583ac139 Mon Sep 17 00:00:00 2001 From: MK Date: Mon, 3 Aug 2026 21:11:17 +0800 Subject: [PATCH 2/7] style: oxfmt the defaultPackage type union --- packages/cli/src/define-config.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/cli/src/define-config.ts b/packages/cli/src/define-config.ts index caa60db112..62ae8ed0e8 100644 --- a/packages/cli/src/define-config.ts +++ b/packages/cli/src/define-config.ts @@ -64,9 +64,7 @@ declare module '@voidzero-dev/vite-plus-core' { * static read is why the values must stay plain string literals. */ */ - defaultPackage?: - | string - | { dev?: string; build?: string; preview?: string; pack?: string }; + defaultPackage?: string | { dev?: string; build?: string; preview?: string; pack?: string }; run?: RunConfig; From 7f45a8be09cdbbe79a14f8be82eb9a8f23e4e5c6 Mon Sep 17 00:00:00 2001 From: MK Date: Mon, 3 Aug 2026 22:26:04 +0800 Subject: [PATCH 3/7] test(snapshots): mark the per-command fallthrough fixture as ESM Same new-Vite CommonJS config warning as the spread fixture; type: module keeps the recorded output stable. --- .../per_command_fallthrough/package.json | 6 +++++- ...kage_per_command_fallthrough.global.md.new | 20 +++++++++++++++++++ ...ckage_per_command_fallthrough.local.md.new | 18 +++++++++++++++++ .../unanalyzable_config_ignored.global.md.new | 20 +++++++++++++++++++ .../unanalyzable_config_ignored.local.md.new | 18 +++++++++++++++++ 5 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command_fallthrough.global.md.new create mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command_fallthrough.local.md.new create mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/unanalyzable_config_ignored.global.md.new create mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/unanalyzable_config_ignored.local.md.new diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/package.json b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/package.json index 08deaafa1c..31f940891d 100644 --- a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/package.json +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/package.json @@ -1 +1,5 @@ -{ "name": "per-command-fallthrough", "private": true } +{ + "name": "per-command-fallthrough", + "type": "module", + "private": true +} diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command_fallthrough.global.md.new b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command_fallthrough.global.md.new new file mode 100644 index 0000000000..e1bd5a5de9 --- /dev/null +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command_fallthrough.global.md.new @@ -0,0 +1,20 @@ +# default_package_per_command_fallthrough + +A command absent from the defaultPackage object falls through to the +normal resolution: the map only declares `pack`, so bare `vp build` runs +in place at the (runnable) root with no note. + +## `cd per_command_fallthrough && vp build` + +``` +VITE+ - The Unified Toolchain for the Web + +(!) Your Vite config uses features that are unsupported by `configLoader: 'native'`, which is planned to become the default in a future major version of Vite: + - ESM syntax in a file loaded as CommonJS (vite.config.ts:1:1). Use a `.mjs` extension or set `"type": "module"` in the closest package.json +Set `VITE_CONFIG_NATIVE_IGNORE_WARNING=true` to suppress this warning. +✓ 2 modules transformed. +computing gzip size... +dist/index.html kB │ gzip: kB + +✓ built in +``` diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command_fallthrough.local.md.new b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command_fallthrough.local.md.new new file mode 100644 index 0000000000..1ac0400ad6 --- /dev/null +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command_fallthrough.local.md.new @@ -0,0 +1,18 @@ +# default_package_per_command_fallthrough + +A command absent from the defaultPackage object falls through to the +normal resolution: the map only declares `pack`, so bare `vp build` runs +in place at the (runnable) root with no note. + +## `cd per_command_fallthrough && vp build` + +``` +(!) Your Vite config uses features that are unsupported by `configLoader: 'native'`, which is planned to become the default in a future major version of Vite: + - ESM syntax in a file loaded as CommonJS (vite.config.ts:1:1). Use a `.mjs` extension or set `"type": "module"` in the closest package.json +Set `VITE_CONFIG_NATIVE_IGNORE_WARNING=true` to suppress this warning. +✓ 2 modules transformed. +computing gzip size... +dist/index.html kB │ gzip: kB + +✓ built in +``` diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/unanalyzable_config_ignored.global.md.new b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/unanalyzable_config_ignored.global.md.new new file mode 100644 index 0000000000..a3ce308ed6 --- /dev/null +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/unanalyzable_config_ignored.global.md.new @@ -0,0 +1,20 @@ +# unanalyzable_config_ignored + +Regression guard for spread/unanalyzable configs: a config that only parses +as an open map might hide defaultPackage behind the spread, but that must +not fail the command. Bare vp build falls through and runs in place. + +## `cd spread && vp build` + +``` +VITE+ - The Unified Toolchain for the Web + +(!) Your Vite config uses features that are unsupported by `configLoader: 'native'`, which is planned to become the default in a future major version of Vite: + - ESM syntax in a file loaded as CommonJS (vite.config.ts:3:1). Use a `.mjs` extension or set `"type": "module"` in the closest package.json +Set `VITE_CONFIG_NATIVE_IGNORE_WARNING=true` to suppress this warning. +✓ 2 modules transformed. +computing gzip size... +dist/index.html kB │ gzip: kB + +✓ built in +``` diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/unanalyzable_config_ignored.local.md.new b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/unanalyzable_config_ignored.local.md.new new file mode 100644 index 0000000000..d1dcb8e36a --- /dev/null +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/unanalyzable_config_ignored.local.md.new @@ -0,0 +1,18 @@ +# unanalyzable_config_ignored + +Regression guard for spread/unanalyzable configs: a config that only parses +as an open map might hide defaultPackage behind the spread, but that must +not fail the command. Bare vp build falls through and runs in place. + +## `cd spread && vp build` + +``` +(!) Your Vite config uses features that are unsupported by `configLoader: 'native'`, which is planned to become the default in a future major version of Vite: + - ESM syntax in a file loaded as CommonJS (vite.config.ts:3:1). Use a `.mjs` extension or set `"type": "module"` in the closest package.json +Set `VITE_CONFIG_NATIVE_IGNORE_WARNING=true` to suppress this warning. +✓ 2 modules transformed. +computing gzip size... +dist/index.html kB │ gzip: kB + +✓ built in +``` From 1612dae4785d8d887505d905c16c70f9b2a91778 Mon Sep 17 00:00:00 2001 From: MK Date: Tue, 4 Aug 2026 14:42:38 +0800 Subject: [PATCH 4/7] fix(cli): drop a doubled comment terminator from the rebase The docs-reword conflict resolution left two closing */ on the defaultPackage doc comment, breaking the dist build's parse. --- packages/cli/src/define-config.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/cli/src/define-config.ts b/packages/cli/src/define-config.ts index 62ae8ed0e8..0426dc277f 100644 --- a/packages/cli/src/define-config.ts +++ b/packages/cli/src/define-config.ts @@ -63,7 +63,6 @@ declare module '@voidzero-dev/vite-plus-core' { * config, so this also works at roots with no vite-plus dependency; the * static read is why the values must stay plain string literals. */ - */ defaultPackage?: string | { dev?: string; build?: string; preview?: string; pack?: string }; run?: RunConfig; From 5c1da8c0ff5f93e670ccd8bf893bc012d58030d5 Mon Sep 17 00:00:00 2001 From: MK Date: Tue, 4 Aug 2026 15:06:23 +0800 Subject: [PATCH 5/7] test(snapshots): drop committed runner artifacts Same .md.new failing-run leftovers as the base branch; the recorded snapshots are the reviewed, warning-free versions. --- ...kage_per_command_fallthrough.global.md.new | 20 ------------------- ...ckage_per_command_fallthrough.local.md.new | 18 ----------------- .../unanalyzable_config_ignored.global.md.new | 20 ------------------- .../unanalyzable_config_ignored.local.md.new | 18 ----------------- 4 files changed, 76 deletions(-) delete mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command_fallthrough.global.md.new delete mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command_fallthrough.local.md.new delete mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/unanalyzable_config_ignored.global.md.new delete mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/unanalyzable_config_ignored.local.md.new diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command_fallthrough.global.md.new b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command_fallthrough.global.md.new deleted file mode 100644 index e1bd5a5de9..0000000000 --- a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command_fallthrough.global.md.new +++ /dev/null @@ -1,20 +0,0 @@ -# default_package_per_command_fallthrough - -A command absent from the defaultPackage object falls through to the -normal resolution: the map only declares `pack`, so bare `vp build` runs -in place at the (runnable) root with no note. - -## `cd per_command_fallthrough && vp build` - -``` -VITE+ - The Unified Toolchain for the Web - -(!) Your Vite config uses features that are unsupported by `configLoader: 'native'`, which is planned to become the default in a future major version of Vite: - - ESM syntax in a file loaded as CommonJS (vite.config.ts:1:1). Use a `.mjs` extension or set `"type": "module"` in the closest package.json -Set `VITE_CONFIG_NATIVE_IGNORE_WARNING=true` to suppress this warning. -✓ 2 modules transformed. -computing gzip size... -dist/index.html kB │ gzip: kB - -✓ built in -``` diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command_fallthrough.local.md.new b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command_fallthrough.local.md.new deleted file mode 100644 index 1ac0400ad6..0000000000 --- a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command_fallthrough.local.md.new +++ /dev/null @@ -1,18 +0,0 @@ -# default_package_per_command_fallthrough - -A command absent from the defaultPackage object falls through to the -normal resolution: the map only declares `pack`, so bare `vp build` runs -in place at the (runnable) root with no note. - -## `cd per_command_fallthrough && vp build` - -``` -(!) Your Vite config uses features that are unsupported by `configLoader: 'native'`, which is planned to become the default in a future major version of Vite: - - ESM syntax in a file loaded as CommonJS (vite.config.ts:1:1). Use a `.mjs` extension or set `"type": "module"` in the closest package.json -Set `VITE_CONFIG_NATIVE_IGNORE_WARNING=true` to suppress this warning. -✓ 2 modules transformed. -computing gzip size... -dist/index.html kB │ gzip: kB - -✓ built in -``` diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/unanalyzable_config_ignored.global.md.new b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/unanalyzable_config_ignored.global.md.new deleted file mode 100644 index a3ce308ed6..0000000000 --- a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/unanalyzable_config_ignored.global.md.new +++ /dev/null @@ -1,20 +0,0 @@ -# unanalyzable_config_ignored - -Regression guard for spread/unanalyzable configs: a config that only parses -as an open map might hide defaultPackage behind the spread, but that must -not fail the command. Bare vp build falls through and runs in place. - -## `cd spread && vp build` - -``` -VITE+ - The Unified Toolchain for the Web - -(!) Your Vite config uses features that are unsupported by `configLoader: 'native'`, which is planned to become the default in a future major version of Vite: - - ESM syntax in a file loaded as CommonJS (vite.config.ts:3:1). Use a `.mjs` extension or set `"type": "module"` in the closest package.json -Set `VITE_CONFIG_NATIVE_IGNORE_WARNING=true` to suppress this warning. -✓ 2 modules transformed. -computing gzip size... -dist/index.html kB │ gzip: kB - -✓ built in -``` diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/unanalyzable_config_ignored.local.md.new b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/unanalyzable_config_ignored.local.md.new deleted file mode 100644 index d1dcb8e36a..0000000000 --- a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/unanalyzable_config_ignored.local.md.new +++ /dev/null @@ -1,18 +0,0 @@ -# unanalyzable_config_ignored - -Regression guard for spread/unanalyzable configs: a config that only parses -as an open map might hide defaultPackage behind the spread, but that must -not fail the command. Bare vp build falls through and runs in place. - -## `cd spread && vp build` - -``` -(!) Your Vite config uses features that are unsupported by `configLoader: 'native'`, which is planned to become the default in a future major version of Vite: - - ESM syntax in a file loaded as CommonJS (vite.config.ts:3:1). Use a `.mjs` extension or set `"type": "module"` in the closest package.json -Set `VITE_CONFIG_NATIVE_IGNORE_WARNING=true` to suppress this warning. -✓ 2 modules transformed. -computing gzip size... -dist/index.html kB │ gzip: kB - -✓ built in -``` From 5992c1bf34c4558488e0b3648702df056a69ae29 Mon Sep 17 00:00:00 2001 From: MK Date: Tue, 4 Aug 2026 15:21:58 +0800 Subject: [PATCH 6/7] test(snapshots): shape the per-command fixtures as monorepos per_command and per_command_fallthrough now carry a workspaces field with apps/web and packages/ui members, matching the review scenario (pack a library, dev an app) and exercising the workspace-root classification path instead of the no-metadata fallback (#2305 review). --- .../per_command/{frontend => apps/web}/index.html | 2 +- .../per_command/apps/web/package.json | 1 + .../per_command/frontend/package.json | 1 - .../per_command/lib/package.json | 1 - .../per_command/lib/src/index.ts | 1 - .../app_root_default_package/per_command/package.json | 10 +++++++++- .../per_command/packages/ui/package.json | 1 + .../per_command/packages/ui/src/index.ts | 1 + .../per_command/vite.config.ts | 2 +- .../per_command_fallthrough/lib/package.json | 1 - .../per_command_fallthrough/lib/src/index.ts | 1 - .../per_command_fallthrough/package.json | 6 +----- .../per_command_fallthrough/packages/ui/package.json | 1 + .../per_command_fallthrough/packages/ui/src/index.ts | 1 + .../per_command_fallthrough/vite.config.ts | 2 +- .../fixtures/app_root_default_package/snapshots.toml | 10 +++++----- .../snapshots/default_package_per_command.global.md | 10 +++++----- .../snapshots/default_package_per_command.local.md | 10 +++++----- .../default_package_per_command_fallthrough.global.md | 4 ++-- .../default_package_per_command_fallthrough.local.md | 4 ++-- 20 files changed, 37 insertions(+), 33 deletions(-) rename crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/{frontend => apps/web}/index.html (69%) create mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/apps/web/package.json delete mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/frontend/package.json delete mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/lib/package.json delete mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/lib/src/index.ts create mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/packages/ui/package.json create mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/packages/ui/src/index.ts delete mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/lib/package.json delete mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/lib/src/index.ts create mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/packages/ui/package.json create mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/packages/ui/src/index.ts diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/frontend/index.html b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/apps/web/index.html similarity index 69% rename from crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/frontend/index.html rename to crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/apps/web/index.html index af5534a716..ce6d6280c2 100644 --- a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/frontend/index.html +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/apps/web/index.html @@ -1,6 +1,6 @@ -

frontend

+

web

diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/apps/web/package.json b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/apps/web/package.json new file mode 100644 index 0000000000..64630869c1 --- /dev/null +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/apps/web/package.json @@ -0,0 +1 @@ +{ "name": "web", "private": true } diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/frontend/package.json b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/frontend/package.json deleted file mode 100644 index 8314f0679b..0000000000 --- a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/frontend/package.json +++ /dev/null @@ -1 +0,0 @@ -{ "name": "frontend", "private": true } diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/lib/package.json b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/lib/package.json deleted file mode 100644 index cc2149de27..0000000000 --- a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/lib/package.json +++ /dev/null @@ -1 +0,0 @@ -{ "name": "lib", "private": true } diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/lib/src/index.ts b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/lib/src/index.ts deleted file mode 100644 index da7d8c9665..0000000000 --- a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/lib/src/index.ts +++ /dev/null @@ -1 +0,0 @@ -export const lib = 'lib'; diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/package.json b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/package.json index 7d435299d4..f23425bd85 100644 --- a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/package.json +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/package.json @@ -1 +1,9 @@ -{ "name": "per-command-config", "private": true } +{ + "name": "per-command-config", + "type": "module", + "private": true, + "workspaces": [ + "apps/*", + "packages/*" + ] +} diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/packages/ui/package.json b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/packages/ui/package.json new file mode 100644 index 0000000000..dd63f88e1f --- /dev/null +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/packages/ui/package.json @@ -0,0 +1 @@ +{ "name": "ui", "private": true } diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/packages/ui/src/index.ts b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/packages/ui/src/index.ts new file mode 100644 index 0000000000..f538469c7d --- /dev/null +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/packages/ui/src/index.ts @@ -0,0 +1 @@ +export const ui = 'ui'; diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/vite.config.ts b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/vite.config.ts index 13eec31456..754c5f8e4d 100644 --- a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/vite.config.ts +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command/vite.config.ts @@ -1,3 +1,3 @@ export default { - defaultPackage: { build: './frontend', pack: './lib' }, + defaultPackage: { build: './apps/web', pack: './packages/ui' }, }; diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/lib/package.json b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/lib/package.json deleted file mode 100644 index cc2149de27..0000000000 --- a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/lib/package.json +++ /dev/null @@ -1 +0,0 @@ -{ "name": "lib", "private": true } diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/lib/src/index.ts b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/lib/src/index.ts deleted file mode 100644 index da7d8c9665..0000000000 --- a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/lib/src/index.ts +++ /dev/null @@ -1 +0,0 @@ -export const lib = 'lib'; diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/package.json b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/package.json index 31f940891d..eb32387cc7 100644 --- a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/package.json +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/package.json @@ -1,5 +1 @@ -{ - "name": "per-command-fallthrough", - "type": "module", - "private": true -} +{ "name": "per-command-fallthrough", "type": "module", "private": true, "workspaces": ["packages/*"] } diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/packages/ui/package.json b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/packages/ui/package.json new file mode 100644 index 0000000000..dd63f88e1f --- /dev/null +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/packages/ui/package.json @@ -0,0 +1 @@ +{ "name": "ui", "private": true } diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/packages/ui/src/index.ts b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/packages/ui/src/index.ts new file mode 100644 index 0000000000..f538469c7d --- /dev/null +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/packages/ui/src/index.ts @@ -0,0 +1 @@ +export const ui = 'ui'; diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/vite.config.ts b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/vite.config.ts index 19d1c8f913..f46068d2cc 100644 --- a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/vite.config.ts +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/per_command_fallthrough/vite.config.ts @@ -1,3 +1,3 @@ export default { - defaultPackage: { pack: './lib' }, + defaultPackage: { pack: './packages/ui' }, }; diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots.toml b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots.toml index 250c622983..073163eff9 100644 --- a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots.toml +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots.toml @@ -64,9 +64,9 @@ steps = [{ argv = ["vp", "build"], cwd = "dc_wrapper" }] name = "default_package_per_command" vp = ["local", "global"] comment = """ -The object form maps commands individually: `vp build` targets ./frontend -while `vp pack` targets ./lib, so one repo can dev an app and pack a -library (rfcs/cwd-flag.md). +The object form maps commands individually at a workspace root: `vp build` +targets ./apps/web while `vp pack` targets ./packages/ui, so one monorepo +can dev an app and pack a library (rfcs/cwd-flag.md). """ steps = [ { argv = ["vp", "build"], cwd = "per_command" }, @@ -78,7 +78,7 @@ name = "default_package_per_command_fallthrough" vp = ["local", "global"] comment = """ A command absent from the defaultPackage object falls through to the -normal resolution: the map only declares `pack`, so bare `vp build` runs -in place at the (runnable) root with no note. +normal resolution: the map only declares `pack`, so bare `vp build` at +this workspace root runs in place at the (runnable) root with no note. """ steps = [{ argv = ["vp", "build"], cwd = "per_command_fallthrough" }] diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command.global.md b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command.global.md index 9659d08d87..a56291d0b5 100644 --- a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command.global.md +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command.global.md @@ -1,15 +1,15 @@ # default_package_per_command -The object form maps commands individually: `vp build` targets ./frontend -while `vp pack` targets ./lib, so one repo can dev an app and pack a -library (rfcs/cwd-flag.md). +The object form maps commands individually at a workspace root: `vp build` +targets ./apps/web while `vp pack` targets ./packages/ui, so one monorepo +can dev an app and pack a library (rfcs/cwd-flag.md). ## `cd per_command && vp build` ``` VITE+ - The Unified Toolchain for the Web -note: vp build: using ./frontend (defaultPackage in vite.config.ts) +note: vp build: using ./apps/web (defaultPackage in vite.config.ts) ✓ 2 modules transformed. computing gzip size... dist/index.html kB │ gzip: kB @@ -22,7 +22,7 @@ dist/index.html kB │ gzip: kB ``` VITE+ - The Unified Toolchain for the Web -note: vp pack: using ./lib (defaultPackage in vite.config.ts) +note: vp pack: using ./packages/ui (defaultPackage in vite.config.ts) ℹ entry: src/index.ts ℹ Build start ℹ dist/index.mjs kB │ gzip: kB diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command.local.md b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command.local.md index 3271a5e885..43141d909f 100644 --- a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command.local.md +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command.local.md @@ -1,13 +1,13 @@ # default_package_per_command -The object form maps commands individually: `vp build` targets ./frontend -while `vp pack` targets ./lib, so one repo can dev an app and pack a -library (rfcs/cwd-flag.md). +The object form maps commands individually at a workspace root: `vp build` +targets ./apps/web while `vp pack` targets ./packages/ui, so one monorepo +can dev an app and pack a library (rfcs/cwd-flag.md). ## `cd per_command && vp build` ``` -note: vp build: using ./frontend (defaultPackage in vite.config.ts) +note: vp build: using ./apps/web (defaultPackage in vite.config.ts) ✓ 2 modules transformed. computing gzip size... dist/index.html kB │ gzip: kB @@ -18,7 +18,7 @@ dist/index.html kB │ gzip: kB ## `cd per_command && vp pack` ``` -note: vp pack: using ./lib (defaultPackage in vite.config.ts) +note: vp pack: using ./packages/ui (defaultPackage in vite.config.ts) ℹ entry: src/index.ts ℹ Build start ℹ dist/index.mjs kB │ gzip: kB diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command_fallthrough.global.md b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command_fallthrough.global.md index 8c8b9baa06..9aa2859bbd 100644 --- a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command_fallthrough.global.md +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command_fallthrough.global.md @@ -1,8 +1,8 @@ # default_package_per_command_fallthrough A command absent from the defaultPackage object falls through to the -normal resolution: the map only declares `pack`, so bare `vp build` runs -in place at the (runnable) root with no note. +normal resolution: the map only declares `pack`, so bare `vp build` at +this workspace root runs in place at the (runnable) root with no note. ## `cd per_command_fallthrough && vp build` diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command_fallthrough.local.md b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command_fallthrough.local.md index 0172f1f529..dffba62bd1 100644 --- a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command_fallthrough.local.md +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command_fallthrough.local.md @@ -1,8 +1,8 @@ # default_package_per_command_fallthrough A command absent from the defaultPackage object falls through to the -normal resolution: the map only declares `pack`, so bare `vp build` runs -in place at the (runnable) root with no note. +normal resolution: the map only declares `pack`, so bare `vp build` at +this workspace root runs in place at the (runnable) root with no note. ## `cd per_command_fallthrough && vp build` From d55c81f78fd45a52bec42597fc05e50f354f7108 Mon Sep 17 00:00:00 2001 From: MK Date: Tue, 4 Aug 2026 15:32:05 +0800 Subject: [PATCH 7/7] test(snapshots): prove the declared pack entry in the fallthrough case vp pack in the same fixture routes to the declared ./packages/ui while vp build falls through, covering both halves of the object form (#2305 review). --- .../app_root_default_package/snapshots.toml | 8 ++++++-- ...ult_package_per_command_fallthrough.global.md | 16 +++++++++++++++- ...ault_package_per_command_fallthrough.local.md | 14 +++++++++++++- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots.toml b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots.toml index 073163eff9..d52a2c6520 100644 --- a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots.toml +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots.toml @@ -79,6 +79,10 @@ vp = ["local", "global"] comment = """ A command absent from the defaultPackage object falls through to the normal resolution: the map only declares `pack`, so bare `vp build` at -this workspace root runs in place at the (runnable) root with no note. +this workspace root runs in place at the (runnable) root with no note, +while `vp pack` still routes to the declared ./packages/ui. """ -steps = [{ argv = ["vp", "build"], cwd = "per_command_fallthrough" }] +steps = [ + { argv = ["vp", "build"], cwd = "per_command_fallthrough" }, + { argv = ["vp", "pack"], cwd = "per_command_fallthrough" }, +] diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command_fallthrough.global.md b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command_fallthrough.global.md index 9aa2859bbd..00ec553fbd 100644 --- a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command_fallthrough.global.md +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command_fallthrough.global.md @@ -2,7 +2,8 @@ A command absent from the defaultPackage object falls through to the normal resolution: the map only declares `pack`, so bare `vp build` at -this workspace root runs in place at the (runnable) root with no note. +this workspace root runs in place at the (runnable) root with no note, +while `vp pack` still routes to the declared ./packages/ui. ## `cd per_command_fallthrough && vp build` @@ -15,3 +16,16 @@ dist/index.html kB │ gzip: kB ✓ built in ``` + +## `cd per_command_fallthrough && vp pack` + +``` +VITE+ - The Unified Toolchain for the Web + +note: vp pack: using ./packages/ui (defaultPackage in vite.config.ts) +ℹ entry: src/index.ts +ℹ Build start +ℹ dist/index.mjs kB │ gzip: kB +ℹ 1 files, total: kB +✔ Build complete in +``` diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command_fallthrough.local.md b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command_fallthrough.local.md index dffba62bd1..cd4a43cebe 100644 --- a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command_fallthrough.local.md +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package_per_command_fallthrough.local.md @@ -2,7 +2,8 @@ A command absent from the defaultPackage object falls through to the normal resolution: the map only declares `pack`, so bare `vp build` at -this workspace root runs in place at the (runnable) root with no note. +this workspace root runs in place at the (runnable) root with no note, +while `vp pack` still routes to the declared ./packages/ui. ## `cd per_command_fallthrough && vp build` @@ -13,3 +14,14 @@ dist/index.html kB │ gzip: kB ✓ built in ``` + +## `cd per_command_fallthrough && vp pack` + +``` +note: vp pack: using ./packages/ui (defaultPackage in vite.config.ts) +ℹ entry: src/index.ts +ℹ Build start +ℹ dist/index.mjs kB │ gzip: kB +ℹ 1 files, total: kB +✔ Build complete in +```