feat: allow partial overriding of getModulesRunBeforeMainModule #51820
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:
Part of facebook/metro#1480
This PR introduces a way to override
getModulesRunBeforeMainModulein@react-native/community-cli-plugin. Currently, the plugin completely ignores the existing metro config and hardcodes paths toInitializeCorefrom RN & potential OOT platforms.Due to the nature of this change, it's not possible to bail out of overriding when the config is already present, because most setups already include defaults from
@react-native/metro-configormetro-config.To make this change non-breaking for existing setups, we can iterate over the paths from existing config and only add the current overrides if they are not already present in the config.
While the change does not allow full control over
getModulesRunBeforeMainModule(meaningInitializeCorewill always need to be included), it allows to control the order of startup modules, and allows for prepending something to the list, so that it can execute before theInitializeCoreChangelog:
[GENERAL] [ADDED] - Allow overriding getModulesRunBeforeMainModule in community-cli-plugin
Test Plan:
TBD