-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Use babel-plugin-react-native-web #4125
Use babel-plugin-react-native-web #4125
Conversation
You might want to keep the webpack alias in there for people installing node modules, as CRA won't run Babel over everything and can't be configured to so so. |
Can you give an example of this? I don't understand the problem. Sounds like advanced usage in which someone would want to eject. |
CRA doesn't run Babel over node modules. If someone installs a package that imports "react-native" it will throw an error unless the module is passed through Babel, or the webpack alias is in place |
This seems reasonable to me. In the future we plan to compile node modules so we can remove the alias then. Are there any issues with using the alias and this plugin together? |
Ah, didn't think of that case, since I haven't used any external modules that import @iansu the babel plugin works over both |
IIRC, Dan said that wouldn't involve compiling all dependencies |
49ef620
to
6a1d05f
Compare
Webpack 4 has built-in tree shaking rather than relying on uglifyjs which improves code elimination efficiently. I wonder if these extra kb will be shaken when we upgrade. |
Doesn't that require an entire package to be marked as having no side effects? |
This can probably be closed as webpack will now tree-shake the ES modules |
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?