Skip to content

Commit

Permalink
fix(unplugin-vue-i18n): don't analyze identifiers in vue files when u…
Browse files Browse the repository at this point in the history
…sing `pug/jsx/tsx` languages (#414)
  • Loading branch information
userquin authored Nov 10, 2024
1 parent 89f10aa commit a01d848
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions packages/unplugin-vue-i18n/src/core/directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export function directivePlugin({
let vuePlugin: RollupPlugin | null = null
let vuePluginOptions: VuePluginResolvedOptions | null = null

const excludeLangs = ['pug', 'jsx', 'tsx']

return {
name: resolveNamespace('directive'),
enforce: 'pre',
Expand Down Expand Up @@ -74,19 +76,19 @@ export function directivePlugin({
},

async transform(code, id) {
const { filename } = parseVueRequest(id)

// lazy load vue plugin options
if (vuePluginOptions == null) {
vuePluginOptions = getVuePluginOptions(vuePlugin!)
}

if (id.endsWith('.vue')) {
analyzeIdentifiers(
getDescriptor(filename, code, vuePluginOptions!),
vuePluginOptions,
translationIdentifiers
)
const { filename, query } = parseVueRequest(id)
if (!excludeLangs.includes(query.lang ?? '')) {
// lazy load vue plugin options
if (vuePluginOptions == null) {
vuePluginOptions = getVuePluginOptions(vuePlugin!)
}
analyzeIdentifiers(
getDescriptor(filename, code, vuePluginOptions),
vuePluginOptions,
translationIdentifiers
)
}
}

return {
Expand Down

0 comments on commit a01d848

Please sign in to comment.