Skip to content

feat: support vite8 resolve.tsconfigPaths#494

Merged
james-elicx merged 2 commits intocloudflare:mainfrom
hyoban:3-12-vite-8
Mar 12, 2026
Merged

feat: support vite8 resolve.tsconfigPaths#494
james-elicx merged 2 commits intocloudflare:mainfrom
hyoban:3-12-vite-8

Conversation

@hyoban
Copy link
Contributor

@hyoban hyoban commented Mar 12, 2026

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 12, 2026

Open in StackBlitz

npm i https://pkg.pr.new/vinext@494

commit: cb4c54c

@james-elicx
Copy link
Collaborator

/bigbonk review

Copy link
Contributor

@ask-bonk ask-bonk bot left a comment

Choose a reason for hiding this comment

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

Clean, well-scoped change. The approach is correct:

  1. Plugin gating: vite-tsconfig-paths is excluded from the plugin array on Vite 8+, and the native resolve.tsconfigPaths is enabled instead.
  2. User override respected: Checking === undefined correctly distinguishes "user didn't set it" from "user explicitly set it to false".
  3. Cached version lookup: Hoisting getViteMajorVersion() into a single const viteMajorVersion at the top of vinext() is a good cleanup — it was being called redundantly before (line 1263 in the old code).
  4. Test coverage: All three important cases are covered — Vite 7 keeps the plugin, Vite 8 enables native paths, and explicit tsconfigPaths: false is not overridden.
  5. Peer dep range: ^8.0.0-beta.0 is appropriate for early beta support.

Two minor observations (non-blocking):


expect(findNamedPlugin(plugins, "vite-tsconfig-paths")).toBeDefined();

fs.rmSync(root, { recursive: true, force: true });
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: The temp directory cleanup (fs.rmSync) is at the end of each test body, but if an assertion fails mid-test, it won't run. Since afterEach already restores process.cwd(), consider also moving rmSync into afterEach (or using try/finally within each test) so temp dirs don't leak on failure.

Non-blocking — the leaked dirs are in os.tmpdir() so they'll be cleaned up by the OS eventually.

}
}

type UserResolveConfigWithTsconfigPaths = NonNullable<UserConfig["resolve"]> & {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Once Vite 8 ships a stable release with tsconfigPaths in its public UserConfig["resolve"] type, this custom type can be removed and you can use Vite's type directly. Worth a TODO comment so it doesn't get forgotten.

Non-blocking.

@ask-bonk
Copy link
Contributor

ask-bonk bot commented Mar 12, 2026

Review submitted. Here's a summary:

Approved — this is a clean, well-scoped change that correctly adds Vite 8 resolve.tsconfigPaths support.

What the PR does:

  • On Vite 8+, skips the vite-tsconfig-paths plugin and instead enables the native resolve.tsconfigPaths: true config
  • Respects user overrides — if the user explicitly sets tsconfigPaths: false, vinext won't override it
  • Hoists getViteMajorVersion() into a single call (was called redundantly before)
  • Adds the ^8.0.0-beta.0 peer dependency range
  • Includes good test coverage for all three key scenarios

Two non-blocking nits:

  1. Temp directory cleanup in tests (fs.rmSync) is at the end of each test body — if an assertion fails mid-test, it won't run. Could be moved to afterEach to avoid leaking temp dirs on failure.
  2. The UserResolveConfigWithTsconfigPaths custom type can be replaced with Vite's native type once Vite 8 ships stable — worth a TODO comment.

github run

@james-elicx james-elicx merged commit 5909e00 into cloudflare:main Mar 12, 2026
19 checks passed
@james-elicx
Copy link
Collaborator

Nice one!

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.

2 participants