Skip to content

fix(cli): enable compile cache before importing the CLI - #2648

Merged
fengmk2 merged 2 commits into
voidzero-dev:mainfrom
pablog12:fix/compile-cache-before-cli-import
Sep 10, 2026
Merged

fix(cli): enable compile cache before importing the CLI#2648
fengmk2 merged 2 commits into
voidzero-dev:mainfrom
pablog12:fix/compile-cache-before-cli-import

Conversation

@pablog12

@pablog12 pablog12 commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

The npm vp wrapper calls enableCompileCache(), but its static import loads and evaluates the CLI dependency graph before that call executes. Use an awaited dynamic import so the existing cache initialization happens first.

The regression test runs the real wrapper in an isolated ESM fixture. It fails on the previous code (getCompileCacheDir() is undefined during CLI module evaluation) and passes with this change. It also checks arguments containing spaces and preserves a nonzero exit code.

This affects the npm wrapper; it does not claim to optimize the native/global entrypoint that bypasses it. Downstream warm-cache measurements on Linux/Node 24.19 showed approximately 36 ms less time for a full check and 42 ms for a three-file check; these are project-specific measurements, not a universal benchmark.

Validation on the submitted commit, using frozen pnpm 11.24.0 installations for the workspace and docs, the pinned Rolldown/Vite source revisions, and nightly-2026-08-02 Rust:

  • pnpm build: complete source build passed, including Rolldown, Vite/core, CLI JavaScript and the native CLI binding.
  • Full unit suite through the freshly built npm wrapper: 1,188 passed, one platform skip, across 77 files on Vitest 4.1.11 (5.34 seconds).
  • Full repository native TypeScript check (tsgo --noEmit): passed after installing the separately documented docs dependencies.
  • vp check packages/cli/src/__tests__/bootstrap-compile-cache.spec.ts: formatting, type-aware lint and type checks passed with the repository's configuration.
  • node --check packages/cli/bin/vp and the built wrapper's --version command: passed.

The ordinary pnpm test:unit invocation initially had two environment-dependent failures: pnpm's shim injected NODE_PATH, allowing a deliberately missing-dependency fixture to resolve an unrelated hoisted Vite; a hook test assumes /usr/bin/dirname and an ordinary /bin/sh, whereas this NixOS host has no /usr/bin/dirname and wraps /bin/sh with a modified PATH. All tests passed when invoking node packages/cli/bin/vp test --run --maxWorkers=4 with NODE_PATH, NO_COLOR and FORCE_COLOR cleared, inside a temporary Bubblewrap environment supplying standard coreutils and a plain Bash /bin/sh. No production code, test assertions, snapshots or host system paths were changed to accommodate these failures.

The whole Rust workspace test suite, PTY/browser snapshot matrix and cross-platform CI matrix were not run locally.

After the repository's documented dependency setup, run the regression test with:

pnpm test:unit packages/cli/src/__tests__/bootstrap-compile-cache.spec.ts

This is an isolated bootstrap unit test: the CLI module is a fixture, so it tests ESM initialization order without exercising command output or the native CLI.

AI assistance: implementation and self-review performed with OpenAI Codex using GPT-6 Astra (gpt-6-astra), with reasoning effort set to high.

@fengmk2 fengmk2 self-assigned this Sep 10, 2026
@fengmk2 fengmk2 added test: e2e Auto run e2e tests test: install-e2e run vite install e2e test test: create-e2e Run `vp create` e2e tests test: sfw preview-build Publish this PR's commits to the registry bridge as preview builds labels Sep 10, 2026
@pablog12

Copy link
Copy Markdown
Contributor Author

Thanks for enabling the broader CI matrix. I investigated the failing Windows Socket Firewall job:

  • sfw --version reports 1.15.1.
  • The first command, sfw "vp.exe" i -g pnpm@9.15.0, prints Vite+ already includes 'pnpm'; skipping., then aborts with Assertion failed: !(handle->flags & UV_HANDLE_CLOSING), file src\win\async.c, line 76 (exit 127). It never reaches the subsequent clone/install steps.
  • The skip is the existing native global-install early return. This PR changes only the npm packages/cli/bin/vp wrapper and adds its regression test; that wrapper is not on this failing command's execution path.

