Skip to content
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

[Packager] how does react native find ActivityIndicatorIOS when using require('ActivityIndicatorIOS')? #896

Closed
limboy opened this issue Apr 17, 2015 · 7 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@limboy
Copy link

limboy commented Apr 17, 2015

for example, this is the webView.ios.js header

var ActivityIndicatorIOS = require('ActivityIndicatorIOS');
var EdgeInsetsPropType = require('EdgeInsetsPropType');
var React = require('React');
var ReactIOSViewAttributes = require('ReactIOSViewAttributes');
var StyleSheet = require('StyleSheet');
var Text = require('Text');
var View = require('View');

ActivityIndicatorIOS is in Libraries/Components/ActivityIndicatorIOS/ActivityIndicatorIOS.ios.js

while EdgeInsetsPropType is in Libraries/StyleSheet/EdgeInsetsPropType.js

where is the search path setting?


PS: in ListView.js, there is

var React = require('React');

but when is React be installed? package.json doesn't contain it.

@ide
Copy link
Contributor

ide commented Apr 17, 2015

The packager uses two methods to look up modules. The first is based on docblock headers: if you write "@providesModule X" in the first docblock this enables require('X'). The other method is Node's resolution.

To answer your question, you are seeing the first type of module resolution. Grep for @providesModule moduleName and I think you'll find the source of modules you're looking for.

@ide ide closed this as completed Apr 17, 2015
@ide ide reopened this Apr 17, 2015
@limboy
Copy link
Author

limboy commented Apr 17, 2015

that's it! thanks for ur help :)

PS: which module is doing the work?

PPS: ReactClass / ReactChildren doesn't seems in the form of @providesModule X

@brentvatne
Copy link
Collaborator

ping @ide

@ide
Copy link
Contributor

ide commented May 31, 2015

@lzyy what is your question?

@limboy
Copy link
Author

limboy commented May 31, 2015

@ide the question is I didn't find @proviedModels ReactClass under react-native project, so wondering where does it come from. so after dig into the system node_modules dir, finally found the definition. so find my answer.

the second question is how @provideModeuls module declared in comments make it a real module, it seems is the effort of JSTransform, it has --use-provides-module parameter. but when is JSTransform involved?

@brentvatne brentvatne changed the title how does react native find ActivityIndicatorIOS when using require('ActivityIndicatorIOS')? [Packager] how does react native find ActivityIndicatorIOS when using require('ActivityIndicatorIOS')? May 31, 2015
@ide
Copy link
Contributor

ide commented May 31, 2015

When you run the packager and load a bundle, it scans all the files for @providesModule and adds them to the dependency graph:

if (moduleDocBlock.providesModule || moduleDocBlock.provides) {

@ide ide closed this as completed May 31, 2015
@jeffpc1993
Copy link

jeffpc1993 commented Aug 31, 2016

But I can't seem to access
const EdgeInsetsPropType = require('EdgeInsetsPropType ') from a file within node modules folder. This project has react-native as it's dependency.
I instead have to specify full path like
const EdgeInsetsPropType = require('react-native/Libraries/StyleSheet/EdgeInsetsPropType')

@facebook facebook locked as resolved and limited conversation to collaborators May 31, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 22, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

5 participants