You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(cli): align vite exports with upstream vite package (#375)
Add missing exports to vite-plus CLI package to match vite's export map:
- ./client (types only, ambient declarations)
- ./module-runner
- ./internal
- ./dist/client/*
- ./types/*
- ./types/internal/* (blocked)
This enables imports like:
```typescript
import type { ImportGlobFunction } from '@voidzero-dev/vite-plus/types/importGlob.d.ts';
```
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <[email protected]>
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Aligns the CLI package’s export map with upstream Vite by generating shims that re-export from the core package and refining test shims.
>
> - Add `syncCorePackageExports()` to `build.ts` to create shims for `./client` (triple-slash types), `./module-runner`, `./internal`, `./dist/client/*` (JS), and `./types/*` (type-only `export type *`), with `./types/internal/*` blocked
> - Require core build artifacts; mirror `dist/vite/client` and `dist/vite/types` into `dist/client` and `dist/types`
> - Update `packages/cli/package.json` exports to include the new Vite-compatible subpaths and precedence (`./types/internal/*` before `./types/*`)
> - Enhance test export shims to include side-effect imports in `.d.ts` to preserve augmentations; keep auto-sync of `./test/*`
> - Expand `BUNDLING.md` to document the new 4-step build, export mapping, output structure, and rationale
>
> <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 714de68. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
This document explains how `@voidzero-dev/vite-plus` is built and how it re-exports the test package.
3
+
This document explains how `@voidzero-dev/vite-plus` is built and how it re-exports from both the core and test packages to serve as a drop-in replacement for `vite`.
4
4
5
5
## Overview
6
6
7
-
The CLI package uses a **3-step build process**:
7
+
The CLI package uses a **4-step build process**:
8
8
9
9
1.**TypeScript Compilation** - Compile TypeScript source to JavaScript
3.**Test Package Export Sync** - Re-export `@voidzero-dev/vite-plus-test` under `./test/*`
11
+
3.**Core Package Export Sync** - Re-export `@voidzero-dev/vite-plus-core` under `./client`, `./types/*`, etc.
12
+
4.**Test Package Export Sync** - Re-export `@voidzero-dev/vite-plus-test` under `./test/*`
12
13
13
-
This allows users to import everything from a single package (`@voidzero-dev/vite-plus`) instead of needing to know about the separate test package.
14
+
This architecture allows users to import everything from a single package (`@voidzero-dev/vite-plus`) as a drop-in replacement for `vite`, without needing to know about the separate core and test packages.
14
15
15
16
## Build Steps
16
17
@@ -50,7 +51,39 @@ await cli.build({
50
51
51
52
The build generates platform-specific native binaries and formats the generated JavaScript wrapper with `oxfmt`.
52
53
53
-
### Step 3: Test Package Export Sync (`syncTestPackageExports`)
Creates shim files that re-export from `@voidzero-dev/vite-plus-core`, enabling this package to be a drop-in replacement for upstream `vite`. This is critical for compatibility with existing Vite plugins and configurations.
57
+
58
+
**Prerequisites**: The core package must be built first (its `dist/vite/` directory must exist).
**Note on export ordering**: In `package.json`, the `./types/internal/*` export (set to `null`) must appear before `./types/*` for correct precedence. More specific patterns must precede wildcards.
85
+
86
+
### Step 4: Test Package Export Sync (`syncTestPackageExports`)
54
87
55
88
Reads the test package's exports and creates shim files that re-export everything under `./test/*`:
This is important because `./types/*` only exposes `.d.ts` files and should never include runtime code.
195
+
196
+
### Internal Types Blocking
197
+
198
+
The `./types/internal/*` export is set to `null` in package.json to block access to internal type definitions:
199
+
200
+
```json
201
+
"./types/internal/*": null,
202
+
"./types/*": { "types": "./dist/types/*" }
203
+
```
204
+
205
+
The `syncTypesDir()` helper skips the top-level `internal` directory when creating shims, since access is blocked at the exports level.
206
+
207
+
### Client Types (Triple-Slash Reference)
208
+
209
+
The `./client` export uses a triple-slash reference instead of a regular export because Vite's `client.d.ts` contains ambient type declarations (for CSS modules, assets, etc.) that should be globally available:
@@ -275,4 +396,6 @@ The build script automatically updates `package.json`:
275
396
2. Adds new exports from test package
276
397
3. Ensures `dist/test` is in the `files` array
277
398
278
-
This keeps the CLI package exports in sync with the test package without manual maintenance.
399
+
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.
400
+
401
+
This keeps the CLI package exports in sync with both upstream Vite and the test package without manual maintenance.
0 commit comments