Skip to content

fix(module): preserve package interop in async CJS imports - #117

Merged
steipete merged 1 commit into
mainfrom
claude/fix-cjs-package-scope-interop
Oct 5, 2026
Merged

steipete merged 1 commit into
mainfrom
claude/fix-cjs-package-scope-interop

Conversation

@steipete

@steipete steipete commented Oct 5, 2026 •

Copy link
Copy Markdown

Async imports of .cjs files inside a "type": "module" package lose the package's CommonJS interop behavior: exports.default is unwrapped and __esModule disappears from the namespace. The async transpiler used the extension-derived parser hint as the package-context tag.

Carry the parser hint separately and derive the interop tag from the already-resolved package metadata. This preserves CommonJS parsing while matching the synchronous loader's package handling, including cache hits. Adapts the focused parser/tag separation from oven-sh/bun#40940; thanks @robobun.

Node 24 passes the exact fixture. Existing native Windows baseline fails three annotation assertions; the added regression also protects plain .cjs top-level this. P2 review is scoped-clean, all 12 Rust target checks pass without skips on the integration, and scoped formatting passes.

Native Windows Server 2022 x64 proof used matched source and verified binaries: the resolver runner improved from 37/42 test files passing on fork main d2d2a26ef973cdd97b37953f5dba58052acad74f to 42/42 passing, with both dependency-install steps also successful. The passing executable was built from local integration 03aa23b6adea8e12235339d8650cae41fa1ea80d (tree 1c5084c96b361801cd9f595795774ec41e81e250), combining four independent fixes. This branch's production and test files are byte-identical in that integration. Executable SHA-256: cbd65560d2f8651dc82722d1d957803651e2803f0a1a66ae039b946d3b53b156.

OpenClaw consumer before/after qualification remains pending.

Exact-head fork CI passes both required lanes: Linux x64 (15/15 selected and compatibility test files) and macOS arm64 (12/12); both dependency-install steps also pass in each lane. Native Windows proof is recorded above because this PR workflow has no Windows test lane.

Broader native Windows qualification also passes: 29/29 selected compatibility test files and 2/2 dependency-install steps (31/31 runner rows), exit zero, no timeout, in 162.284 seconds. This uses runtime integration c4cb855cda5787bb55f185bd4cbd3a33a2f0cc79 (executable SHA-256 b4073b6e8a59bf3365f1b6b5df954c767615a3317feca68067616750fb0fac8d) and the three exact process/TLS test-file blobs from harness commit 81c8c5a2a5b5ab69eae1785dac8297717c5b2471, with BUN_TEST_NODE_VERSION=v24.21.0. Test-file bytes were verified before and after the run. This combined integration proof is separate from each PR’s individual CI and from OpenClaw consumer qualification.

Keep the parser format hint separate from the package-scope source tag. Adapts oven-sh#40940 for the async runtime loader.
@steipete
steipete merged commit 1f976ed into main Oct 5, 2026
11 of 13 checks passed
@steipete
steipete deleted the claude/fix-cjs-package-scope-interop branch October 5, 2026 08:37
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.
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