Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 14, 2025

closes: #12193

Description

Patches @endo/bundle-source to automatically retry with esbuild minimization when bundles exceed 500KB, preventing RPC node max_body_bytes rejections until bundle chunking is available.

Patch implementation (.yarn/patches/@endo-bundle-source-npm-4.1.2-*.patch):

  • Adds byteLimit option (default 500KB) and esbuildPath option
  • On overflow, invokes esbuild --bundle --minify-whitespace and re-bundles the output
  • Creates temporary package.json if needed for esbuild's module resolution

Prevent esbuild from bundling imports (~20 files):

  • Pattern: const mod = '@pkg/name'; await import(mod) prevents esbuild from inlining
  • Applied to: deploy scripts, test utilities, and dynamic imports that must remain external

Kernel bundle exemption:

  • Set byteLimit: Infinity in SwingSet bundling paths (kernel bundles don't transit RPC)

Test fidelity:

  • fakeVatAdmin.registerBundle() now generates bundleIDs containing the bundle hash
  • Ensures test bundleIDs match production format for endoZipBase64 bundles

Security Considerations

Introduces esbuild as a dependency for minimization. Only activated when standard Endo bundles exceed 500KB.

Scaling Considerations

Raises effective contract size ceiling without requiring on-chain changes. Bundles under 500KB unchanged; larger bundles trade legibility for deployability.

Documentation Considerations

Transparent to consumers—no API changes required. The intermediate-variable pattern for dynamic imports is self-explanatory.

Testing Considerations

Existing tests pass. Enhanced bundleID generation improves test realism without affecting behavior.

Upgrade Considerations

Temporary workaround removable once bundle chunking ships. No migration needed—byteLimit is optional and backward-compatible.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Patch @endo/bundle-source to esbuild if bundle is too big feat: patch @endo/bundle-source to use esbuild for oversized bundles Nov 14, 2025
Copilot AI requested a review from michaelfig November 14, 2025 16:49
Copilot finished work on behalf of michaelfig November 14, 2025 16:49
@michaelfig
Copy link
Member

Thanks. I've cannibalised the description.

@michaelfig michaelfig closed this Nov 14, 2025
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.

2 participants