Skip to content

Commit a73a91c

Browse files
committed
feat: add define option to top-level
1 parent a79b5d9 commit a73a91c

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export async function buildSingle(resolved: ResolvedOptions): Promise<
8080
watch,
8181
unused,
8282
target,
83+
define,
8384
onSuccess,
8485
} = resolved
8586

@@ -93,13 +94,15 @@ export async function buildSingle(resolved: ResolvedOptions): Promise<
9394
resolve: { alias },
9495
treeshake,
9596
platform,
97+
define,
9698
plugins: [
9799
pkg && ExternalPlugin(pkg, resolved.skipNodeModulesBundle),
98100
unused && Unused.rolldown(unused === true ? {} : unused),
99101
dts && IsolatedDecl.rolldown(dts === true ? {} : dts),
100102
target &&
101103
transformPlugin({
102-
target: typeof target === 'string' ? target : target.join(','),
104+
target:
105+
target && (typeof target === 'string' ? target : target.join(',')),
103106
}),
104107
plugins,
105108
].filter((plugin) => !!plugin),

src/options.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export interface Options {
4040
/** @default false */
4141
minify?: boolean
4242
target?: string | string[]
43+
define?: Record<string, string>
4344
/** @default 'node' */
4445
platform?: 'node' | 'neutral' | 'browser'
4546
/**
@@ -81,6 +82,7 @@ export type ResolvedOptions = Omit<
8182
| 'outputOptions'
8283
| 'minify'
8384
| 'target'
85+
| 'define'
8486
| 'alias'
8587
| 'external'
8688
| 'onSuccess'

0 commit comments

Comments
 (0)