Skip to content

Commit b15c7bc

Browse files
committed
fix: normalize runtime option names
1 parent 48386db commit b15c7bc

5 files changed

Lines changed: 12 additions & 8 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ await bundle(path.resolve('./src/index.ts'), {
571571
external: [], // string[]
572572
format: 'esm', // 'esm' | 'cjs'
573573
target: 'es2022', // ES syntax target
574-
runtime: 'nodejs', // 'browser' | 'nodejs'
574+
runtime: 'node', // 'browser' | 'node'
575575
cwd: process.cwd(), // string
576576
clean: true, // boolean
577577
tsconfig: 'tsconfig.json', // string

src/bin/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Options:
4242
--no-external do not bundle external dependencies
4343
--no-clean do not clean dist folder before building, default: false
4444
--target <target> js features target: swc target es versions. default: es2022
45-
--runtime <runtime> build runtime (nodejs, browser). default: browser
45+
--runtime <runtime> build runtime (node, browser). default: browser
4646
--env <env> inlined process env variables, separate by comma. default: NODE_ENV
4747
--cwd <cwd> specify current working directory
4848
--sourcemap enable sourcemap generation
@@ -110,8 +110,9 @@ async function parseCliArgs(argv: string[]) {
110110
})
111111
.option('runtime', {
112112
type: 'string',
113+
choices: ['browser', 'node'] as const,
113114
default: 'browser',
114-
description: 'build runtime (nodejs, browser)',
115+
description: 'build runtime (node, browser)',
115116
})
116117
.option('target', {
117118
type: 'string',
@@ -192,7 +193,7 @@ async function parseCliArgs(argv: string[]) {
192193
dts: args['dts'] === false ? false : undefined,
193194
dtsBundle: args['dts-bundle'],
194195
help: args['help'],
195-
runtime: args['runtime'],
196+
runtime: args['runtime'] as CliArgs['runtime'],
196197
target: args['target'] as CliArgs['target'],
197198
// no-external is a boolean flag, turning external to `false`
198199
external:

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export type { BundleConfig } from './types'
1+
export type { BundleConfig, Runtime } from './types'
22
export { default as bundle } from './bundle'
33
// Piscina worker handler, loaded by name from dist/index.js. Not public API.
44
export { buildEntryInWorker } from './worker'

src/types.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import type { TypescriptOptions } from './typescript'
66

77
type PackageType = 'commonjs' | 'module'
88

9+
type Runtime = 'browser' | 'node'
10+
911
type ExportType =
1012
| 'import'
1113
| 'module'
@@ -43,7 +45,7 @@ type BundleConfig = {
4345
external?: string[] | null
4446
env?: string[]
4547
dts?: { respectExternal?: boolean } | false
46-
runtime?: string
48+
runtime?: Runtime
4749
pkg?: PackageMetadata
4850
clean?: boolean
4951
tsconfig?: string
@@ -144,7 +146,7 @@ type CliArgs = {
144146
external?: string | null
145147
dts?: false
146148
dtsBundle?: boolean
147-
runtime?: string
149+
runtime?: Runtime
148150
clean?: boolean
149151
tsconfig?: string
150152
onSuccess?: string
@@ -212,4 +214,5 @@ export type {
212214
bundleEntryOptions,
213215
BrowserslistConfig,
214216
CustomRollupInputOptions,
217+
Runtime,
215218
}

src/typing.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe('types', () => {
1313
external: [],
1414
format: 'esm',
1515
target: 'es2015',
16-
runtime: 'nodejs',
16+
runtime: 'node',
1717
}
1818

1919
return () => bundle('./tmp/index.ts', options)

0 commit comments

Comments
 (0)