fix(nuxt): strip non-.vue extensions from component types (#7673)

This commit is contained in:
Daniel Roe 2022-09-20 09:54:46 +01:00 committed by GitHub
parent 334e2aba4b
commit 347abcd065
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -75,7 +75,9 @@ export const componentsTypeTemplate: NuxtTemplate<ComponentsTemplateContext> = {
const buildDir = nuxt.options.buildDir
const componentTypes = options.getComponents().map(c => [
c.pascalName,
`typeof ${genDynamicImport(isAbsolute(c.filePath) ? relative(buildDir, c.filePath) : c.filePath, { wrapper: false })}['${c.export}']`
`typeof ${genDynamicImport(isAbsolute(c.filePath)
? relative(buildDir, c.filePath).replace(/(?<=\w)\.(?!vue)\w+$/g, '')
: c.filePath.replace(/(?<=\w)\.(?!vue)\w+$/g, ''), { wrapper: false })}['${c.export}']`
])
return `// Generated by components discovery