Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure InitializeCore is run before app code #4814

Merged
2 commits merged into from
May 7, 2020
Merged

Conversation

acoates-ms
Copy link
Contributor

@acoates-ms acoates-ms commented May 6, 2020

Fixes #4779

The reason fast refresh wasn't working is that fast refresh requires a custom implementation of require to be used within the bundle. That implementation of require expects a custom property 'Refresh' to be set on it. That variable is set by 'setupReactRefresh', which is one of the things that InitializeCore does.

The solution to allow metro to work on all platforms at once caused the default config of metro to not run InitializeCore before other modules.

This happened because the default react-native config of metro uses a full path to react-native's InitializeCore to tell metro to require that module before the main entry file of the apps. Metro silently ignores paths in getModulesRunBeforeMainModule that are not part of the bundle. Since we use InitializeCore from react-native-windows, the module specified in getModulesRunBeforeMainModule was just ignored.

The change here adds the path to InitializeCore from react-native, react-native-windows and react-native-macos to the config. That way which ever of those modules ends up in the bundle will be required before the apps main entry file.

All of this custom metro config will be replaced by react-native-community/cli#1115 which will fix the defaults in the CLI. (But hopefully we can work through all these kinds of issues before we get that merged)

Microsoft Reviewers: Open in CodeFlow

@acoates-ms acoates-ms requested a review from a team as a code owner May 6, 2020 21:42
@acoates-ms acoates-ms added Backport to 0.62 AutoMerge Causes a PR to be automatically merged once all requirements are passed (label drives bot activity) labels May 6, 2020
@ghost
Copy link

ghost commented May 6, 2020

Hello @acoates-ms!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

Do note that I've been instructed to only help merge pull requests of this repository that have been opened for at least 10 hours, a condition that will be fulfilled in about 8 hours 52 minutes. No worries though, I will be back when the time is right! 😉

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit 6088cb0 into microsoft:master May 7, 2020
NickGerleman pushed a commit to NickGerleman/react-native-windows that referenced this pull request May 7, 2020
* Ensure InitializeCore is run before app code

* Change files
@acoates-ms acoates-ms deleted the fixfast branch May 21, 2020 17:17
@jonthysell jonthysell added the Breaking Change This PR will break existing apps and should be part of the known breaking changes for the release label Jun 9, 2020
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AutoMerge Causes a PR to be automatically merged once all requirements are passed (label drives bot activity) Breaking Change This PR will break existing apps and should be part of the known breaking changes for the release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fast Refresh does not work on RNW 0.62
3 participants