File tree Expand file tree Collapse file tree 4 files changed +16
-5
lines changed
Expand file tree Collapse file tree 4 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -254,7 +254,7 @@ This will bundle the output into a single executable file using Node.js SEA. Req
254254
255255When ` exe ` is enabled:
256256
257- - The default output format changes from ` esm ` to ` cjs ` (unless ESM SEA is supported).
257+ - The default output format changes from ` esm ` to ` cjs ` (unless ESM SEA is supported, i.e., Node.js >= v25.7.0 ).
258258- Declaration file generation (` dts ` ) is disabled by default.
259259- Code splitting is disabled.
260260- Only single entry points are supported.
Original file line number Diff line number Diff line change @@ -254,7 +254,7 @@ tsdown --copy public
254254
255255启用 ` exe ` 时:
256256
257- - 默认输出格式从 ` esm ` 变更为 ` cjs ` (除非支持 ESM SEA)。
257+ - 默认输出格式从 ` esm ` 变更为 ` cjs ` (除非支持 ESM SEA,即 Node.js >= v25.7.0 )。
258258- 默认禁用声明文件生成(` dts ` )。
259259- 禁用代码分割。
260260- 仅支持单入口。
Original file line number Diff line number Diff line change 1+ import satisfies from 'semver/functions/satisfies.js'
12import { readFile } from 'node:fs/promises'
23import path from 'node:path'
34import process from 'node:process'
@@ -290,14 +291,18 @@ export async function resolveUserConfig(
290291 write,
291292 }
292293
294+ let defaultFormat : Format = 'esm'
293295 if ( exe ) {
294296 validateSea ( config )
297+ if ( satisfies ( process . version , '<25.7.0' ) ) {
298+ defaultFormat = 'cjs'
299+ }
295300 }
296301
297302 const objectFormat = typeof format === 'object' && ! Array . isArray ( format )
298303 const formats = objectFormat
299304 ? ( Object . keys ( format ) as Format [ ] )
300- : resolveComma ( toArray < Format > ( format , exe ? 'cjs' : 'es' ) )
305+ : resolveComma ( toArray < Format > ( format , defaultFormat ) )
301306
302307 return formats . map ( ( fmt , idx ) : ResolvedConfig => {
303308 const once = idx === 0
Original file line number Diff line number Diff line change @@ -329,11 +329,17 @@ export interface UserConfig {
329329 //#region Output Options
330330
331331 /**
332- * Output format(s). Defaults to ESM.
332+ * Output format(s). Available formats are
333+ * - `esm`: ESM
334+ * - `cjs`: CommonJS
335+ * - `iife`: IIFE
336+ * - `umd`: UMD
337+ *
338+ * Defaults to ESM.
333339 *
334340 * ### Usage with {@link exe}
335341 * If `exe` is enabled, the default format will depend on support level of SEA in the target Node.js version:
336- * - If ESM SEA is supported, the default format will be ESM.
342+ * - If ESM SEA is supported (Node.js > v25.7) , the default format will be ESM.
337343 * - If only CJS SEA is supported, the default format will be CJS.
338344 */
339345 format ?: Format | Format [ ] | Partial < Record < Format , Partial < ResolvedConfig > > >
You can’t perform that action at this time.
0 commit comments