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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions packages/unplugin-vue-i18n/src/core/directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,13 @@ export function directivePlugin({
if (vuePluginOptions == null) {
vuePluginOptions = getVuePluginOptions(vuePlugin!)
}
analyzeIdentifiers(
getDescriptor(filename, code, vuePluginOptions),
vuePluginOptions,
translationIdentifiers
)
if (vuePluginOptions?.compiler) {
analyzeIdentifiers(
getDescriptor(filename, code, vuePluginOptions),
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?

}
}

Expand Down
Loading