Skip to content

fix: binary entrypoint output and shim type declarations - #512

Merged
dsherret merged 4 commits into
denoland:mainfrom
dsherret:fix_bin_entrypoints
Jul 27, 2026
Merged

fix: binary entrypoint output and shim type declarations#512
dsherret merged 4 commits into
denoland:mainfrom
dsherret:fix_bin_entrypoints

Conversation

@dsherret

Copy link
Copy Markdown
Collaborator

Closes #319
Closes #338
Closes #409

Four related fixes.

A binary's modules are no longer in the script output (#319)

A binary is only ever run by Node.js, so emitting its modules to script/ as well as esm/ was dead weight. The transform now returns the output files that are only reachable from a binary entrypoint and they're left out of the script program. A module that something else uses (an export entrypoint or a test) still goes to both.

Following your note on the issue, the reachability is computed in the rust code. As a side effect a binary may now use a top level await even when the package has a CommonJS output.

A binary entrypoint may go without a name (#338)

{ kind: "bin", path: "./cli.ts" } produced "bin": { "undefined": "./esm/cli.js" }. It now emits the string form, which npm treats as the package name being the command:

"bin": "./esm/cli.js"

name is optional on EntryPoint now, and it errors when an export entrypoint has no name or when there are multiple binaries and one of them has no name.

The binary pointed at a file that doesn't exist

With esModule: false the "bin" entry still pointed at ./esm/.... It now points at the script output in that case.

Shim type declarations reach the dev dependencies (#409)

A shim's typesPackage (ex. @types/ws for the webSocket shim) went into the test environment's dependencies, so it was dropped when test was false and the output failed to type check. They now go through the types dependencies that #509 added, which always reach devDependencies.

dsherret added 4 commits July 26, 2026 20:32
- keep the modules that only a binary entrypoint uses out of the script
  output, since a binary is only ever run by node (denoland#319)
- allow a single binary entrypoint to go without a name, which uses the
  package name as the name of the command (denoland#338)
- point the binary at the script output when there's no esm output,
  which was pointing at a file that didn't exist
- add the type declarations of a shim to the dev dependencies whether or
  not the tests are included in the output (denoland#409)

Closes denoland#319
Closes denoland#338
Closes denoland#409
- keep an entrypoint that's also an export out of the binary only files,
  which was leaving it out of the script output
- don't error for a top level await in a file that isn't in the script
  output
- dedupe the type declarations of a shim that's in both the shims and
  the test shims
- add end to end coverage and document the behavior
@dsherret
dsherret merged commit eaa5668 into denoland:main Jul 27, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant