Skip to content

Commit

Permalink
import functions from h3 with relative path
Browse files Browse the repository at this point in the history
  • Loading branch information
Louis9902 committed Mar 2, 2024
1 parent 18f2f33 commit 5a2ffb1
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string>();
const imports = await nitro.unimport
.getImports()
Expand Down Expand Up @@ -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({
Expand Down

0 comments on commit 5a2ffb1

Please sign in to comment.