Skip to content

feat(exe): add cross-platform executable building via @tsdown/exe#786

Merged
sxzz merged 9 commits intomainfrom
sxzz/exe-cross-platform
Mar 3, 2026
Merged

feat(exe): add cross-platform executable building via @tsdown/exe#786
sxzz merged 9 commits intomainfrom
sxzz/exe-cross-platform

Conversation

@sxzz
Copy link
Member

@sxzz sxzz commented Mar 3, 2026

#776

Summary

Adds cross-platform executable building support to --exe feature via a new @tsdown/exe package. Users can specify target platforms, architectures, and Node.js versions to build executables for different OS/arch combinations.

Changes

New package: @tsdown/exe

  • platform.ts — Types (ExeTarget, ExePlatform, ExeArch, ExeExtensionOptions) and URL construction for nodejs.org binary downloads
  • cache.ts — System cache directory resolution (XDG, macOS Library/Caches, Windows LOCALAPPDATA)
  • download.ts — Downloads and extracts Node.js binaries, with caching and debug logging (tsdown:exe:download)
  • index.ts — Public API exports
  • Node version validation: requires >=18.16.0 (SEA support)
  • Dependencies: semver, tinyexec, obug

Modified: src/features/exe.ts

  • ExeOptions now extends ExeExtensionOptions from @tsdown/exe (adds targets field)
  • buildExe() refactored to handle both single-platform and cross-platform builds
  • Extracted buildSingleExe() and resolveOutputFileName() helpers
  • Cross-platform builds: lazy-loads @tsdown/exe, downloads target Node.js binary, sets SEA executable option
  • Platform-aware output naming (.exe suffix, platform-arch suffix)
  • Improved error handling with throwOnError and stdio: 'inherit' for tinyexec calls
  • Improved codesign logic for cross-platform darwin targets

Other changes

  • @tsdown/exe added as optional peer dependency and dev dependency
  • scripts/release.ts: improved tinyexec error handling
  • src/features/pkg/exports.ts: support inlinedDependencies field
  • Various dependency and export configuration updates

Usage

export default {
  exe: {
    targets: [
      { platform: 'linux', arch: 'x64', nodeVersion: '25.7.0' },
      { platform: 'darwin', arch: 'arm64', nodeVersion: '25.7.0' },
      { platform: 'win', arch: 'x64', nodeVersion: '25.7.0' },
    ],
  },
}

Add a new `@tsdown/exe` package that enables building executables for
multiple platforms (win/darwin/linux) and architectures (x64/arm64).

The package downloads Node.js binaries from nodejs.org, caches them in
the system cache directory, and uses the SEA `executable` config field
to produce cross-platform executables.

Users specify targets in their config:
```ts
exe: {
  targets: [
    { platform: 'linux', arch: 'x64', nodeVersion: '22.14.0' },
    { platform: 'darwin', arch: 'arm64', nodeVersion: '22.14.0' },
    { platform: 'win', arch: 'x64', nodeVersion: '22.14.0' },
  ],
}
```
@netlify
Copy link

netlify bot commented Mar 3, 2026

Deploy Preview for tsdown-main ready!

Name Link
🔨 Latest commit 5b7a61c
🔍 Latest deploy log https://app.netlify.com/projects/tsdown-main/deploys/69a709a6d14d2d000849e01f
😎 Deploy Preview https://deploy-preview-786--tsdown-main.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 3, 2026

Open in StackBlitz

tsdown

pnpm add https://pkg.pr.new/rolldown/tsdown@786 -D
npm i https://pkg.pr.new/rolldown/tsdown@786 -D
yarn add https://pkg.pr.new/rolldown/tsdown@786.tgz -D

create-tsdown

pnpm add https://pkg.pr.new/rolldown/tsdown/create-tsdown@786 -D
npm i https://pkg.pr.new/rolldown/tsdown/create-tsdown@786 -D
yarn add https://pkg.pr.new/rolldown/tsdown/create-tsdown@786.tgz -D

@tsdown/exe

pnpm add https://pkg.pr.new/rolldown/tsdown/@tsdown/exe@786 -D
npm i https://pkg.pr.new/rolldown/tsdown/@tsdown/exe@786 -D
yarn add https://pkg.pr.new/rolldown/tsdown/@tsdown/exe@786.tgz -D

tsdown-migrate

pnpm add https://pkg.pr.new/rolldown/tsdown/tsdown-migrate@786 -D
npm i https://pkg.pr.new/rolldown/tsdown/tsdown-migrate@786 -D
yarn add https://pkg.pr.new/rolldown/tsdown/tsdown-migrate@786.tgz -D

commit: bd6af02

sxzz added 6 commits March 3, 2026 17:46
- Validate target nodeVersion satisfies SEA requirements (>=18.16.0 <19.0.0 || >=19.7.0)
- Add obug debug logging throughout download/extract flow
- Add semver and obug as dependencies of @tsdown/exe
- Rename validateNodeVersion to normalizeNodeVersion (validates + strips leading v)
- Simplify SEA version range to >=18.16.0
- Use throwOnError and stdio: inherit for tinyexec calls
- Add debug log for --build-sea invocation
@sxzz sxzz mentioned this pull request Mar 3, 2026
6 tasks
@sxzz sxzz force-pushed the sxzz/exe-cross-platform branch from 257190c to 0e908f0 Compare March 3, 2026 15:30
@sxzz sxzz force-pushed the sxzz/exe-cross-platform branch from 0e908f0 to dbdd618 Compare March 3, 2026 15:32
- Add docs/options/exe.md (EN) and docs/zh-CN/options/exe.md (zh-CN)
- Add sidebar entry and translation for Executable option
- Update CLI reference (EN + zh-CN) with cross-platform info and doc links
- Update skills: option-exe.md, reference-cli.md, SKILL.md
- Remove SEA terminology throughout, link to Node.js docs instead
@sxzz sxzz merged commit b683385 into main Mar 3, 2026
17 checks passed
@sxzz sxzz deleted the sxzz/exe-cross-platform branch March 3, 2026 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant