Use babel-plugin-react-native-web #4125
Closed
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.
Fixes necolas/react-native-web#629
Problem: Current support for react-native-web uses a webpack alias. This causes the entirety of react-native-web to be bundled when building for production. Unfortunately, this means that every single module, used or not, will be bundled. This can grow app sizes by upwards of 50KiB without any benefit.
Solution: react-native-web publishes a babel plugin that handles aliasing of
react-native -> react-native-web
and also swaps the import paths so that it doesn't import the entire app, but just the specific modules used. Info at necolas/react-native-web/packages/babel-plugin-react-native-webTest Plan:
yarn create-react-app test
cd test && yarn add react-native-web
import { View } from 'react-native';
toApp.js
and use it in place of anydiv
yarn test
yarn start
yarn build
yarn eject
and repeat steps 4-6NOTE: AppVeyor failure looks like a fluke. Can anyone verify?