Expose the Captun worker as a package subpath#14
Merged
Conversation
commit: |
mmkal
commented
May 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Expose the existing Captun Worker entrypoint as a package subpath. Published consumers can now import
captun/workerand get the default Worker handler plus theCaptunServerShardDurable Object class from the compiled package.Intended effect
Downstream Cloudflare stacks can deploy Captun inside their own app instead of depending on a separate Captun deployment or threading custom egress fetch hooks through tests:
The source export points to
src/worker.tsfor repo-local usage, and the publish export points todist/worker.js/dist/worker.d.tsso packed and published packages expose the same subpath.Verification
pnpm checkpnpm testpnpm pack --pack-destination ignoreme-packtar -xOf ignoreme-pack/captun-0.0.2.tgz package/package.jsonconfirmed./workermaps to./dist/worker.jsand./dist/worker.d.ts.pnpm publish:dry-runrancheck,test, andprepack, then completed successfully forcaptun@0.0.2.Note
Low Risk
Low risk packaging/type-surface change that primarily affects how consumers import the Worker; minimal runtime logic changes beyond the env type definition.
Overview
Exposes the existing Worker entrypoint as a new
captun/workerpackage subpath for both source usage and published builds, mapping tosrc/worker.tsanddist/worker.*respectively.Updates
src/worker.tsto define its ownCaptunEnvshape (including theCaptunServerShardDO namespace) instead of extending a repo-localEnvtype, improving portability of the generated.d.tsfor downstream deployments.Reviewed by Cursor Bugbot for commit 5f1a8f4. Bugbot is set up for automated code reviews on this repo. Configure here.