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

Bundler doesn't import index.js if require is on a Directory #72

Closed
boopathi opened this issue Feb 14, 2015 · 4 comments
Closed

Bundler doesn't import index.js if require is on a Directory #72

boopathi opened this issue Feb 14, 2015 · 4 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@boopathi
Copy link
Contributor

- Project
  \ _ Component
       \ _ index.js
  \ _ App.js

App.js is the entry point

// App.js
var Component = require('./Component');

doesn't import index.js automatically. Had to manually specify

// App.js
var Component = require('./Component/index');
@boopathi boopathi changed the title Bundler doesn't look for index.js if require is on a Folder Bundler doesn't import index.js if require is on a Directory Feb 14, 2015
@amasad
Copy link
Contributor

amasad commented Feb 14, 2015

Thanks, we don't implement the full CommonJS spec. We use a different module format, where every module is declared via @providesModule in the docblock, see the example JS code:
https://github.com/facebook/react-native/blob/master/Examples/UIExplorer/SpinnerExample.js#L4

However, I'm aware that this is counter-intuitive for users, because we support part of the spec, namely, packages and relative imports in packages (mainly to be able to use npm modules). Anyways, I'll see if this feature can be safely added, otherwise, will make sure there is an options for users to use CommonJS instead of @providesModule

@nmn
Copy link
Contributor

nmn commented Mar 27, 2015

+1 for normal commonJS instead of the @provides docblock. The node version of commonJS and custom JS build scripts would be the best case scenario.

@amasad
Copy link
Contributor

amasad commented Mar 27, 2015

I actually forgot to close this issue. If lib is a dir with index.js require('./lib') will be the same as require('./lib/index.js').

And you don't have to use @providesModule. There are still differences from node modules and we'll work towards that, but I'm also happy to fix any differences you see in the near term

@amasad amasad closed this as completed Mar 27, 2015
@vjeux
Copy link
Contributor

vjeux commented Mar 27, 2015

Actually, please don't use @providesModule. This is an internal convention that shouldn't be exposed to developers.

harrykiselev pushed a commit to harrykiselev/react-native that referenced this issue Aug 5, 2015
Update docs - rephrase the source code structure
@facebook facebook locked as resolved and limited conversation to collaborators May 29, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 23, 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