Fix metro-runtime's require system getter checks for ESM live bindings#1575
Closed
kitten wants to merge 1 commit into
Closed
Fix metro-runtime's require system getter checks for ESM live bindings#1575kitten wants to merge 1 commit into
metro-runtime's require system getter checks for ESM live bindings#1575kitten wants to merge 1 commit into
Conversation
ba85a86 to
978d484
Compare
Contributor
robhogan
approved these changes
Sep 10, 2025
robhogan
left a comment
Contributor
There was a problem hiding this comment.
Looks good - thanks
There's a small edge case here where a module may export a dangerous getter and be an __esModule, because we allow mixed syntax:
module.exports = {
get danger() {
throw 'problems';
}
};
export default 'spanner';...but I think we can live with that - nobody should be writing it. You might want to disallow hybrid CJS/ESM syntax on your end to be sure.
Contributor
Author
|
Current thinking is to leave it on until we find a library that relies on mixed ESM+CJS that causes this to break 👍 Mostly because we're curious if we need to actively prohibit this |
Contributor
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
In Expo, we're about to introduce ESM live bindings. We noticed that the
metro-runtimeperforms checks for getters to skip over for Fast Refresh checks, likely because of CommonJS modules that may be doingmodule.exports = { get() { throw new Error() } }and the likes.This check is redundant on ESModule-transpiled modules, since we know that getters that were transpiled in for ESM exports are safe to access.
For example, we may have entries such as:
See: expo/expo#39525
Changelog: [Fix] Fix metro-runtime's fast refresh checks to not skip over getters for ES modules
Test plan