Skip to content

Commit

Permalink
feat: allow disabling tsconfig generation
Browse files Browse the repository at this point in the history
vite doesn't likes this
  • Loading branch information
pi0 committed Apr 6, 2022
1 parent 0f20bf8 commit f30a026
Showing 1 changed file with 27 additions and 21 deletions.
48 changes: 27 additions & 21 deletions src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ export async function build (nitro: Nitro) {
return nitro.options.dev ? _watch(nitro) : _build(nitro)
}

export async function writeTypes (nitro: Nitro) {
export interface WriteTypesOptions {
tsConfig?: boolean
}

export async function writeTypes (nitro: Nitro, opts: WriteTypesOptions = {}) {
const routeTypes: Record<string, string[]> = {}

const middleware = [
Expand Down Expand Up @@ -94,27 +98,29 @@ export async function writeTypes (nitro: Nitro) {

await writeFile(join(nitro.options.buildDir, 'types/nitro.d.ts'), lines.join('\n'))

const tsConfig: TSConfig = {
compilerOptions: {
target: 'ESNext',
module: 'ESNext',
moduleResolution: 'Node',
allowJs: true,
resolveJsonModule: true,
paths: {
'#nitro': [
join(runtimeDir, 'index')
],
'#nitro/*': [
join(runtimeDir, '*')
]
}
},
include: [
'./nitro.d.ts'
]
if (opts.tsConfig !== false) {
const tsConfig: TSConfig = {
compilerOptions: {
target: 'ESNext',
module: 'ESNext',
moduleResolution: 'Node',
allowJs: true,
resolveJsonModule: true,
paths: {
'#nitro': [
join(runtimeDir, 'index')
],
'#nitro/*': [
join(runtimeDir, '*')
]
}
},
include: [
'./nitro.d.ts'
]
}
await writeFile(join(nitro.options.buildDir, 'types/tsconfig.json'), JSON.stringify(tsConfig, null, 2))
}
await writeFile(join(nitro.options.buildDir, 'types/tsconfig.json'), JSON.stringify(tsConfig, null, 2))
}

async function _build (nitro: Nitro) {
Expand Down

0 comments on commit f30a026

Please sign in to comment.