Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: auto-import does not work when using @vitejs/plugin-vue alone #1412

Merged
merged 1 commit into from
Feb 12, 2025

Conversation

aiktb
Copy link
Contributor

@aiktb aiktb commented Feb 8, 2025

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-vue directly)

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

enforce: 'post',

https://vite.dev/guide/using-plugins#enforcing-plugin-ordering
It is indeed caused by the execution order of the vite plugin.

Copy link

netlify bot commented Feb 8, 2025

Deploy Preview for creative-fairy-df92c4 ready!

Name Link
🔨 Latest commit f1f65d2
🔍 Latest deploy log https://app.netlify.com/sites/creative-fairy-df92c4/deploys/67a755061868b70008c2cb0f
😎 Deploy Preview https://deploy-preview-1412--creative-fairy-df92c4.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@aiktb aiktb marked this pull request as draft February 8, 2025 13:07
@aiktb aiktb marked this pull request as ready for review February 8, 2025 14:02
Copy link
Contributor

@Timeraa Timeraa left a comment

Choose a reason for hiding this comment

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

Code looks fine can't test myself right now though.

Copy link

pkg-pr-new bot commented Feb 8, 2025

Open in Stackblitz

@wxt-dev/auto-icons

npm i https://pkg.pr.new/@wxt-dev/auto-icons@1412

@wxt-dev/i18n

npm i https://pkg.pr.new/@wxt-dev/i18n@1412

@wxt-dev/module-solid

npm i https://pkg.pr.new/@wxt-dev/module-solid@1412

@wxt-dev/module-react

npm i https://pkg.pr.new/@wxt-dev/module-react@1412

@wxt-dev/module-svelte

npm i https://pkg.pr.new/@wxt-dev/module-svelte@1412

@wxt-dev/module-vue

npm i https://pkg.pr.new/@wxt-dev/module-vue@1412

@wxt-dev/storage

npm i https://pkg.pr.new/@wxt-dev/storage@1412

@wxt-dev/unocss

npm i https://pkg.pr.new/@wxt-dev/unocss@1412

wxt

npm i https://pkg.pr.new/wxt@1412

commit: f1f65d2

Copy link

codecov bot commented Feb 8, 2025

Codecov Report

Attention: Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 81.11%. Comparing base (0d56100) to head (f1f65d2).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
packages/wxt/src/testing/wxt-vitest-plugin.ts 0.00% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

@aklinker1
Copy link
Collaborator

Hmm, interesting. I swear I added enforce: 'post', but maybe that was somewhere else... Thanks for the PR. Will test soon as well. Traveling today

Copy link
Collaborator

@aklinker1 aklinker1 left a comment

Choose a reason for hiding this comment

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

Yeah, seems to work. Will merge and release!

@aklinker1 aklinker1 merged commit d6ee456 into wxt-dev:main Feb 12, 2025
18 checks passed
@aklinker1
Copy link
Collaborator

Released in v0.19.27

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.

Imports added outside Vue <script> block
3 participants