Skip to content

Commit

Permalink
refactor: use full path for router type
Browse files Browse the repository at this point in the history
  • Loading branch information
wobsoriano committed May 20, 2022
1 parent 09d043d commit a458ed9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default defineNuxtModule<ModuleOptions>({
nuxt.options.build.transpile.push(runtimeDir, '#build/trpc-client', '#build/trpc-handler')

const handlerPath = join(nuxt.options.buildDir, 'trpc-handler.ts')
const trpcOptionsPath = join(nuxt.options.rootDir, 'server/trpc')

// Final resolved configuration
const finalConfig = nuxt.options.runtimeConfig.public.trpc = defu(nuxt.options.runtimeConfig.public.trpc, {
Expand All @@ -48,7 +49,7 @@ export default defineNuxtModule<ModuleOptions>({
getContents() {
return `
import * as trpc from '@trpc/client'
import type { router } from '~/server/trpc'
import type { router } from '${trpcOptionsPath}'
const client = trpc.createTRPCClient<typeof router>({
url: '${finalConfig.baseURL}${finalConfig.trpcURL}',
Expand All @@ -66,7 +67,7 @@ export default defineNuxtModule<ModuleOptions>({
return `
import { createTRPCHandler } from 'trpc-nuxt/api'
import { useRuntimeConfig } from '#imports'
import * as functions from '~/server/trpc'
import * as functions from '${trpcOptionsPath}'
const { trpc: { trpcURL } } = useRuntimeConfig().public
Expand Down

0 comments on commit a458ed9

Please sign in to comment.