Skip to content

Commit 28d04b0

Browse files
authored
fix(types): use "unjs/pathe" to make the exported type use relative path (#516)
1 parent 1e3216c commit 28d04b0

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/module.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { fileURLToPath } from 'node:url'
22
import fs from 'node:fs'
33
import { defu } from 'defu'
4+
import { relative } from 'pathe'
45
import { defineNuxtModule, addPlugin, createResolver, addTemplate, extendViteConfig, useLogger, addImportsDir } from '@nuxt/kit'
56
import type { CookieOptions } from 'nuxt/app'
67
import type { SupabaseClientOptions } from '@supabase/supabase-js'
@@ -247,11 +248,11 @@ export default defineNuxtModule<ModuleOptions>({
247248
if (options.types) {
248249
// resolvePath is used to minify user input error.
249250
const path = await resolvePath(options.types)
250-
const basePath = await resolvePath('~~') // ~~ should be the base path in a nuxt project.
251+
const typesPath = await resolvePath('~~/.nuxt/types/') // this is the default path for nuxt types
251252

252253
if (fs.existsSync(path)) {
253-
// we are replacing the basePath with ../.. to move back to the root (~~) directory.
254-
return `export * from '${path.replace(basePath, '../..')}'`
254+
// Make the path relative to the "types" directory.
255+
return `export * from '${relative(typesPath, path)}'`
255256
}
256257
}
257258

0 commit comments

Comments
 (0)