fix: auto-import does not work when using @vitejs/plugin-vue alone - #1412
Merged
Merged
Conversation
✅ Deploy Preview for creative-fairy-df92c4 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
aiktb
marked this pull request as draft
February 8, 2025 13:07
aiktb
marked this pull request as ready for review
February 8, 2025 14:02
Timeraa
approved these changes
Feb 8, 2025
Timeraa
left a comment
Member
There was a problem hiding this comment.
Code looks fine can't test myself right now though.
@wxt-dev/auto-icons
@wxt-dev/i18n
@wxt-dev/module-solid
@wxt-dev/module-react
@wxt-dev/module-svelte
@wxt-dev/module-vue
@wxt-dev/storage
@wxt-dev/unocss
wxt
commit: |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1412 +/- ##
==========================================
- Coverage 81.22% 81.11% -0.11%
==========================================
Files 128 128
Lines 6296 6271 -25
Branches 1073 1066 -7
==========================================
- Hits 5114 5087 -27
- Misses 1167 1169 +2
Partials 15 15 ☔ View full report in Codecov by Sentry. |
Member
|
Hmm, interesting. I swear I added |
aklinker1
approved these changes
Feb 12, 2025
aklinker1
left a comment
Member
There was a problem hiding this comment.
Yeah, seems to work. Will merge and release!
Member
|
Released in v0.19.27 |
zizzfizzix
pushed a commit
to zizzfizzix/wxt
that referenced
this pull request
Aug 29, 2026
`unimport/unplugin` calls `MagicString#generateMap()` with no options, which produces a line-level sourcemap with no `source`. Since auto-imports are injected at the top of the file, tools that rely on columns - like V8 code coverage - see the whole module as a single statement. The result is that any module referencing an auto-imported variable (`browser`, `storage`, ...) silently drops out of coverage reports, which inflates the reported percentage and lets thresholds pass when they shouldn't. This was fixed once in wxt-dev#381, but wxt-dev#1412 replaced the `wxt:unimport` plugin with `UnimportPlugin.vite()` in both the build path and `WxtVitest()`, dropping the `hires` option along the way. Restore the `wxt:unimport` plugin with the sourcemap options from wxt-dev#381, keeping the `enforce: 'post'` ordering and the include/exclude filter that wxt-dev#1412 relied on. The defaults are imported from `unimport/unplugin`, so they can't drift. Both the build path and `WxtVitest()` share the plugin. Fixes wxt-dev#2604 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011PEx8LKp7AtQkR3tJfyFrY
5 tasks
zizzfizzix
pushed a commit
to zizzfizzix/wxt
that referenced
this pull request
Aug 29, 2026
`unimport/unplugin` calls `MagicString#generateMap()` with no options, which produces a line-level sourcemap with no `source`. Since auto-imports are injected at the top of the file, tools that rely on columns - like V8 code coverage - see the whole module as a single statement. The result is that any module referencing an auto-imported variable (`browser`, `storage`, ...) silently drops out of coverage reports, which inflates the reported percentage and lets thresholds pass when they shouldn't. This was fixed once in wxt-dev#381, but wxt-dev#1412 replaced the `wxt:unimport` plugin with `UnimportPlugin.vite()` in both the build path and `WxtVitest()`, dropping the `hires` option along the way. Restore the `wxt:unimport` plugin with the sourcemap options from wxt-dev#381, keeping the `enforce: 'post'` ordering and the include/exclude filter that wxt-dev#1412 relied on. The defaults are imported from `unimport/unplugin`, so they can't drift. Both the build path and `WxtVitest()` share the plugin. Fixes wxt-dev#2604 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011PEx8LKp7AtQkR3tJfyFrY
This was referenced Aug 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
close #1356
wxt uses its own unimport vite plugin instead of the official vite plugin, which causes the auto-import in the vue file to fail (instead of using
@wxt-dev/module-vue, it uses@vitejs/plugin-vuedirectly)The problem was fixed after applying this patch at https://github.com/aiktb/vue-browser-test.git, so I can be sure that this is the problem.
This should also close unjs/unimport#419 as this is not a unimport bug. cc @aklinker1
By comparing the source code of WXT and unimport, I found the problem. The vite plugin implemented by WXT lacks the following key code:
https://github.com/unjs/unimport/blob/6265894d07500d3ce0e24b247bdbb12e37a559d8/src/unplugin.ts#L48
https://vite.dev/guide/using-plugins#enforcing-plugin-ordering
It is indeed caused by the execution order of the vite plugin.