Skip to content

Expose the Captun worker as a package subpath#14

Merged
mmkal merged 3 commits into
mainfrom
mmkal/26/05/22/export-worker-module
May 23, 2026
Merged

Expose the Captun worker as a package subpath#14
mmkal merged 3 commits into
mainfrom
mmkal/26/05/22/export-worker-module

Conversation

@mmkal
Copy link
Copy Markdown
Contributor

@mmkal mmkal commented May 21, 2026

Summary

Expose the existing Captun Worker entrypoint as a package subpath. Published consumers can now import captun/worker and get the default Worker handler plus the CaptunServerShard Durable 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:

import worker, { CaptunServerShard } from "captun/worker";

export { CaptunServerShard };
export default worker;

The source export points to src/worker.ts for repo-local usage, and the publish export points to dist/worker.js/dist/worker.d.ts so packed and published packages expose the same subpath.

Verification

  • pnpm check
  • pnpm test
  • pnpm pack --pack-destination ignoreme-pack
  • tar -xOf ignoreme-pack/captun-0.0.2.tgz package/package.json confirmed ./worker maps to ./dist/worker.js and ./dist/worker.d.ts.
  • pnpm publish:dry-run ran check, test, and prepack, then completed successfully for captun@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/worker package subpath for both source usage and published builds, mapping to src/worker.ts and dist/worker.* respectively.

Updates src/worker.ts to define its own CaptunEnv shape (including the CaptunServerShard DO namespace) instead of extending a repo-local Env type, improving portability of the generated .d.ts for downstream deployments.

Reviewed by Cursor Bugbot for commit 5f1a8f4. Bugbot is set up for automated code reviews on this repo. Configure here.

@mmkal mmkal marked this pull request as ready for review May 21, 2026 23:27
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 21, 2026

Open in StackBlitz

npm i https://pkg.pr.new/captun@14

commit: 5f1a8f4

Comment thread src/worker.ts
@mmkal mmkal merged commit 9db4f37 into main May 23, 2026
5 checks passed
@mmkal mmkal deleted the mmkal/26/05/22/export-worker-module branch May 23, 2026 11:28
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