Skip to content

Commit

Permalink
feat(plugin-vue): warn compiler-sfc version mismatch
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Aug 24, 2021
1 parent dc8e6c9 commit e7263b9
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions packages/plugin-vue/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,16 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin {
? createFilter(/\.(j|t)sx?$/)
: createFilter(refTransform)

// compat for older verisons
const canUseRefTransform = typeof shouldTransformRef === 'function'

let options: ResolvedOptions = {
isProduction: process.env.NODE_ENV === 'production',
...rawOptions,
include,
exclude,
customElement,
refTransform,
root: process.cwd()
}

Expand Down Expand Up @@ -182,15 +189,15 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin {
return
}
if (!filter(filename) && !query.vue) {
if (
refTransformFilter(filename) &&
!query.vue &&
shouldTransformRef(code)
) {
return transformRef(code, {
filename,
sourceMap: true
})
if (!query.vue && refTransformFilter(filename)) {
if (!canUseRefTransform) {
this.warn('refTransform requires @vue/compiler-sfc@^3.2.5.')
} else if (shouldTransformRef(code)) {
return transformRef(code, {
filename,
sourceMap: true
})
}
}
return
}
Expand Down

0 comments on commit e7263b9

Please sign in to comment.