0.7.3 • Published 6 years ago

babel-plugin-react-native-web-commonjs v0.7.3

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

Workaround for lerna + yarn workspaces react-native-web/issues/982

babel-plugin-react-native-web

npm version PRs Welcome

A Babel plugin that will alias react-native to react-native-web and exclude any modules not required by your app (keeping bundle size down).

Installation

yarn add --dev babel-plugin-react-native-web-cjs

Usage

.babelrc

{
  "plugins": ["react-native-web-cjs"]
}

Example

NOTE: react-native-web internal paths are not stable and you must not rely on them. Always use the Babel plugin to optimize your build. What follows is an example of the rewrite performed by the plugin.

Before

import { StyleSheet, View } from 'react-native';

After

import StyleSheet from 'react-native-web/dist/exports/StyleSheet';
import View from 'react-native-web/dist/exports/View';