Skip to content

Update npm build to put stuff in react-router/lib #154

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

Closed
mjackson opened this issue Jul 31, 2014 · 10 comments
Closed

Update npm build to put stuff in react-router/lib #154

mjackson opened this issue Jul 31, 2014 · 10 comments

Comments

@mjackson
Copy link
Member

I'm a big fan of the way the React project puts all their stuff in react/lib in the npm package. It makes it easy to use pieces of the project without requireing the whole thing.

e.g. instead of

var Link = require('react-router').Link;

I'd like to be able to do

var Link = require('react-router/lib/Link');

Basically everything we now export in main.js should be available to require this way.

@sophiebits
Copy link
Contributor

Might be reasonable to just drop the lib/ too.

@ryanflorence
Copy link
Member

I would love require('react-router/Link') but I would also hate having source files in the project root. npm refuses to help in this regard.

@sophiebits
Copy link
Contributor

You don't have to publish from the project root, right? React has several npm packages corresponding to different directories in the source tree.

@ryanflorence
Copy link
Member

but if you want to use what's on master with npm install rackt/react-router then all your code breaks. I'd like to encourage people to try the latest master seamlessly.

@ryanflorence
Copy link
Member

@mjackson this is my preference, and is how the repository was set up originally :P

@ryanflorence
Copy link
Member

ooh, I think I have a great idea ...

Any modules in the root of the project are "public", anything in modules is "private".

But the source code still lives in modules, we just have a vanity module to expose it at the root.

// react-router/Link.js
module.exports = require('./modules/components/Link');

This way

  • we still get good folder structure for our source code
  • people can install from master
  • people can `require('react-router/Link');
  • its easy to understand which modules in the repo are public, and which are not

@mjackson
Copy link
Member Author

@spicyj 👍

@mjackson
Copy link
Member Author

@rpflorence That sounds like a good plan. I'm 👍

@ryanflorence
Copy link
Member

this is why npm doesn't provide some "modules" config directory. everybody knows what is going on with a package, its just the file system, the end.

/me goes back to figuring out why his ruby module isn't loading in rails

ryanflorence added a commit that referenced this issue Aug 1, 2014
this puts all public modules in the root of the
package to:

- conveniently require them
- easily identify what is public v. private

for example:

```js
// instead of doing this
var Router = require('react-router');
var Link = Router.Link;

// or this
var Link = require('react-router/modules/Link');

// you can now do this
var Link = require('react-router/Link');
```

closes #154
@ryanflorence
Copy link
Member

closing, follow #156

jakobz pushed a commit to jakobz/react-router that referenced this issue Aug 7, 2014
this puts all public modules in the root of the
package to:

- conveniently require them
- easily identify what is public v. private

for example:

```js
// instead of doing this
var Router = require('react-router');
var Link = Router.Link;

// or this
var Link = require('react-router/modules/Link');

// you can now do this
var Link = require('react-router/Link');
```

closes remix-run#154
@lock lock bot locked as resolved and limited conversation to collaborators Jan 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants