Skip to content

fix(module): preserve namespace markers across import and require - #106

Closed
steipete wants to merge 3 commits into
claude/w142-manifest-basefrom
claude/w142-esmodule-namespace
Closed

steipete wants to merge 3 commits into
claude/w142-manifest-basefrom
claude/w142-esmodule-namespace

Conversation

@steipete

@steipete steipete commented Oct 4, 2026

Copy link
Copy Markdown

Draft: this integration requires the namespace API merged in openclaw/WebKit#1 and the next matching OpenClaw WebKit artifact batch. Keep it unmerged until that engine pin and checksum manifest can advance together. The branch is stacked on the production manifest commit cf636c2f14914b3ba4b319874312d654cc5ea064. The base ref claude/w142-manifest-base mirrors that exact reviewed commit while its canonical integration branch awaits its own native proof. Retarget this stack to the canonical manifest PR when available. The namespace branch’s runtime source and JavaScript tests are byte-identical to the native-proven commit 33a6210ffaa72c10306335c11dc0e6018496fd7c.

Bun's shared namespace prototype made "__esModule" in ns true even for unmarked ESM, causing tsx/Vite to unwrap Zod's default namespace and lose its explicit z export. Use a separate engine namespace facade for require(esm) so imports stay unmarked while requires retain an own enumerable marker and live bindings. Cover require-cache materialization as well as ordinary and extension-mediated require. Preserve explicit CJS markers and module.exports; keep native namespaces forwarded through CJS intact.

Adapts oven-sh/bun#33894, oven-sh/bun#39888, and oven-sh/WebKit#279 by @robobun. Bun's existing behavior of evicting ESM records when require.cache is deleted is preserved.

Native Linux proof with the matching locally built engine:

  • Node 24 marker reflection matches across 10 fixture shapes. Import-first, require-first, cache-first, explicit marker, live-binding, and CJS forwarding controls pass.
  • Both minimal Zod scripts pass, including require after import.
  • 159 focused/plugin tests, all 46 fork-selection rows, 138 JSC configurations, and four continuous-GC controls pass.
  • Real Vite/tsx production builds in grouped and individual-module modes: Node 2/2, old Bun 0/2 with missing zod.z, patched Bun 2/2.
  • Broader resolve/module/VM suites: 1,545 pass; two baseline failures and one release-only internal-test-module error remain documented.
  • Eight measured ABBA samples per arm: warmed reads unchanged; cached require/import within 1%; fresh CJS imports +2.1%, first ESM require +5.9%, reflection +14.4% while exposing the added own property.
  • Isolated Codex review is scoped-clean through P2. The engine PR's hosted native qualification is green.

The committed production manifest continues to identify batch 1 until the coordinator publishes the new engine. No upstream preview pin or download fallback is introduced by this draft.

Adapt oven-sh#33894 and oven-sh#39888 by @robobun. Use the paired WebKit namespace facade API so imports stay unmarked while require(esm) gets an own enumerable marker and live exports. Preserve explicit CJS markers and the Node module.exports namespace entry. Requires the OpenClaw WebKit namespace engine patch; keep this integration in draft until its artifacts are published.
Create the require facade when require.cache materializes an imported ESM module. Keep native namespaces forwarded through CommonJS intact instead of interpreting their synthetic marker as a Babel wrapper. Preserve the existing Bun contract that cache deletion also invalidates ESM records; test marker ownership separately from that cache policy.
steipete added a commit that referenced this pull request Oct 5, 2026
Merge oven-sh/bun through 9bd19c9 and pin the published OpenClaw WebKit 42ab38d705d4838748ccee77e7deb0e4e35515ee manifest. Preserve upstream and fork history, with the credited namespace counterpart from #106 and the original package-scope interop fix from #117.

Keep the fork resolver, module-loader context, CallSite, cache and idle-accounting behavior. Configure fetch TLS once per connection and preserve PostgreSQL/MySQL query isolation through errors. Repair the inherited fetch leak fixture so it awaits its listener, requests and cleanup and checks actual object reclamation; synchronize the TLS renegotiation fixture with a framed client-ready message.

Qualified with direct Linux builds, the fork selection, Node resolver oracle, Linux OpenClaw consumers, TLS before/after controls, both fork CI lanes, and a scoped-clean independent P2 review. No Bun release or tag.
@steipete

steipete commented Oct 5, 2026

Copy link
Copy Markdown
Author

Superseded by #124, merged as 9ecd8d0260b38f71b1a733bdce55c9a6b4a6bd98. The namespace counterpart is retained as a distinct credited prerequisite (a7c2bb616e49193b542081ba74c0fcb7abced15d) and lands atomically with the checksum-pinned OpenClaw WebKit release it requires.

Qualification includes the namespace/package-interop suites, both Vite production-build modes, the Linux consumer matrix, and both fork CI lanes on the final sync head. The original contributor credit and regression coverage are preserved. No Bun release or tag was created.

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