Skip to content

Commit

Permalink
fix: transpile nitro auto-imports
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Oct 11, 2022
1 parent dab5f5d commit d77b5df
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,23 @@ export default defineNuxtModule<SanityModuleOptions>({
].filter(Boolean))

nuxt.hook('prepare:types', ({ tsConfig }) => {
tsConfig.compilerOptions ||= {}
tsConfig.compilerOptions.paths['#sanity-client'] = [join(runtimeDir, 'client')]
})

nuxt.hook('nitro:config', (config) => {
if (config.imports === false) return

config.virtual ||= {}
config.virtual['#sanity-client'] =
options.minimal
? genExport(join(runtimeDir, 'client'), ['createClient'])
: genExport('@sanity/client', [{ name: 'default', as: 'createClient' }])

config.externals ||= {}
config.externals.inline ||= []
config.externals.inline.push(runtimeDir)

config.imports = defu(config.imports, {
presets: [
{
Expand Down

0 comments on commit d77b5df

Please sign in to comment.