镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

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

Description

@boopathi
- 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');

Activity

  1. 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[/+] on Feb 14, 2015
  2. amasad commented on Feb 14, 2015

    @amasad
    Contributor

    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

  3. nmn commented on Mar 27, 2015

    @nmn
    Contributor

    +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.

  4. amasad commented on Mar 27, 2015

    @amasad
    Contributor

    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

  5. vjeux commented on Mar 27, 2015

    @vjeux
    Contributor

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

  6. locked as resolved and limited conversation to collaborators on May 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions