corymsmith / react-native-icons

Quick and easy icons in React Native
MIT License
1.14k stars 141 forks source link

Requiring internal react-native modules will stop working #59

Closed amasad closed 9 years ago

amasad commented 9 years ago

react-native uses a module format that is specific to Facebook that relies on a global namespace. We're trying to isolate it from the outside world and use the standard CommonJS and node modules instead. Therefore in the latest react-native version 0.7.0-rc.2 requiring any of the internal modules using their name will be warning and in the future will be an error.

For example require('NativeModules') is now a warning:

Unable to resolve module NativeModules from [project_path]/node_modules/react-native-icons/FAKIconImage.ios.js

To depend on NativeModules please use the exported react-native node module:

require('react-native').NativeModules

This issue was originally reported here: https://github.com/facebook/react-native/issues/1808

mnylen commented 9 years ago

It seems that the 0.7's updated packager also completely changes how requires should be done.

I started some of this work at https://github.com/mnylen/react-native-icons/tree/0.7-support . Hopefully it helps a bit.

amasad commented 9 years ago

Yes, good catch. We actually never intended that our non-standard internal module system leak out into the community. It works ok for the company but won't work in the wild; mainly because it's single global namespace. Going forward we want to use node modules standard.

jeffreywescott commented 9 years ago

Why is this closed? AFAICT, this is still a problem in the code:

FAKIconImage.ios.js:

var EdgeInsetsPropType = require('EdgeInsetsPropType');
var NativeMethodsMixin = require('NativeMethodsMixin');
var NativeModules = require('NativeModules');
var PropTypes = require('ReactPropTypes');
var ImageResizeMode = require('ImageResizeMode');
var ImageStylePropTypes = require('ImageStylePropTypes');
var React = require('React');
var ReactNativeViewAttributes = require('ReactNativeViewAttributes');
var StyleSheet = require('StyleSheet');
var StyleSheetPropType = require('StyleSheetPropType');

Am I missing something?

corymsmith commented 9 years ago

@jeffreywescott Some of them were fixed and I had closed it incorrectly. Will re-open now. Some of the modules aren't exposed so will have to sort out what to do with those. If you have any thoughts or want to do a PR let me know.

jeffreywescott commented 9 years ago

See: #71. It's not perfect, but at least things are running in my project on react-native 0.8.0.