mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 23:22:02 +00:00
fix(nuxt): only strip supported extensions when generating import types (#26218)
This commit is contained in:
parent
a04b88bfcd
commit
8010b04f69
@ -145,6 +145,8 @@ function addDeclarationTemplates (ctx: Unimport, options: Partial<ImportsOptions
|
|||||||
const resolvedImportPathMap = new Map<string, string>()
|
const resolvedImportPathMap = new Map<string, string>()
|
||||||
const r = ({ from }: Import) => resolvedImportPathMap.get(from)
|
const r = ({ from }: Import) => resolvedImportPathMap.get(from)
|
||||||
|
|
||||||
|
const SUPPORTED_EXTENSION_RE = new RegExp(`\\.(${nuxt.options.extensions.map(i => i.replace('.', '')).join('|')})$`)
|
||||||
|
|
||||||
async function cacheImportPaths (imports: Import[]) {
|
async function cacheImportPaths (imports: Import[]) {
|
||||||
const importSource = Array.from(new Set(imports.map(i => i.from)))
|
const importSource = Array.from(new Set(imports.map(i => i.from)))
|
||||||
await Promise.all(importSource.map(async (from) => {
|
await Promise.all(importSource.map(async (from) => {
|
||||||
@ -164,7 +166,7 @@ function addDeclarationTemplates (ctx: Unimport, options: Partial<ImportsOptions
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (existsSync(path) && !(await isDirectory(path))) {
|
if (existsSync(path) && !(await isDirectory(path))) {
|
||||||
path = path.replace(/\.[a-z]+$/, '')
|
path = path.replace(SUPPORTED_EXTENSION_RE, '')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isAbsolute(path)) {
|
if (isAbsolute(path)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user