From 86d61abeda05cf7d75a6a2cf1c037da5665053ba Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Fri, 26 May 2023 11:59:27 -0500 Subject: [PATCH] feat: allow customising generated tsConfig --- src/build.ts | 4 ++-- src/options.ts | 1 + src/types/nitro.ts | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/build.ts b/src/build.ts index a28c001a7b..b433635be5 100644 --- a/src/build.ts +++ b/src/build.ts @@ -198,7 +198,7 @@ declare module 'nitropack' { nitro.options.typescript.tsconfigPath ); const tsconfigDir = dirname(tsConfigPath); - const tsConfig: TSConfig = { + const tsConfig: TSConfig = defu(nitro.options.typescript.tsConfig, { compilerOptions: { forceConsistentCasingInFileNames: true, strict: nitro.options.typescript.strict, @@ -224,7 +224,7 @@ declare module 'nitropack' { ? [join(relative(tsconfigDir, nitro.options.srcDir), "**/*")] : []), ], - }; + }); buildFiles.push({ path: tsConfigPath, contents: JSON.stringify(tsConfig, null, 2), diff --git a/src/options.ts b/src/options.ts index cf46abef0e..b393e5b398 100644 --- a/src/options.ts +++ b/src/options.ts @@ -101,6 +101,7 @@ const NitroDefaults: NitroConfig = { generateTsConfig: true, tsconfigPath: "types/tsconfig.json", internalPaths: false, + tsConfig: {}, }, nodeModulesDirs: [], hooks: {}, diff --git a/src/types/nitro.ts b/src/types/nitro.ts index 9c7713072b..f7ab4e41a5 100644 --- a/src/types/nitro.ts +++ b/src/types/nitro.ts @@ -12,6 +12,7 @@ import type { Storage, BuiltinDriverName } from "unstorage"; import type { ServerOptions as HTTPProxyOptions } from "http-proxy"; import type { ProxyOptions } from "h3"; import type { ResolvedConfig, ConfigWatcher } from "c12"; +import type { TSConfig } from "pkg-types"; import type { NodeExternalsOptions } from "../rollup/plugins/externals"; import type { RollupConfig } from "../rollup/config"; import type { Options as EsbuildOptions } from "../rollup/plugins/esbuild"; @@ -262,6 +263,7 @@ export interface NitroOptions extends PresetOptions { generateTsConfig?: boolean; /** the path of the generated `tsconfig.json`, relative to buildDir */ tsconfigPath: string; + tsConfig?: Partial; }; hooks: NestedHooks; nodeModulesDirs: string[];