This points to the Windows/SFW execution path rather than the compile-cache change, but I cannot confirm the crash's cause locally on Linux. The Linux/macOS test jobs and the ecosystem E2E/project-creation matrices passed. Could a maintainer rerun the failed jobs to check reproducibility? I attempted the rerun, but GitHub requires repository admin rights.

The fixture also currently skips its intended registry download because pnpm is bundled; that may warrant a separate CI fixture update.

@github-actions

Copy link
Copy Markdown
Contributor

Registry bridge build (b2d868d)

Warning

This build is from the fork pablog12/vite-plus and has not been reviewed.
Installing it runs that code on your machine. Build log

This commit build is published to the registry bridge, which serves these as ordinary npm versions (every other package proxies to npmjs):

Package Version
vite-plus 0.0.0-commit.b2d868d8aa515ed1b4d592ebb22ecb90e3504fcf
@voidzero-dev/vite-plus-core 0.0.0-commit.b2d868d8aa515ed1b4d592ebb22ecb90e3504fcf

Install the Vite+ CLI built from this commit, then migrate a project:

# macOS / Linux
curl -fsSL https://raw.githubusercontent.com/pablog12/vite-plus/b2d868d8aa515ed1b4d592ebb22ecb90e3504fcf/packages/cli/install.sh | VP_PR_VERSION=2648 bash
# Windows (PowerShell)
$env:VP_PR_VERSION="2648"; irm https://raw.githubusercontent.com/pablog12/vite-plus/b2d868d8aa515ed1b4d592ebb22ecb90e3504fcf/packages/cli/install.ps1 | iex

Or download the standalone Windows installer built from this commit:

Architecture Installer
x64 vp-setup-x86_64-pc-windows-msvc.exe
Arm64 vp-setup-aarch64-pc-windows-msvc.exe

GitHub requires you to sign in and downloads each installer as a ZIP artifact. Extract vp-setup.exe, then run it against this preview build:

.\vp-setup.exe --version "0.0.0-commit.b2d868d8aa515ed1b4d592ebb22ecb90e3504fcf" --registry "https://registry-bridge.viteplus.dev/"

After installing, upgrade the current project's vite-plus to this test build with:

vp migrate

Or point your package manager at the bridge registry https://registry-bridge.viteplus.dev/:

Package manager Registry config
npm / pnpm / Bun .npmrc: registry=https://registry-bridge.viteplus.dev/
Yarn (v2+) .yarnrc.yml: npmRegistryServer: "https://registry-bridge.viteplus.dev/"

Then pin the build (vite aliases to vite-plus-core; pnpm can use a catalog, npm an overrides entry):

{
  "devDependencies": {
    "vite-plus": "0.0.0-commit.b2d868d8aa515ed1b4d592ebb22ecb90e3504fcf",
    "vite": "npm:@voidzero-dev/vite-plus-core@0.0.0-commit.b2d868d8aa515ed1b4d592ebb22ecb90e3504fcf"
  }
}

@fengmk2 fengmk2 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pablog12 Thanks, LGTM.

Since vpr has already fixed the compile cache issue in this way https://github.com/pablog12/vite-plus/blob/b2d868d8aa515ed1b4d592ebb22ecb90e3504fcf/packages/cli/bin/vpr#L10, I will delete the newly added test case packages/cli/src/tests/bootstrap-compile-cache.spec.ts before merge, as it should not be necessary.

Signed-off-by: MK (fengmk2) <fengmk2@gmail.com>
@fengmk2
fengmk2 merged commit 86b2288 into voidzero-dev:main Sep 10, 2026
103 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preview-build Publish this PR's commits to the registry bridge as preview builds test: create-e2e Run `vp create` e2e tests test: e2e Auto run e2e tests test: install-e2e run vite install e2e test test: sfw

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants