JSModuleNamespaceObject: expose __esModule marker as own property - #361
Closed
terry90918 wants to merge 1 commit into
Closed
JSModuleNamespaceObject: expose __esModule marker as own property#361terry90918 wants to merge 1 commit into
terry90918 wants to merge 1 commit into
Conversation
When Bun's require(esm) sets m_hasESModuleMarker on a module namespace
object, the marker was previously surfaced through a custom accessor on
a bespoke prototype. That made ns.__esModule read as true but kept it
invisible to own-property operations (Object.keys, Object.hasOwn,
spread, Object.assign, JSON.stringify), which is what transpiler interop
helpers rely on after cloning the namespace.
Node's require(esm) returns a namespace where __esModule is an own,
enumerable, non-configurable data property, interleaved with the other
exports in code-point order.
This change makes m_hasESModuleMarker == True behave as an own property:
getOwnPropertySlotCommon reports { value: true, writable, enumerable,
configurable: false } directly on this
getOwnPropertyNames inserts __esModule at its sorted position
deleteProperty treats it as non-configurable
put / defineOwnProperty write the TriState directly instead of
routing through Base:: (which previously
relied on a prototype accessor)
With this in place Bun can drop its custom moduleNamespaceObjectStructure
prototype and return to the spec's null prototype.
Author
|
@robobun The automatic Preview Build stopped at the fork-permission gate ( This PR is a patch-identical replay of #279 on current main, intended only to refresh the preview artifact for the companion Bun fix. Thank you. |
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.
Summary
This replays the single-file fix from #279 onto the current
oven-sh/WebKit:mainso Bun can obtain a fresh, compatible preview build.The original #279 preview (
autobuild-preview-pr-279-10b2c963) no longer compiles with current Bun main because the surrounding WebKit API has moved. The patch itself is unchanged: its stable patch ID matches #279 exactly.This pull request is only intended to refresh the preview artifact on top of current main. It carries forward the original author’s implementation and intent; it is not claiming replacement credit for #279.
Change
When Bun sets
m_hasESModuleMarker,JSModuleNamespaceObjectexposes__esModuleas its own enumerable, non-configurable property and includes it in sorted own-property enumeration. This lets the companion Bun change remove the custom namespace prototype and preserve correct ESM namespace re-exports through CommonJS interop helpers.Validation
git diff --check upstream/main...HEADSource/JavaScriptCore/runtime/JSModuleNamespaceObject.cpp(28 additions, 4 deletions).Original implementation: #279
Companion Bun work: supersedes oven-sh/bun#33894