Skip to content

Fix Vite 8/Rolldown support and add cross-version compatibility coverage#13

Open
dino-careaccess wants to merge 1 commit intodavidmyersdev:mainfrom
dino-careaccess:vite-8-support
Open

Fix Vite 8/Rolldown support and add cross-version compatibility coverage#13
dino-careaccess wants to merge 1 commit intodavidmyersdev:mainfrom
dino-careaccess:vite-8-support

Conversation

@dino-careaccess
Copy link
Copy Markdown

@dino-careaccess dino-careaccess commented Mar 23, 2026

Summary

This is more than a peer dependency bump.

The package was still using a config() hook to inject build.rollupOptions.external as a predicate function. That worked historically, but it breaks down in Vite 8/Rolldown when the consuming project also has its own static rollupOptions.external entries. In that case, Vite/Rolldown can end up with a mixed external config that includes both static entries and a function, which causes server/SSR-style builds to fail.

The fix here is to stop mutating rollupOptions.external and instead externalize matching imports during resolution. That keeps the plugin compatible with Vite 8 while still preserving support for older Vite versions.

What changed

  • Reworked the plugin to externalize dependencies in resolveId during build instead of injecting rollupOptions.external
  • Kept support for:
    • declared dependencies
    • dependency subpaths
    • include
    • except
    • Node builtins
  • Fixed dependency matching so package names are matched directly instead of through unescaped regex patterns
  • Updated the peer dependency range to include Vite 8
  • Updated the repo build/test setup so the package builds cleanly on Vite 8

Why the test coverage expanded

Once the peer range says Vite 8 is supported, this repo needs to prove that the implementation still works across the versions it claims to support.

This PR adds two layers of coverage:

  1. Targeted integration tests around the actual Vite 8 regression:

    • server/SSR-oriented build behavior
    • coexistence with user-supplied static rollupOptions.external
    • include/except/builtin handling
  2. A compatibility matrix that exercises representative Vite releases from 2 through 8 in temporary fixtures

The matrix is important because the implementation change was not Vite-8-only. It replaced the core mechanism the plugin uses to externalize imports, so it was worth verifying that older Vite versions still behave correctly instead of assuming they do.

Verification

Verified locally with:

  • pnpm test
  • pnpm build
  • pnpm test:matrix

The matrix covers:

  • Vite 2.9.18
  • Vite 3.2.11
  • Vite 4.5.14
  • Vite 5.4.19
  • Vite 6.4.1
  • Vite 7.0.3
  • Vite 8.0.2

Notes

  • The main Vite 8 issue addressed here is the plugin's current rollupOptions.external = (id) => ... strategy, not just the peer range.
  • Resolves support Vite 8 #12

@dino-careaccess
Copy link
Copy Markdown
Author

@davidmyersdev 👋 , I would appreciate your review! Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

support Vite 8

1 participant