Skip to content

Commit

Permalink
[changed] location of public modules
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ryanflorence committed Aug 1, 2014
1 parent a597441 commit 154afba
Show file tree
Hide file tree
Showing 26 changed files with 46 additions and 33 deletions.
1 change: 1 addition & 0 deletions ActiveState.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./modules/mixins/ActiveState');
1 change: 1 addition & 0 deletions AsyncState.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./modules/mixins/AsyncState');
1 change: 1 addition & 0 deletions Link.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./modules/components/Link');
1 change: 1 addition & 0 deletions Route.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./modules/components/Route');
1 change: 1 addition & 0 deletions Routes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./modules/components/Routes');
11 changes: 11 additions & 0 deletions docs/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,14 @@ React Router API
- [`ActiveState`](/docs/api/mixins/ActiveState.md)
- [`AsyncState`](/docs/api/mixins/AsyncState.md)


Public Modules
--------------

All modules found at the repository root are considered public. You can
require them conveniently with `var Route = require('react-router/Route');` etc.

Note that we do not support requiring modules from our `modules`
directory. (No notes in the changelog, no changes to the versioning of
the lib, etc.)

6 changes: 3 additions & 3 deletions docs/api/mixins/ActiveState.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ Let's say you are using bootstrap and want to get `active` on those `li`
tags for the Tabs:

```js
var Router = require('react-router');
var Link = Router.Link;
var Link = require('react-router/Link');
var ActiveState = require('react-router/ActiveState');

var Tab = React.createClass({

mixins: [ Router.ActiveState ],
mixins: [ ActiveState ],

getInitialState: function () {
return { isActive: false };
Expand Down
6 changes: 3 additions & 3 deletions docs/guides/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ Guide: Overview
===============

```
var Routes = require('react-router').Routes;
var Route = require('react-router').Route;
var Routes = require('react-router/Routes');
var Route = require('react-router/Route');
React.renderComponent((
<Routes>
Expand Down Expand Up @@ -50,7 +50,7 @@ will render the active child route handler.
Here's the rest of the application:

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

var App = React.createClass({
render: function() {
Expand Down
2 changes: 1 addition & 1 deletion examples/animations/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @jsx React.DOM */
var React = require('react');
var Router = require('../../modules/main');
var Router = require('../../index');
var Routes = Router.Routes;
var Route = Router.Route;
var Link = Router.Link;
Expand Down
2 changes: 1 addition & 1 deletion examples/auth-flow/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @jsx React.DOM */
var React = require('react');
var Router = require('../../modules/main');
var Router = require('../../index');
var Route = Router.Route;
var Routes = Router.Routes;
var Link = Router.Link;
Expand Down
2 changes: 1 addition & 1 deletion examples/data-flow/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @jsx React.DOM */
var React = require('react');
var Router = require('../../modules/main');
var Router = require('../../index');
var Route = Router.Route;
var Routes = Router.Routes;
var Link = Router.Link;
Expand Down
2 changes: 1 addition & 1 deletion examples/dynamic-segments/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @jsx React.DOM */
var React = require('react');
var Router = require('../../modules/main');
var Router = require('../../index');
var Route = Router.Route;
var Routes = Router.Routes;
var Link = Router.Link;
Expand Down
2 changes: 1 addition & 1 deletion examples/master-detail/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @jsx React.DOM */
var React = require('react');
var Router = require('../../modules/main');
var Router = require('../../index');
var Route = Router.Route;
var Routes = Router.Routes;
var Link = Router.Link;
Expand Down
2 changes: 1 addition & 1 deletion examples/partial-app-loading/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @jsx React.DOM */
var React = require('react');
var Router = require('../../modules/main');
var Router = require('../../index');
var Route = Router.Route;
var Routes = Router.Routes;
var Link = Router.Link;
Expand Down
2 changes: 1 addition & 1 deletion examples/partial-app-loading/dashboard.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @jsx React.DOM */

var React = require('react');
var ReactRouter = require('../../modules/main');
var ReactRouter = require('../../index');
var Link = ReactRouter.Link;

var Dashboard = React.createClass({
Expand Down
2 changes: 1 addition & 1 deletion examples/query-params/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @jsx React.DOM */
var React = require('react');
var Router = require('../../modules/main');
var Router = require('../../index');
var Route = Router.Route;
var Routes = Router.Routes;
var Link = Router.Link;
Expand Down
2 changes: 1 addition & 1 deletion examples/shared-root/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @jsx React.DOM */
var React = require('react');
var Router = require('../../modules/main');
var Router = require('../../index');
var Route = Router.Route;
var Routes = Router.Routes;
var Link = Router.Link;
Expand Down
2 changes: 1 addition & 1 deletion examples/simple-master-detail/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @jsx React.DOM */
var React = require('react');
var Router = require('../../modules/main');
var Router = require('../../index');
var Route = Router.Route;
var Routes = Router.Routes;
var Link = Router.Link;
Expand Down
2 changes: 1 addition & 1 deletion examples/transitions/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @jsx React.DOM */
var React = require('react');
var Router = require('../../modules/main');
var Router = require('../../index');
var Route = Router.Route;
var Routes = Router.Routes;
var Link = Router.Link;
Expand Down
1 change: 1 addition & 0 deletions goBack.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./modules/helpers/goBack');
8 changes: 8 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
exports.ActiveState = require('./ActiveState');
exports.AsyncState = require('./AsyncState');
exports.Link = require('./Link');
exports.Route = require('./Route');
exports.Routes = require('./Routes');
exports.goBack = require('./goBack');
exports.replaceWith = require('./replaceWith');
exports.transitionTo = require('./transitionTo');
14 changes: 0 additions & 14 deletions modules/main.js

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"react",
"router"
],
"main": "modules/main",
"main": "./index",
"repository": {
"type": "git",
"url": "https://github.com/rackt/react-router.git"
Expand Down
1 change: 1 addition & 0 deletions replaceWith.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./modules/helpers/replaceWith');
2 changes: 1 addition & 1 deletion script/build
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
mkdir -p dist
NODE_ENV=production node_modules/.bin/browserify modules/main.js -t browserify-shim -t envify --detect-globals false -s ReactRouter > dist/react-router.js
NODE_ENV=production node_modules/.bin/browserify index.js -t browserify-shim -t envify --detect-globals false -s ReactRouter > dist/react-router.js
node_modules/.bin/uglifyjs dist/react-router.js --compress warnings=false > dist/react-router.min.js
1 change: 1 addition & 0 deletions transitionTo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./modules/helpers/transitionTo');

0 comments on commit 154afba

Please sign in to comment.