From 9d26ed43273e0faade8007b6d860a4dc59e4b938 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Fri, 6 Mar 2026 15:28:17 +0800 Subject: [PATCH 1/5] docs(cli): rewrite package.json exports management section in BUNDLING.md Replaces the inaccurate three-layer pipeline description with a correct two-category breakdown (manual vs automated). The previous version incorrectly claimed sync-remote-deps.ts managed CLI package.json exports and referenced ./rolldown/* entries that don't exist in this package. Co-Authored-By: Claude Opus 4.6 --- packages/cli/BUNDLING.md | 44 +++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/packages/cli/BUNDLING.md b/packages/cli/BUNDLING.md index 1ec7ff718e..746728dbda 100644 --- a/packages/cli/BUNDLING.md +++ b/packages/cli/BUNDLING.md @@ -504,14 +504,44 @@ const CORE_PACKAGE_NAME = '@voidzero-dev/vite-plus-core'; const TEST_PACKAGE_NAME = '@voidzero-dev/vite-plus-test'; ``` -### Package.json Auto-Update +### Package.json Exports Management -The build script automatically updates `package.json`: +The `exports` field in `package.json` has two categories: **manual** and **automated**. -1. Removes old `./test/*` exports -2. Adds new exports from test package -3. Ensures `dist/test` is in the `files` array +#### Manual exports -Core package exports (`./client`, `./module-runner`, `./internal`, `./dist/client/*`, `./types/*`) are defined statically in `package.json` and not auto-generated, since they match upstream Vite's exports structure. +All non-`./test*` exports are manually maintained in `package.json`. These fall into two groups: -This keeps the CLI package exports in sync with both upstream Vite and the test package without manual maintenance. +**CLI-native exports** — point to CLI's own compiled TypeScript (built by `buildCli()` via tsc): + +| Export | Description | +| ---------------- | -------------------------- | +| `.` | Main entry (CLI utilities) | +| `./bin` | CLI binary entry point | +| `./binding` | NAPI native binding | +| `./lint` | Lint utilities | +| `./pack` | Pack utilities | +| `./package.json` | Package metadata | + +**Core shim exports** — point to shim files auto-generated by `syncCorePackageExports()` that re-export from `@voidzero-dev/vite-plus-core`. The shim files are regenerated on each build, but the `package.json` entries themselves are manual: + +| Export | Description | +| -------------------- | ----------------------------------------------------------------------- | +| `./client` | Triple-slash reference for ambient type declarations (CSS modules, etc) | +| `./module-runner` | Vite module runner for SSR/environments | +| `./internal` | Internal Vite APIs | +| `./dist/client/*` | Client runtime files | +| `./types/internal/*` | Blocked (`null`) to prevent access to internal types | +| `./types/*` | Type-only re-exports | + +**Note**: The core package's own exports (which the shims point to) are generated upstream by `packages/tools/src/sync-remote-deps.ts`. See [Core Package Bundling](../core/BUNDLING.md) for details. + +#### Automated exports (`./test/*`) + +All `./test*` exports are fully managed by `syncTestPackageExports()`. The build script: + +1. Reads `packages/test/package.json` exports +2. Creates shim files in `dist/test/` +3. Removes old `./test*` exports from `package.json` +4. Merges in newly generated test exports +5. Ensures `dist/test` is in the `files` array From 6755d3f3a72a9c3b15d14fff817817c7cdbbfdf2 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Fri, 6 Mar 2026 15:53:32 +0800 Subject: [PATCH 2/5] feat(lint): add `./lint` export and use it for oxlint config generation - Add `./lint` subpath export to CLI package.json - Create `src/lint.ts` to re-export `defineConfig` from the lint module - Update Rust config generator to import from `vite-plus/lint` instead of `oxlint` Co-Authored-By: Claude Opus 4.6 --- packages/cli/binding/src/cli.rs | 2 +- packages/cli/package.json | 4 ++++ packages/cli/src/lint.ts | 13 +++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 packages/cli/src/lint.ts diff --git a/packages/cli/binding/src/cli.rs b/packages/cli/binding/src/cli.rs index 6cecc92644..06dc21f934 100644 --- a/packages/cli/binding/src/cli.rs +++ b/packages/cli/binding/src/cli.rs @@ -263,7 +263,7 @@ impl SubcommandResolver { let config_path = config_dir.join(temp_filename); let content = format!( - "import {{ defineConfig }} from 'oxlint';\nimport viteConfig from './{config_basename}';\nexport default defineConfig(viteConfig.{field_name} as any);\n" + "import {{ defineConfig }} from 'vite-plus/lint';\nimport viteConfig from './{config_basename}';\nexport default defineConfig(viteConfig.{field_name} as any);\n" ); write(&config_path, content).await?; diff --git a/packages/cli/package.json b/packages/cli/package.json index d8196408c1..338af24071 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -55,6 +55,10 @@ "import": "./binding/index.cjs", "require": "./binding/index.cjs" }, + "./lint": { + "types": "./dist/lint.d.ts", + "import": "./dist/lint.js" + }, "./package.json": "./package.json", "./pack": { "types": "./dist/pack.d.ts", diff --git a/packages/cli/src/lint.ts b/packages/cli/src/lint.ts new file mode 100644 index 0000000000..25f7703d56 --- /dev/null +++ b/packages/cli/src/lint.ts @@ -0,0 +1,13 @@ +export { + type AllowWarnDeny, + type DummyRule, + type DummyRuleMap, + type ExternalPluginEntry, + type ExternalPluginsConfig, + type OxlintConfig, + type OxlintEnv, + type OxlintGlobals, + type OxlintOverride, + type RuleCategories, + defineConfig, +} from 'oxlint'; From 4f4cb268ddd4276a2c9a0ab9e5c3298c31f4205a Mon Sep 17 00:00:00 2001 From: LongYinan Date: Fri, 6 Mar 2026 16:11:32 +0800 Subject: [PATCH 3/5] fix(tools): add CLI self-reference in snap test node_modules The snap test harness symlinks `packages/cli/node_modules` into the temp directory, but `vite-plus` itself isn't in that directory (it only exists in the workspace root `node_modules`). Create a real `node_modules` dir with individual symlinks plus a `vite-plus` entry pointing to the CLI package, so `vite-plus/*` subpath imports resolve in generated files like `.vite-plus-lint.tmp.mts`. Co-Authored-By: Claude Opus 4.6 --- packages/tools/src/snap-test.ts | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/packages/tools/src/snap-test.ts b/packages/tools/src/snap-test.ts index 656db6610d..c54b4ff699 100755 --- a/packages/tools/src/snap-test.ts +++ b/packages/tools/src/snap-test.ts @@ -113,10 +113,24 @@ export async function snapTest() { } } - // Make dependencies available in the test cases + // Make dependencies available in the test cases. + // Create a real node_modules directory so we can add the CLI package itself + // alongside the symlinked dependencies (needed for `vite-plus/*` imports in + // generated config files like .vite-plus-lint.tmp.mts). + const tempNodeModules = path.join(tempTmpDir, 'node_modules'); + fs.mkdirSync(tempNodeModules); + const cliNodeModules = path.resolve('node_modules'); + for (const entry of fs.readdirSync(cliNodeModules)) { + fs.symlinkSync( + path.join(cliNodeModules, entry), + path.join(tempNodeModules, entry), + process.platform === 'win32' ? 'junction' : 'dir', + ); + } + // Add the CLI package itself so `vite-plus/*` subpath imports resolve fs.symlinkSync( - path.resolve('node_modules'), - path.join(tempTmpDir, 'node_modules'), + path.resolve('.'), + path.join(tempNodeModules, 'vite-plus'), process.platform === 'win32' ? 'junction' : 'dir', ); From afef87a3de50d01a470d135440c06576041106f9 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Fri, 6 Mar 2026 16:43:48 +0800 Subject: [PATCH 4/5] Update snapshot --- .../cli-helper-message/snap.txt | 19 +++++++++---------- .../command-version-no-side-effects/snap.txt | 16 ++++++++-------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/packages/cli/snap-tests-global/cli-helper-message/snap.txt b/packages/cli/snap-tests-global/cli-helper-message/snap.txt index 9d29913801..c5668ea4f4 100644 --- a/packages/cli/snap-tests-global/cli-helper-message/snap.txt +++ b/packages/cli/snap-tests-global/cli-helper-message/snap.txt @@ -55,16 +55,16 @@ VITE+ - The Unified Toolchain for the Web vp v Local vite-plus: - vite-plus Not found + vite-plus v Tools: - vite Not found - rolldown Not found - vitest Not found - oxfmt Not found - oxlint Not found - oxlint-tsgolint Not found - tsdown Not found + vite v + rolldown v + vitest v + oxfmt v + oxlint v + oxlint-tsgolint v + tsdown v > vp install -h # show install help message VITE+ - The Unified Toolchain for the Web @@ -406,5 +406,4 @@ Options: --force Force reinstall even if already on the target version --silent Suppress output --registry Custom npm registry URL - -h, --help Print help - + -h, --help Print help \ No newline at end of file diff --git a/packages/cli/snap-tests-global/command-version-no-side-effects/snap.txt b/packages/cli/snap-tests-global/command-version-no-side-effects/snap.txt index c23315020a..20c1f0fd4d 100644 --- a/packages/cli/snap-tests-global/command-version-no-side-effects/snap.txt +++ b/packages/cli/snap-tests-global/command-version-no-side-effects/snap.txt @@ -4,16 +4,16 @@ VITE+ - The Unified Toolchain for the Web vp v Local vite-plus: - vite-plus Not found + vite-plus v Tools: - vite Not found - rolldown Not found - vitest Not found - oxfmt Not found - oxlint Not found - oxlint-tsgolint Not found - tsdown Not found + vite v + rolldown v + vitest v + oxfmt v + oxlint v + oxlint-tsgolint v + tsdown v > test -f .node-version && echo 'FAIL: .node-version was created' || echo 'OK: no .node-version created' OK: no .node-version created From f9329cfb9139510d3d7211aeb9f97d0683acaa42 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Fri, 6 Mar 2026 17:10:26 +0800 Subject: [PATCH 5/5] Update snap --- packages/cli/snap-tests-global/cli-helper-message/snap.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/cli/snap-tests-global/cli-helper-message/snap.txt b/packages/cli/snap-tests-global/cli-helper-message/snap.txt index c5668ea4f4..eefe1b4d55 100644 --- a/packages/cli/snap-tests-global/cli-helper-message/snap.txt +++ b/packages/cli/snap-tests-global/cli-helper-message/snap.txt @@ -406,4 +406,5 @@ Options: --force Force reinstall even if already on the target version --silent Suppress output --registry Custom npm registry URL - -h, --help Print help \ No newline at end of file + -h, --help Print help +