mirror of
https://github.com/ArthurDanjou/trpc-nuxt.git
synced 2026-01-14 12:14:40 +01:00
2
client.d.ts
vendored
2
client.d.ts
vendored
@@ -1 +1 @@
|
|||||||
export * from './dist/runtime/client'
|
export * from './dist/client/index'
|
||||||
|
|||||||
1
handler.d.ts
vendored
1
handler.d.ts
vendored
@@ -1 +0,0 @@
|
|||||||
export * from './dist/runtime/handler'
|
|
||||||
17
module.mjs
Normal file
17
module.mjs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import { defineNuxtModule } from '@nuxt/kit'
|
||||||
|
|
||||||
|
export default defineNuxtModule({
|
||||||
|
meta: {
|
||||||
|
name: 'trpc-nuxt',
|
||||||
|
configKey: 'trpc',
|
||||||
|
compatibility: {
|
||||||
|
nuxt: '^3.0.0-rc.13',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
async setup(_moduleOptions, nuxt) {
|
||||||
|
nuxt.options.build.transpile.push('trpc-nuxt')
|
||||||
|
nuxt.options.vite.optimizeDeps = nuxt.options.vite.optimizeDeps || {}
|
||||||
|
nuxt.options.vite.optimizeDeps.exclude = nuxt.options.vite.optimizeDeps.exclude || []
|
||||||
|
nuxt.options.vite.optimizeDeps.exclude.push('trpc-nuxt/client')
|
||||||
|
},
|
||||||
|
})
|
||||||
42
package.json
42
package.json
@@ -5,59 +5,53 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"sideEffects": false,
|
"sideEffects": false,
|
||||||
"exports": {
|
"exports": {
|
||||||
|
"./package.json": "./package.json",
|
||||||
".": {
|
".": {
|
||||||
"require": "./dist/module.cjs",
|
"require": "./dist/index.cjs",
|
||||||
"import": "./dist/module.mjs"
|
"import": "./dist/index.mjs"
|
||||||
},
|
},
|
||||||
"./client": {
|
"./client": {
|
||||||
"types": "./dist/runtime/client.d.ts",
|
"require": "./dist/client/index.cjs",
|
||||||
"import": "./dist/runtime/client.mjs"
|
"import": "./dist/client/index.mjs"
|
||||||
},
|
},
|
||||||
"./handler": {
|
"./module": {
|
||||||
"types": "./dist/runtime/handler.d.ts",
|
"import": "./module.mjs"
|
||||||
"import": "./dist/runtime/handler.mjs"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"main": "./dist/module.cjs",
|
"main": "./dist/index.mjs",
|
||||||
"types": "./dist/types.d.ts",
|
"module": "./dist/index.mjs",
|
||||||
|
"types": "./dist/index.d.ts",
|
||||||
"files": [
|
"files": [
|
||||||
"dist",
|
"dist",
|
||||||
"client.d.ts",
|
"client.d.ts",
|
||||||
"handler.d.ts"
|
"module.mjs"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "pnpm prepack && pnpm --filter playground dev",
|
"dev": "concurrently \"pnpm build --watch\" \"pnpm --filter playground dev\"",
|
||||||
"dev:prepare": "nuxt-module-build --stub && nuxi prepare playground",
|
"dev:prepare": "pnpm build && nuxt prepare playground",
|
||||||
"prepublishOnly": "pnpm prepack",
|
"prepublishOnly": "pnpm build",
|
||||||
"prepack": "nuxt-module-build",
|
"build": "tsup",
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"lint:fix": "eslint . --fix",
|
"lint:fix": "eslint . --fix",
|
||||||
"release": "bumpp && npm publish"
|
"release": "bumpp && npm publish"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@trpc/client": "^10.0.0-proxy-beta.21",
|
"@trpc/client": "^10.0.0-proxy-beta.21",
|
||||||
"@trpc/server": "^10.0.0-proxy-beta.21"
|
"@trpc/server": "^10.0.0-proxy-beta.21",
|
||||||
|
"nuxt": "^3.0.0-rc.13"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nuxt/kit": "^3.0.0-rc.13",
|
|
||||||
"dedent": "^0.7.0",
|
|
||||||
"defu": "^6.1.0",
|
|
||||||
"fast-glob": "^3.2.12",
|
|
||||||
"h3": "^0.8.6",
|
"h3": "^0.8.6",
|
||||||
"knitwork": "^0.1.2",
|
|
||||||
"nanoid": "^4.0.0",
|
"nanoid": "^4.0.0",
|
||||||
"ohash": "^0.1.5",
|
"ohash": "^0.1.5",
|
||||||
"pathe": "^0.3.9",
|
|
||||||
"ufo": "^0.8.6"
|
"ufo": "^0.8.6"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@nuxt/module-builder": "^0.2.0",
|
|
||||||
"@nuxt/schema": "^3.0.0-rc.13",
|
|
||||||
"@nuxtjs/eslint-config-typescript": "^11.0.0",
|
"@nuxtjs/eslint-config-typescript": "^11.0.0",
|
||||||
"@trpc/client": "10.0.0-rc.4",
|
"@trpc/client": "10.0.0-rc.4",
|
||||||
"@trpc/server": "10.0.0-rc.4",
|
"@trpc/server": "10.0.0-rc.4",
|
||||||
"@types/dedent": "^0.7.0",
|
|
||||||
"bumpp": "^8.2.1",
|
"bumpp": "^8.2.1",
|
||||||
|
"concurrently": "^7.5.0",
|
||||||
"eslint": "^8.25.0",
|
"eslint": "^8.25.0",
|
||||||
"nuxt": "3.0.0-rc.13",
|
"nuxt": "3.0.0-rc.13",
|
||||||
"tsup": "6.4.0",
|
"tsup": "6.4.0",
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
// https://v3.nuxtjs.org/api/configuration/nuxt.config
|
// https://v3.nuxtjs.org/api/configuration/nuxt.config
|
||||||
export default defineNuxtConfig({
|
export default defineNuxtConfig({
|
||||||
modules: ['trpc-nuxt'],
|
modules: ['trpc-nuxt/module']
|
||||||
trpc: {
|
|
||||||
enableFileRouting: true
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -5,7 +5,8 @@
|
|||||||
"build": "nuxt build",
|
"build": "nuxt build",
|
||||||
"dev": "nuxt dev",
|
"dev": "nuxt dev",
|
||||||
"generate": "nuxt generate",
|
"generate": "nuxt generate",
|
||||||
"preview": "nuxt preview"
|
"preview": "nuxt preview",
|
||||||
|
"postinstall": "nuxt prepare"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@trpc/client": "10.0.0-rc.4",
|
"@trpc/client": "10.0.0-rc.4",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { httpBatchLink, loggerLink } from '@trpc/client'
|
import { httpBatchLink, loggerLink } from '@trpc/client'
|
||||||
import { createTRPCNuxtProxyClient } from 'trpc-nuxt/client'
|
import { createTRPCNuxtProxyClient } from 'trpc-nuxt/client'
|
||||||
import superjson from 'superjson'
|
import superjson from 'superjson'
|
||||||
import type { AppRouter } from '#build/trpc/handler'
|
import type { AppRouter } from '~~/server/trpc/routers'
|
||||||
|
|
||||||
export default defineNuxtPlugin(() => {
|
export default defineNuxtPlugin(() => {
|
||||||
const client = createTRPCNuxtProxyClient<AppRouter>({
|
const client = createTRPCNuxtProxyClient<AppRouter>({
|
||||||
|
|||||||
23
playground/server/api/trpc/[trpc].ts
Normal file
23
playground/server/api/trpc/[trpc].ts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { createNuxtApiHandler } from 'trpc-nuxt'
|
||||||
|
import { appRouter } from '@/server/trpc/routers'
|
||||||
|
import { createContext } from '@/server/trpc/context'
|
||||||
|
|
||||||
|
export default createNuxtApiHandler({
|
||||||
|
router: appRouter,
|
||||||
|
/**
|
||||||
|
* @link https://trpc.io/docs/context
|
||||||
|
*/
|
||||||
|
createContext,
|
||||||
|
onError ({ error }) {
|
||||||
|
if (error.code === 'INTERNAL_SERVER_ERROR') {
|
||||||
|
// send to bug reporting
|
||||||
|
console.error('Something went wrong', error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @link https://trpc.io/docs/caching#api-response-caching
|
||||||
|
*/
|
||||||
|
// responseMeta() {
|
||||||
|
// // ...
|
||||||
|
// },
|
||||||
|
})
|
||||||
17
playground/server/trpc/context.ts
Normal file
17
playground/server/trpc/context.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||||
|
import type { inferAsyncReturnType } from '@trpc/server'
|
||||||
|
import type { H3Event } from 'h3'
|
||||||
|
|
||||||
|
export type Context = inferAsyncReturnType<typeof createContext>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates context for an incoming request
|
||||||
|
* @link https://trpc.io/docs/context
|
||||||
|
*/
|
||||||
|
export function createContext (
|
||||||
|
opts: H3Event
|
||||||
|
) {
|
||||||
|
// for API-response caching see https://trpc.io/docs/caching
|
||||||
|
|
||||||
|
return {}
|
||||||
|
}
|
||||||
10
playground/server/trpc/routers/index.ts
Normal file
10
playground/server/trpc/routers/index.ts
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import { router } from '../trpc'
|
||||||
|
import { todoRouter } from './todo'
|
||||||
|
import { userRouter } from './user'
|
||||||
|
|
||||||
|
export const appRouter = router({
|
||||||
|
todo: todoRouter,
|
||||||
|
user: userRouter
|
||||||
|
})
|
||||||
|
|
||||||
|
export type AppRouter = typeof appRouter
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
import { publicProcedure, router } from '#trpc/init'
|
import { publicProcedure, router } from '../trpc'
|
||||||
|
|
||||||
const baseURL = 'https://jsonplaceholder.typicode.com'
|
const baseURL = 'https://jsonplaceholder.typicode.com'
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@ const TodoShape = z.object({
|
|||||||
|
|
||||||
export type Todo = z.infer<typeof TodoShape>
|
export type Todo = z.infer<typeof TodoShape>
|
||||||
|
|
||||||
export default router({
|
export const todoRouter = router({
|
||||||
getTodos: publicProcedure
|
getTodos: publicProcedure
|
||||||
.query(() => {
|
.query(() => {
|
||||||
return $fetch<Todo[]>(`${baseURL}/todos`)
|
return $fetch<Todo[]>(`${baseURL}/todos`)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
import { publicProcedure, router } from '#trpc/init'
|
import { publicProcedure, router } from '../trpc'
|
||||||
|
|
||||||
const baseURL = 'https://jsonplaceholder.typicode.com'
|
const baseURL = 'https://jsonplaceholder.typicode.com'
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@ const UserShape = z.object({
|
|||||||
|
|
||||||
export type User = z.infer<typeof UserShape>
|
export type User = z.infer<typeof UserShape>
|
||||||
|
|
||||||
export default router({
|
export const userRouter = router({
|
||||||
getUsers: publicProcedure
|
getUsers: publicProcedure
|
||||||
.query(() => {
|
.query(() => {
|
||||||
return $fetch<User[]>(`${baseURL}/users`)
|
return $fetch<User[]>(`${baseURL}/users`)
|
||||||
|
|||||||
@@ -1,17 +1,43 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
import { initTRPC } from '@trpc/server'
|
||||||
import type { inferAsyncReturnType } from '@trpc/server'
|
import superjson from 'superjson'
|
||||||
import type { H3Event } from 'h3'
|
import { ZodError } from 'zod'
|
||||||
|
import type { Context } from './context'
|
||||||
|
|
||||||
export type Context = inferAsyncReturnType<typeof createContext>
|
const t = initTRPC.context<Context>().create({
|
||||||
|
transformer: superjson,
|
||||||
|
errorFormatter ({ shape, error }) {
|
||||||
|
return {
|
||||||
|
...shape,
|
||||||
|
data: {
|
||||||
|
...shape.data,
|
||||||
|
zodError:
|
||||||
|
error.code === 'BAD_REQUEST' &&
|
||||||
|
error.cause instanceof ZodError
|
||||||
|
? error.cause!.flatten()
|
||||||
|
: null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates context for an incoming request
|
* Create a router
|
||||||
* @link https://trpc.io/docs/context
|
* @see https://trpc.io/docs/v10/router
|
||||||
*/
|
*/
|
||||||
export function createContext (
|
export const router = t.router
|
||||||
opts: H3Event
|
|
||||||
) {
|
|
||||||
// for API-response caching see https://trpc.io/docs/caching
|
|
||||||
|
|
||||||
return {}
|
/**
|
||||||
}
|
* Create an unprotected procedure
|
||||||
|
* @see https://trpc.io/docs/v10/procedures
|
||||||
|
**/
|
||||||
|
export const publicProcedure = t.procedure
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see https://trpc.io/docs/v10/middlewares
|
||||||
|
*/
|
||||||
|
export const middleware = t.middleware
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see https://trpc.io/docs/v10/merging-routers
|
||||||
|
*/
|
||||||
|
export const mergeRouters = t.mergeRouters
|
||||||
|
|||||||
388
pnpm-lock.yaml
generated
388
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,3 @@
|
|||||||
packages:
|
packages:
|
||||||
- playground
|
- playground
|
||||||
- docs
|
- docs
|
||||||
- examples/*
|
|
||||||
|
|||||||
1
src/index.ts
Normal file
1
src/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export * from './server'
|
||||||
143
src/module.ts
143
src/module.ts
@@ -1,143 +0,0 @@
|
|||||||
import fs from 'fs'
|
|
||||||
import { defineNuxtModule, addTemplate, addServerHandler } from '@nuxt/kit'
|
|
||||||
import fg from 'fast-glob'
|
|
||||||
import { resolve } from 'pathe'
|
|
||||||
import dedent from 'dedent'
|
|
||||||
|
|
||||||
export interface ModuleOptions {
|
|
||||||
enableFileRouting: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
export default defineNuxtModule<ModuleOptions>({
|
|
||||||
meta: {
|
|
||||||
name: 'trpc-nuxt',
|
|
||||||
configKey: 'trpc',
|
|
||||||
compatibility: {
|
|
||||||
nuxt: '^3.0.0-rc.13'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
defaults: {
|
|
||||||
enableFileRouting: false
|
|
||||||
},
|
|
||||||
async setup (moduleOptions, nuxt) {
|
|
||||||
nuxt.options.build.transpile.push('trpc-nuxt')
|
|
||||||
nuxt.options.vite.optimizeDeps = nuxt.options.vite.optimizeDeps || {}
|
|
||||||
nuxt.options.vite.optimizeDeps.exclude = nuxt.options.vite.optimizeDeps.exclude || []
|
|
||||||
nuxt.options.vite.optimizeDeps.exclude.push('trpc-nuxt/client', 'trpc-nuxt/handler')
|
|
||||||
|
|
||||||
if (!moduleOptions.enableFileRouting) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const files: string[] = []
|
|
||||||
const dirs = [
|
|
||||||
resolve(nuxt.options.rootDir, 'server/trpc/routers')
|
|
||||||
]
|
|
||||||
const extGlob = '*.{ts,js}'
|
|
||||||
|
|
||||||
async function scanServerRouters () {
|
|
||||||
files.length = 0
|
|
||||||
files.push(...new Set(
|
|
||||||
(await Promise.all(
|
|
||||||
dirs.map(dir => fg(extGlob, { cwd: dir, absolute: true, onlyFiles: true })))
|
|
||||||
).flat()
|
|
||||||
))
|
|
||||||
return files
|
|
||||||
}
|
|
||||||
|
|
||||||
nuxt.hook('builder:watch', async (e, path) => {
|
|
||||||
if (e === 'change') {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const abs = resolve(nuxt.options.rootDir, path)
|
|
||||||
if (files.includes(abs) || dirs.some(dir => abs.startsWith(dir))) {
|
|
||||||
await scanServerRouters()
|
|
||||||
await nuxt.callHook('builder:generateApp')
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
function getRouteName (routePath: string) {
|
|
||||||
const pathSplit = routePath.split('/')
|
|
||||||
return pathSplit[pathSplit.length - 1]
|
|
||||||
}
|
|
||||||
|
|
||||||
addTemplate({
|
|
||||||
filename: 'trpc/init.mjs',
|
|
||||||
write: true,
|
|
||||||
getContents () {
|
|
||||||
return dedent`
|
|
||||||
import { initTRPC } from '@trpc/server'
|
|
||||||
|
|
||||||
const t = initTRPC.context().create()
|
|
||||||
|
|
||||||
export const router = t.router
|
|
||||||
export const defineRouter = router
|
|
||||||
export const publicProcedure = t.procedure
|
|
||||||
export const middleware = t.middleware
|
|
||||||
export const mergeRouters = t.mergeRouters
|
|
||||||
`
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
addTemplate({
|
|
||||||
filename: 'trpc/types.d.ts',
|
|
||||||
write: true,
|
|
||||||
getContents () {
|
|
||||||
const initFile = resolve(nuxt.options.buildDir, 'trpc/init.mjs')
|
|
||||||
return dedent`
|
|
||||||
declare module '#trpc/init' {
|
|
||||||
const router: typeof import('${initFile}').router
|
|
||||||
const defineRouter: typeof import('${initFile}').defineRouter
|
|
||||||
const publicProcedure: typeof import('${initFile}').publicProcedure
|
|
||||||
const middleware: typeof import('${initFile}').middleware
|
|
||||||
const mergeRouters: typeof import('${initFile}').mergeRouters
|
|
||||||
}
|
|
||||||
`
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
addTemplate({
|
|
||||||
filename: 'trpc/handler.ts',
|
|
||||||
write: true,
|
|
||||||
getContents () {
|
|
||||||
const routeFiles = files.map(i => i.replace(/\.ts$/, ''))
|
|
||||||
const otherConfigPath = resolve(nuxt.options.rootDir, 'server/trpc/trpc.ts')
|
|
||||||
const hasConfig = fs.existsSync(otherConfigPath)
|
|
||||||
return dedent`
|
|
||||||
import { createNuxtApiHandler } from 'trpc-nuxt/handler'
|
|
||||||
import { router } from '${resolve(nuxt.options.buildDir, 'trpc/init.mjs')}'
|
|
||||||
${hasConfig ? `import * as handlerConfig from '${otherConfigPath.replace('.ts', '')}'` : ''}
|
|
||||||
${routeFiles.map(i => `import { default as ${getRouteName(i)}Route } from '${i}'`).join('\n')}
|
|
||||||
|
|
||||||
export const appRouter = router({
|
|
||||||
${routeFiles.map(i => `${getRouteName(i)}: ${getRouteName(i)}Route`).join(',\n')}
|
|
||||||
})
|
|
||||||
|
|
||||||
export type AppRouter = typeof appRouter
|
|
||||||
|
|
||||||
export default createNuxtApiHandler({
|
|
||||||
router: appRouter,
|
|
||||||
${hasConfig ? '...handlerConfig' : ''}
|
|
||||||
})
|
|
||||||
`
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
addServerHandler({
|
|
||||||
route: '/api/trpc/:trpc',
|
|
||||||
handler: resolve(nuxt.options.buildDir, 'trpc/handler.ts'),
|
|
||||||
lazy: true
|
|
||||||
})
|
|
||||||
|
|
||||||
nuxt.hook('nitro:config', (nitroConfig) => {
|
|
||||||
nitroConfig.alias = nitroConfig.alias || {}
|
|
||||||
nitroConfig.alias['#trpc/init'] = resolve(nuxt.options.buildDir, 'trpc/init.mjs')
|
|
||||||
})
|
|
||||||
|
|
||||||
nuxt.hook('prepare:types', (options) => {
|
|
||||||
options.references.push({ path: resolve(nuxt.options.buildDir, 'trpc/types.d.ts') })
|
|
||||||
})
|
|
||||||
|
|
||||||
await scanServerRouters()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
@@ -1,17 +1,17 @@
|
|||||||
|
import type { ResponseMeta } from '@trpc/server/http'
|
||||||
import { resolveHTTPResponse } from '@trpc/server/http'
|
import { resolveHTTPResponse } from '@trpc/server/http'
|
||||||
import {
|
|
||||||
TRPCError
|
|
||||||
} from '@trpc/server'
|
|
||||||
import type {
|
import type {
|
||||||
AnyRouter,
|
AnyRouter,
|
||||||
ProcedureType,
|
ProcedureType,
|
||||||
inferRouterContext,
|
inferRouterContext,
|
||||||
inferRouterError
|
inferRouterError
|
||||||
} from '@trpc/server'
|
} from '@trpc/server'
|
||||||
import type { H3Event } from 'h3'
|
import {
|
||||||
|
TRPCError
|
||||||
|
} from '@trpc/server'
|
||||||
import { createURL } from 'ufo'
|
import { createURL } from 'ufo'
|
||||||
|
import type { H3Event } from 'h3'
|
||||||
import { createError, defineEventHandler, isMethod, readBody } from 'h3'
|
import { createError, defineEventHandler, isMethod, readBody } from 'h3'
|
||||||
import type { ResponseMeta } from '@trpc/server/http'
|
|
||||||
import type { TRPCResponse } from '@trpc/server/rpc'
|
import type { TRPCResponse } from '@trpc/server/rpc'
|
||||||
|
|
||||||
type MaybePromise<T> = T | Promise<T>
|
type MaybePromise<T> = T | Promise<T>
|
||||||
@@ -1,3 +1,16 @@
|
|||||||
{
|
{
|
||||||
"extends": "./playground/.nuxt/tsconfig.json"
|
"compilerOptions": {
|
||||||
|
"target": "es2020",
|
||||||
|
"module": "esnext",
|
||||||
|
"strict": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"noUnusedLocals": true,
|
||||||
|
"noImplicitAny": true,
|
||||||
|
"allowJs": true,
|
||||||
|
"noEmit": true,
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"skipDefaultLibCheck": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
15
tsup.config.ts
Normal file
15
tsup.config.ts
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import { defineConfig } from 'tsup'
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
entry: ['src/index.ts', 'src/client/index.ts'],
|
||||||
|
format: ['cjs', 'esm'],
|
||||||
|
splitting: false,
|
||||||
|
clean: true,
|
||||||
|
external: ['#app', '#imports'],
|
||||||
|
dts: true,
|
||||||
|
outExtension({ format }) {
|
||||||
|
return {
|
||||||
|
js: format === 'esm' ? '.mjs' : `.${format}`,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user