From 0a969854fa76cc671041ffa5e71bfa5aec3a2314 Mon Sep 17 00:00:00 2001 From: EGOIST Date: Mon, 6 Jun 2022 01:21:06 +0800 Subject: [PATCH] fix: allow `format` to be a string in config file --- src/index.ts | 5 ++++- src/options.ts | 7 ++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index 8ac5f349..d31ef334 100644 --- a/src/index.ts +++ b/src/index.ts @@ -56,9 +56,12 @@ const normalizeOptions = async ( } const options: Buildable = { target: 'node14', - format: ['cjs'], outDir: 'dist', ..._options, + format: + typeof _options.format === 'string' + ? [_options.format as Format] + : _options.format || ['cjs'], dts: typeof _options.dts === 'boolean' ? _options.dts diff --git a/src/options.ts b/src/options.ts index f37320c5..2f793483 100644 --- a/src/options.ts +++ b/src/options.ts @@ -72,7 +72,7 @@ export type Options = { jsxFragment?: string outDir?: string outExtension?: OutExtensionFactory - format?: Format[] + format?: Format[] | string globalName?: string env?: { [k: string]: string @@ -176,10 +176,11 @@ export type Options = { } export type NormalizedOptions = Omit< - MarkRequired, - 'dts' + MarkRequired, + 'dts' | 'format' > & { dts?: DtsConfig tsconfigResolvePaths: Record tsconfigDecoratorMetadata?: boolean + format: Format[] }