-
Notifications
You must be signed in to change notification settings - Fork 190
Add support for Babel 7 + RN 0.57 #477
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
Conversation
…nnotations - use file names instead
e9202cc to
72a0101
Compare
72a0101 to
4745777
Compare
… removed global __REACT_HOT_LOADER__
|
fyi, I've been trying this along with using RN0.57.0 against our code which is a lerna based monorepo. So far, it has been a mostly good experience - thanks!
as opposed to your original: I'm not suggesting this is a necessary change, because I am not at all familiar with this code - I'm just pointing out what I needed to do in order to restore my dev behavior for the codebase I am currently working on. If it's not correct, then it might be a helpful clue. Please let me know if I can provide any more information. (also, in terms of my testing: So far I have only been working with android on windows, I will try iOS tomorrow.) |
|
Expanding on what @greg-dove said above -- other than // Remove react-hot-patch as it causes issues with bundling
config.entry = config.entry.filter((entry) => {
return !entry.includes('hot/patch.js');
}); // Remove the react-hot-loader config since we don't use it and it causes runtime issues
config.module.rules.forEach((rule) => {
if (Array.isArray(rule.use)) {
rule.use.forEach((use) => {
if (use.options && use.options.plugins && Array.isArray(use.options.plugins)) {
use.options.plugins = use.options.plugins.filter((plugin) => { return !plugin.includes('react-hot-loader') });
}
});
}
}); |
zamotany
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to approve this, since it's looking really good, but before we merge the following needs to be addressed:
- HMR issue (see my and @greg-dove comments)
- HasteResolver changes (see @acoates-ms comment)
That being said, thank you @hedgepigdaniel for your contribution, we really appreciate your effort and we're looking forward to merge this PR 😉 👍 💪
hot/patch.js
Outdated
| if (module.hot && process.env.NODE_ENV !== 'production') { | ||
| require('../src/hot/client/hotPatch'); | ||
| } | ||
| require('react-hot-loader/patch'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As @greg-dove said, we need to disable proxy creation, otherwise HMR won't persist the state:
require('react-hot-loader/patch').default.disableProxyCreation = true;|
Great job everyone involved! ❤️ |
I've been testing this with React Native 0.57, Babel 7 stable, and Android. I'm not sure if it works with RN 0.56 and the corresponding Babel 7 beta, or on iOS.
Changes
babel-preset-react-nativewithmetro-react-native-babel-presetreact-nativeto^0.57babelPlugin.jsto account for the changed API of@babel/template@providesModuleannotations in globally importable libs. Instead it includes all libraries in theLibrariesdirectory and assumes that their file names are the name that should be imported. Not sure what is wrong with normal relative imports...react-native0.57.1react-hot-loaderto v4, and remove the additional monkey patching ofReact.createElementand co. HMR seems to work fine without it and the monkey patching no longer works on v4. For me it did not previously work with the extra monkey patching +react-native-maps, now it does, even though there is a scary error.react-hot-loader/patchto entry points instead of patching it into the user's entry file with the babel plugin.