From 5a2ffb115190d48042da6cffa5cb90a3d4a077b5 Mon Sep 17 00:00:00 2001 From: Louis Seubert Date: Sat, 2 Mar 2024 19:49:22 +0100 Subject: [PATCH] import functions from `h3` with relative path --- src/build.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/build.ts b/src/build.ts index 32f2f4936a..d7977ca625 100644 --- a/src/build.ts +++ b/src/build.ts @@ -131,13 +131,6 @@ export async function writeTypes(nitro: Nitro) { if (nitro.unimport) { await nitro.unimport.init(); - // TODO: fully resolve utils exported from `#imports` - autoImportExports = await nitro.unimport - .toExports(typesDir) - .then((r) => - r.replace(/#internal\/nitro/g, relative(typesDir, runtimeDir)) - ); - const resolvedImportPathMap = new Map(); const imports = await nitro.unimport .getImports() @@ -171,6 +164,12 @@ export async function writeTypes(nitro: Nitro) { resolvedImportPathMap.set(i.from, path); } + // TODO: fully resolve utils exported from `#imports` + autoImportExports = await nitro.unimport + .toExports(typesDir) + .then((r) => + r.replace(/'(.*)'/g, (_, i) => `'${resolvedImportPathMap.get(i) ?? i}'`) + ); autoImportedTypes = [ ( await nitro.unimport.generateTypeDeclarations({