Skip to content

Commit 0a96985

Browse files
author
EGOIST
committedJun 5, 2022
fix: allow format to be a string in config file
1 parent 90f2d1a commit 0a96985

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed
 

‎src/index.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,12 @@ const normalizeOptions = async (
5656
}
5757
const options: Buildable<NormalizedOptions> = {
5858
target: 'node14',
59-
format: ['cjs'],
6059
outDir: 'dist',
6160
..._options,
61+
format:
62+
typeof _options.format === 'string'
63+
? [_options.format as Format]
64+
: _options.format || ['cjs'],
6265
dts:
6366
typeof _options.dts === 'boolean'
6467
? _options.dts

‎src/options.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export type Options = {
7272
jsxFragment?: string
7373
outDir?: string
7474
outExtension?: OutExtensionFactory
75-
format?: Format[]
75+
format?: Format[] | string
7676
globalName?: string
7777
env?: {
7878
[k: string]: string
@@ -176,10 +176,11 @@ export type Options = {
176176
}
177177

178178
export type NormalizedOptions = Omit<
179-
MarkRequired<Options, 'entry' | 'format' | 'outDir'>,
180-
'dts'
179+
MarkRequired<Options, 'entry' | 'outDir'>,
180+
'dts' | 'format'
181181
> & {
182182
dts?: DtsConfig
183183
tsconfigResolvePaths: Record<string, string[]>
184184
tsconfigDecoratorMetadata?: boolean
185+
format: Format[]
185186
}

0 commit comments

Comments
 (0)
Please sign in to comment.