Skip to content

Commit

Permalink
fix(nuxt): only strip supported extensions when generating import typ…
Browse files Browse the repository at this point in the history
…es (#26218)
  • Loading branch information
productdevbook committed Mar 12, 2024
1 parent a04b88b commit 8010b04
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/nuxt/src/imports/module.ts
Expand Up @@ -145,6 +145,8 @@ function addDeclarationTemplates (ctx: Unimport, options: Partial<ImportsOptions
const resolvedImportPathMap = new Map<string, string>()
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[]) {
const importSource = Array.from(new Set(imports.map(i => i.from)))
await Promise.all(importSource.map(async (from) => {
Expand All @@ -164,7 +166,7 @@ function addDeclarationTemplates (ctx: Unimport, options: Partial<ImportsOptions
}

if (existsSync(path) && !(await isDirectory(path))) {
path = path.replace(/\.[a-z]+$/, '')
path = path.replace(SUPPORTED_EXTENSION_RE, '')
}

if (isAbsolute(path)) {
Expand Down

0 comments on commit 8010b04

Please sign in to comment.