fix: replace Object.assign with Proxy in flattenModule to preserve live bindings#743
Open
pedrotainha wants to merge 2 commits intooriginjs:mainfrom
Open
fix: replace Object.assign with Proxy in flattenModule to preserve live bindings#743pedrotainha wants to merge 2 commits intooriginjs:mainfrom
pedrotainha wants to merge 2 commits intooriginjs:mainfrom
Conversation
…ve bindings Object.assign creates a shallow snapshot that breaks mutable internal state such as React 19 hooks dispatcher (__CLIENT_INTERNALS...H), which is set at render-time and would be null in the snapshot. The Proxy delegates property access to the original module object at access time, preserving live bindings. Fixes originjs#741
This was referenced Mar 23, 2026
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
Object.assign({}, module.default, module)with aProxyinflattenModuleto preserve live mutable bindingsProblem
flattenModuleusesObject.assignto create a shallow snapshot of a shared module's exports. This breaks any mutable internal state that is set after module load time.React 19 stores its hooks dispatcher in
__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE.H, which isnullat load time and only set during render. The snapshot capturesnullpermanently, causing:This affects any React hook when using React Compiler (
babel-plugin-react-compiler) in federated builds.Fix
The
Proxydelegates property access to the original module object at access time (not load time), preserving live bindings.Note: The
originalModulereference is critical — without it,prop in moduleafter reassignment triggers the Proxy's ownhastrap recursively (stack overflow).Test plan
react+react-dombabel-plugin-react-compilerenabledFixes #741