Skip to content

fix: keep user resolve.alias priority over later plugins - #445

Open
lxsmnsyc wants to merge 2 commits into
mainfrom
fix/130-keep-user-alias-main
Open

lxsmnsyc wants to merge 2 commits into
mainfrom
fix/130-keep-user-alias-main

Conversation

@lxsmnsyc

Copy link
Copy Markdown
Member

Fixes #130 on main (1.x). next already stopped rewriting aliases in d684795 and is not affected.

A user's resolve.alias entries now keep priority over aliases added by later plugins. Before, vite-plugin-node-polyfills with a user alias { 'path/posix': 'path-browserify' } failed with Could not load .../path-browserify/posix.

Cause

  • The plugin converted the user's alias object into an array.
  • Vite's mergeAlias merges two alias objects by key. When it merges an object into an array, the later plugin's aliases come first, so they won over the user's.
  • The plugin's own solid-refresh alias was an array too, and caused the same reordering.

Changes

  • The plugin no longer rewrites the user's aliases.
  • The plugin no longer adds an alias for solid-refresh. It resolves solid-refresh in resolveId instead.

Testing

  • Reproduced on Vite 5, 6 and 8. With the fix, the build passes on all three.
  • Added a regression test that fails without the fix, and a dev test that checks the HMR runtime still resolves.
  • vitest run and tsc --noEmit pass.

Note on the first commit

main had no unit tests. The first commit adds the same Vitest setup that next uses: a root vitest.config.ts, a test:unit script, and a step in the Vitest workflow. The other main fix PRs from this batch (#112, #153, #206, #130, #141) share this exact commit, so they do not conflict on it.

🤖 Generated with Claude Code

lxsmnsyc and others added 2 commits October 19, 2026 11:34
- Add a root vitest config and a test:unit script, matching the next branch.
- Run the unit tests in the vitest workflow.
- Exclude test files from the declaration build.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- The plugin turned the user's alias object into an array and added its own alias array. Vite merges an array with a later plugin's alias object by putting the later aliases first, so a plugin alias for `path` matched `path/posix` before the user's own `path/posix` alias.
- Stop rewriting the user's aliases and drop the plugin's own alias. The `solid-refresh` import is resolved in resolveId instead.
- Add a build test with a later plugin alias, and a dev test that the HMR runtime still resolves.

Fixes #130

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Oct 19, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f8439e8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
vite-plugin-solid Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Oct 19, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/vite-plugin-solid@445

commit: f8439e8

@ryansolid ryansolid added the 1.x label Oct 21, 2026 — with Claude
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

alias normalization breaks config

2 participants