Skip to content

Replace deprecated Vite alias customResolver with a pre resolveId hook - #186

Open
cdeil wants to merge 1 commit into
observablehq:mainfrom
cdeil:codex/vite-custom-resolver
Open

cdeil wants to merge 1 commit into
observablehq:mainfrom
cdeil:codex/vite-custom-resolver

Conversation

@cdeil

@cdeil cdeil commented Sep 3, 2026

Copy link
Copy Markdown

This code and PR description is from a coding agent.

Summary

  • Move npm: externalization from Vite's deprecated alias customResolver into the existing Observable plugin.
  • Run the resolver as a pre hook, preserving Notebook Kit's build and preview composition where plugins is assigned after spreading config().
  • Add a focused test for plugin ordering, npm: resolution, externalization, and non-npm: fallthrough.

Why

Vite 8 warns that alias customResolver is deprecated and will be removed in Vite 9. The recommended replacement is a plugin with a resolveId hook and enforce: "pre".

Keeping the hook on observable() is important: Notebook Kit's build and preview commands replace the plugins property after spreading config(), so a separate plugin returned only by config() would be dropped.

Validation

Using Node 24 and pnpm 10, matching CI:

  • Red/green focused regression test
  • Full test suite: 25 files, 222 tests passed
  • pnpm lint (TypeScript and ESLint)
  • pnpm prepublishOnly
  • Complete pnpm docs:build; real npm: imports resolve and the deprecation warning is absent
  • Packed-package consumer build with Vite 8.2.2; the build passes without the warning

This branch has not been deployed

No deployments
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.

1 participant