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(vite-dev): replace default Vue import with named #723

Closed
wants to merge 3 commits into from
Closed

fix(vite-dev): replace default Vue import with named #723

wants to merge 3 commits into from

Conversation

AndreyYolkin
Copy link
Contributor

@AndreyYolkin AndreyYolkin commented Mar 25, 2023

πŸ”— Linked issue

Closes: #583

❓ Type of change

This commit fixes an issue where the default Vue import in Vite was undefined in development mode. To solve this issue, the commit creates Vite transformation plugin, running only in dev mode. It looks for default import and replaces with named. Also it adds named Vue export to the vue dist files.

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

I've created 2 sandboxes with and without "patch"

  1. Broken
  2. Unbroken

Since Nuxt Bridge requires Nuxt 2.16, and Nuxt 2.16 running with Vue 2.7, which is the last minor version of Vue 2, I suppose we can rely on paths of vue dists (vue/dist/vue.runtime.esm.js/mjs) for "patching" them. However we can extend the list of possible files for patching and check if they have default export

I have some difficulties with writing a tests for this fix, because original issue happens only in client dev, but mannually tested with vue-demi, portal-vue, vuetify. I can also add Portal-vue integration in this PR, but I'm not sure about it

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

AndreyYolkin and others added 3 commits March 25, 2023 14:30
This commit fixes an issue where the default Vue import in Vite was undefined in development mode. To solve this issue, the commit creates Vite transformation plugin, running only in dev mode.
@AndreyYolkin
Copy link
Contributor Author

I made a review today, tested with "problematic" libraries and can confirm, that Vite 4 solves this issue in more general way. So I'm closing this PR, but it was interesting diving into internals!

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.

vite: vue is undefined in runtime
2 participants