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(unplugin-vue-i18n): check for vue compiler in directive transform hook #421

Merged

Conversation

userquin
Copy link
Member

resolves #420

@userquin userquin changed the title fix: check for vue compiler in directive transform hook fix(unplugin-vue-i18n): check for vue compiler in directive transform hook Nov 16, 2024
vuePluginOptions,
translationIdentifiers
)
}
Copy link
Member Author

@userquin userquin Nov 16, 2024

Choose a reason for hiding this comment

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

should we set vuePluginOptions to null if missing compiler?

Copy link
Member

@kazupon kazupon Nov 17, 2024

Choose a reason for hiding this comment

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

Ah, yeah!
vue-i18n directive does not work without Vue compiler for SSR.

if Vue compiler is not specify on vitejs/plugin-vue, unplugin-vue-i18n should output warning.
(I recognize vitejs/plugin-vue has Vue compiler as default)

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh that's true, it is about the v-t directive, I'm going to check if ssr is exposed.

If this is only a vite plugin why not just expose the transform hook inside vite?

@userquin
Copy link
Member Author

closing this, it is a bug in @vitejs/plugin-vue, compiler not being initialized correctly: vitejs/vite-plugin-vue#475

@userquin userquin closed this Nov 17, 2024
@userquin userquin deleted the userquin/fix-vite-nuxt-stackblitz-errors branch November 17, 2024 15:42
@userquin userquin restored the userquin/fix-vite-nuxt-stackblitz-errors branch December 5, 2024 11:50
@userquin userquin reopened this Dec 5, 2024
@userquin
Copy link
Member Author

userquin commented Dec 5, 2024

@kazupon @BobbieGoede looks like Vite Vue plugin PR will take some time, I guess we can use the protection in this PR to avoid the error in Nuxt calling Vite warmup.

@BobbieGoede
Copy link
Member

BobbieGoede commented Dec 5, 2024

I agree we probably need to skip transform if the compiler is unset, it seems like both devtools (Overlay.vue) and nuxt (nuxt-root.vue) trigger this in some sort of race condition. I'm not sure if it's something we should/can fix at their end.

Related nuxt-modules/i18n#3241

Copy link
Member

@kazupon kazupon left a comment

Choose a reason for hiding this comment

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

LGTM!

@kazupon kazupon merged commit 4a53965 into intlify:main Dec 6, 2024
10 checks passed
@userquin userquin deleted the userquin/fix-vite-nuxt-stackblitz-errors branch December 6, 2024 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: unplugin-vue-i18n Type: Improvement Includes backwards-compatible fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

error when running Nuxt I18n module with latest Nuxt version (π version) in StackBlitz
3 participants