[RUM-11727] [METRO PLUGIN] Support Metro 0.83+ imports #986
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.
What does this PR do?
Adds support for Metro 0.83+ imports.
Motivation
Internal Metro imports have changed in metro@0.83. Importing internals from
metro/src/..is no longer supported. Internals are now only accessible viametro/private/....We rely on these imports for our custom Metro/Expo Configuration, and we have to address these breaking changes to support Expo SDK 54.
Additional Notes
The changes are retro-compatible
If an import from
metro/private/...fails, it will gracefully fallback to importing frommetro/src/..., to grant compatibility with Metro < 0.83Retrieving the default exports
I have wrapped require statements with a new utility function
getDefaultExport, which returnsimportedModule.defaultifdefaultexists, otherwise it returnsimportedModuledirectly, to support both CommonJS and ESM syntax exports.From the next Metro patch version
0.83.2this will be required to ensure retro-compatibility, as the project is moving towards ESM syntax:Merge Readiness
Review checklist (to be filled by reviewers)