Make compatible with webpack (#244)

This commit is contained in:
Satyajit Sahoo 2017-02-09 02:30:58 +05:30 committed by Adam Miskiewicz
parent 752d876994
commit 1247806f9b
9 changed files with 31 additions and 15 deletions

View File

@ -21,7 +21,7 @@
"transform-flow-strip-types", "transform-flow-strip-types",
], ],
}, },
// For publishing to NPM for RN // For publishing to NPM for web
"publish-web": { "publish-web": {
"presets": ["es2015", "stage-1", "react"], "presets": ["es2015", "stage-1", "react"],
"plugins": [ "plugins": [

View File

@ -7,6 +7,7 @@
"react-native-v1": "lib-rn/react-navigation.js", "react-native-v1": "lib-rn/react-navigation.js",
"web": "lib/react-navigation.web.js" "web": "lib/react-navigation.web.js"
}, },
"module": "lib/react-navigation.web.js",
"webpack": "lib/react-navigation.web.js", "webpack": "lib/react-navigation.web.js",
"repository": { "repository": {
"url": "git@github.com:react-community/react-navigation.git", "url": "git@github.com:react-community/react-navigation.git",

11
src/PlatformHelpers.js Normal file
View File

@ -0,0 +1,11 @@
/* @flow */
export const Linking = {
addEventListener: () => {},
removeEventListener: () => {},
getInitialURL: () => Promise.reject('Unsupported platform'),
};
export const BackAndroid = {
addEventListener: () => {},
};

View File

@ -0,0 +1,12 @@
/* @flow */
import {
BackAndroid,
Linking,
} from 'react-native';
export {
BackAndroid,
Linking,
};

View File

@ -1,11 +1,11 @@
/* @flow */ /* @flow */
import React from 'react'; import React from 'react';
import invariant from 'fbjs/lib/invariant';
import { import {
BackAndroid, BackAndroid,
Linking, Linking,
} from 'react-native'; } from './PlatformHelpers';
import invariant from 'fbjs/lib/invariant';
import NavigationActions from './NavigationActions'; import NavigationActions from './NavigationActions';
import addNavigationHelpers from './addNavigationHelpers'; import addNavigationHelpers from './addNavigationHelpers';

View File

@ -7,7 +7,6 @@ module.exports = {
// Core // Core
get createNavigationContainer() { return require('./createNavigationContainer').default; }, get createNavigationContainer() { return require('./createNavigationContainer').default; },
get StateUtils() { return require('./StateUtils').default; }, get StateUtils() { return require('./StateUtils').default; },
get PropTypes() { return require('./PropTypes').default; },
get addNavigationHelpers() { return require('./addNavigationHelpers').default; }, get addNavigationHelpers() { return require('./addNavigationHelpers').default; },
get NavigationActions() { return require('./NavigationActions').default; }, get NavigationActions() { return require('./NavigationActions').default; },

View File

@ -78,9 +78,6 @@ module.exports = {
// https://github.com/facebookincubator/create-react-app/issues/290 // https://github.com/facebookincubator/create-react-app/issues/290
extensions: ['.js', '.json', '.jsx', ''], extensions: ['.js', '.json', '.jsx', ''],
alias: { alias: {
// Support React Native Web
// https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
'react-native': 'react-native-web',
'react-navigation': path.resolve(__dirname, '../../'), 'react-navigation': path.resolve(__dirname, '../../'),
}, },
}, },

View File

@ -81,9 +81,6 @@ module.exports = {
// https://github.com/facebookincubator/create-react-app/issues/290 // https://github.com/facebookincubator/create-react-app/issues/290
extensions: ['.js', '.json', '.jsx', ''], extensions: ['.js', '.json', '.jsx', ''],
alias: { alias: {
// Support React Native Web
// https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
'react-native': 'react-native-web',
'react-navigation': path.resolve(__dirname, '../../'), 'react-navigation': path.resolve(__dirname, '../../'),
}, },
}, },

View File

@ -57,7 +57,6 @@
"react-addons-css-transition-group": "~15.3.2", "react-addons-css-transition-group": "~15.3.2",
"react-dom": "~15.3.2", "react-dom": "~15.3.2",
"react-markdown": "^2.4.2", "react-markdown": "^2.4.2",
"react-native-web": "^0.0.55",
"react-navigation": "^0.0.0", "react-navigation": "^0.0.0",
"slugify": "^1.1.0" "slugify": "^1.1.0"
}, },