Skip to content

Commit 7ebd62d

Browse files
authored
feat(exports): add bin option to auto-generate package.json bin field (#869)
* feat(exports): add `bin` option to auto-generate package.json bin field Adds `exports.bin` option that auto-generates the `bin` field in package.json based on built entry chunks. Supports three forms: - `true`: auto-detect entry chunks with shebangs - `string`: specify source file, bin name defaults to package name - `Record<string, string>`: map command names to source files * feat(config): use mergeConfig for workspace config merging and support variadic overrides - Replace shallow spread merging with deep `mergeConfig` in workspace resolution - Update `mergeConfig` to accept multiple overrides via rest params * fix
1 parent 148aaaa commit 7ebd62d

File tree

6 files changed

+335
-5
lines changed

6 files changed

+335
-5
lines changed

dts.snapshot.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
"DepsPlugin": "declare function DepsPlugin(_: ResolvedConfig, _: TsdownBundle): Plugin",
129129
"DevtoolsOptions": "interface DevtoolsOptions extends NonNullable<InputOptions['devtools']> {\n ui?: boolean | Partial<StartOptions>\n clean?: boolean\n}",
130130
"ExeOptions": "interface ExeOptions extends ExeExtensionOptions {\n seaConfig?: Omit<SeaConfig, 'main' | 'output' | 'mainFormat'>\n fileName?: string | ((_: RolldownChunk) => string)\n outDir?: string\n}",
131-
"ExportsOptions": "interface ExportsOptions {\n devExports?: boolean | string\n packageJson?: boolean\n all?: boolean\n exclude?: (RegExp | string)[]\n legacy?: boolean\n customExports?: Record<string, any> | ((_: Record<string, any>, _: { pkg: PackageJson; chunks: ChunksByFormat; isPublish: boolean }) => Awaitable<Record<string, any>>)\n inlinedDependencies?: boolean\n}",
131+
"ExportsOptions": "interface ExportsOptions {\n devExports?: boolean | string\n packageJson?: boolean\n all?: boolean\n exclude?: (RegExp | string)[]\n legacy?: boolean\n customExports?: Record<string, any> | ((_: Record<string, any>, _: { pkg: PackageJson; chunks: ChunksByFormat; isPublish: boolean }) => Awaitable<Record<string, any>>)\n inlinedDependencies?: boolean\n bin?: boolean | string | Record<string, string>\n}",
132132
"Format": "type Format = ModuleFormat",
133133
"InlineConfig": "interface InlineConfig extends UserConfig {\n config?: boolean | string\n configLoader?: 'auto' | 'native' | 'unrun'\n filter?: RegExp | Arrayable<string>\n}",
134134
"NoExternalFn": "type NoExternalFn = (_: string, _: string | undefined) => boolean | null | undefined | void",

packages/create-tsdown/tsdown.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@ import type { UserConfig } from '../../src/config.ts'
22

33
export default {
44
entry: ['./src/{index,run}.ts'],
5+
exports: {
6+
bin: true,
7+
},
58
} satisfies UserConfig

packages/migrate/tsdown.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@ import type { UserConfig } from '../../src/config.ts'
33
export default {
44
name: 'migrate',
55
entry: ['./src/{index,run}.ts'],
6+
exports: {
7+
bin: true,
8+
},
69
} satisfies UserConfig

0 commit comments

Comments
 (0)