Bundle fork of capnweb directly - #99
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adjusts the Typegres packaging and documentation so the project’s fork of capnweb is bundled into typegres/capnweb (rather than requiring consumers to install/import capnweb directly), including a Workers-specific build routed via export conditions.
Changes:
- Force-bundle
capnwebin the library build and add aworkerd-conditionedtypegres/capnwebexport that resolves a Workers-compatible bundle. - Re-export the needed
capnwebsurface fromtypegres/capnweband update examples/docs to import fromtypegres/capnwebonly. - Strengthen README snippet testing by installing from a real packed tarball (to match published-consumer resolution) and add coverage for the new RPC README section.
Reviewed changes
Copilot reviewed 10 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tsdown.config.ts | Forces bundling of capnweb and adds a workerd-conditioned shim build. |
| src/readme.test.ts | Switches working-tree install to npm pack tarball and adds RPC section execution assertions. |
| src/capnweb/shim.ts | Re-exports capnweb runtime surface from typegres/capnweb to keep a single effective copy in consumer code. |
| README.md | Adds an RPC section and documents importing Cap’n Web APIs from typegres/capnweb (not capnweb). |
| package.json | Routes typegres/capnweb via conditional exports and moves capnweb to devDependencies. |
| package-lock.json | Updates lockfile to reflect capnweb as dev-only. |
| examples/chat/worker/chat-do.ts | Updates imports to use typegres/capnweb. |
| examples/chat/tests/facet-spike.test.ts | Updates imports to use typegres/capnweb. |
| examples/chat/tests/capabilities.test.ts | Updates imports to use typegres/capnweb. |
| examples/chat/src/rpc.ts | Updates imports to use typegres/capnweb. |
| examples/chat/package.json | Removes direct capnweb dependency. |
| examples/chat/package-lock.json | Updates lockfile after removing capnweb dependency. |
Files not reviewed (1)
- examples/chat/package-lock.json: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+59
to
+66
| const dir = fs.mkdtempSync(path.join(os.tmpdir(), "typegres-pack-")); | ||
| const { stdout } = await execFileP( | ||
| "npm", | ||
| ["pack", "--pack-destination", dir, "--silent"], | ||
| { cwd: REPO_ROOT }, | ||
| ); | ||
| return path.join(dir, stdout.trim().split("\n").pop()!); | ||
| })(); |
`capnweb` was a runtime dependency with a `file:packages/capnweb` specifier, while `files: ["dist"]` meant `packages/` never shipped. npm resolves that by creating node_modules/capnweb as a symlink to a path that doesn't exist inside the installed package, so `npm install typegres` exits 0 and `import "typegres/capnweb"` then dies with ERR_MODULE_NOT_FOUND. The one feature the README lists as shipped, and the foundation of examples/chat, did not work for any consumer. capnweb is now bundled into the entry point. It can't be an ordinary dependency until cloudflare/capnweb#162 lands: the shim needs five commits that aren't in the published 0.6.1 (closure serialization, synchronous replay, zero-arg closures, getLocalTarget).
ryanrasti
force-pushed
the
capnweb-bundled
branch
from
August 6, 2026 20:37
47fbe93 to
c605340
Compare
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.
No description provided.