fix(nuxt3): enable auto-imports for sfc script with type (#931)

This commit is contained in:
Xin Du (Clark) 2021-10-13 21:24:13 +01:00 committed by GitHub
parent ff97e2558c
commit a42458e107
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -30,14 +30,17 @@ export const TransformPlugin = createUnplugin((map: IdentifierMap) => {
enforce: 'post',
transformInclude (id) {
const { pathname, search } = parseURL(id)
const query = parseQuery(search)
const { type } = parseQuery(search)
if (id.includes('node_modules')) {
return false
}
// vue files
if (pathname.endsWith('.vue') && (query.type === 'template' || !search)) {
if (
pathname.endsWith('.vue') &&
(type === 'template' || type === 'script' || !search)
) {
return true
}