JSPM

  • Created
  • Published
  • Downloads 1355689
  • Score
    100M100P100Q193460F
  • License MIT

Babel plugin for React Native for Web

Package Exports

  • babel-plugin-react-native-web
  • babel-plugin-react-native-web/src/moduleMap

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (babel-plugin-react-native-web) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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

Usage

.babelrc

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

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';