diff --git a/ActiveState.js b/ActiveState.js new file mode 100644 index 0000000000..368aba46a0 --- /dev/null +++ b/ActiveState.js @@ -0,0 +1 @@ +module.exports = require('./modules/mixins/ActiveState'); diff --git a/AsyncState.js b/AsyncState.js new file mode 100644 index 0000000000..f9da5df8d4 --- /dev/null +++ b/AsyncState.js @@ -0,0 +1 @@ +module.exports = require('./modules/mixins/AsyncState'); diff --git a/Link.js b/Link.js new file mode 100644 index 0000000000..83c95da09b --- /dev/null +++ b/Link.js @@ -0,0 +1 @@ +module.exports = require('./modules/components/Link'); diff --git a/Route.js b/Route.js new file mode 100644 index 0000000000..293d957845 --- /dev/null +++ b/Route.js @@ -0,0 +1 @@ +module.exports = require('./modules/components/Route'); diff --git a/Routes.js b/Routes.js new file mode 100644 index 0000000000..0d3405dfd8 --- /dev/null +++ b/Routes.js @@ -0,0 +1 @@ +module.exports = require('./modules/components/Routes'); diff --git a/docs/api/README.md b/docs/api/README.md index ccd09ed681..004c2a659c 100644 --- a/docs/api/README.md +++ b/docs/api/README.md @@ -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.) + diff --git a/docs/api/mixins/ActiveState.md b/docs/api/mixins/ActiveState.md index a004104ff0..f251bd3554 100644 --- a/docs/api/mixins/ActiveState.md +++ b/docs/api/mixins/ActiveState.md @@ -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 }; diff --git a/docs/guides/overview.md b/docs/guides/overview.md index affbfa18fe..d25a3568d8 100644 --- a/docs/guides/overview.md +++ b/docs/guides/overview.md @@ -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(( @@ -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() { diff --git a/examples/animations/app.js b/examples/animations/app.js index 874376e1be..031ec7121f 100644 --- a/examples/animations/app.js +++ b/examples/animations/app.js @@ -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; diff --git a/examples/auth-flow/app.js b/examples/auth-flow/app.js index d08dd71fcd..17d898cdd4 100644 --- a/examples/auth-flow/app.js +++ b/examples/auth-flow/app.js @@ -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; diff --git a/examples/data-flow/app.js b/examples/data-flow/app.js index 158163eb7d..26343d4783 100644 --- a/examples/data-flow/app.js +++ b/examples/data-flow/app.js @@ -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; diff --git a/examples/dynamic-segments/app.js b/examples/dynamic-segments/app.js index d16a33bedd..36495dd5c4 100644 --- a/examples/dynamic-segments/app.js +++ b/examples/dynamic-segments/app.js @@ -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; diff --git a/examples/master-detail/app.js b/examples/master-detail/app.js index 1b2faec86e..46ba1c4d75 100644 --- a/examples/master-detail/app.js +++ b/examples/master-detail/app.js @@ -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; diff --git a/examples/partial-app-loading/app.js b/examples/partial-app-loading/app.js index 38bbeb08fd..26e38b01bf 100644 --- a/examples/partial-app-loading/app.js +++ b/examples/partial-app-loading/app.js @@ -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; diff --git a/examples/partial-app-loading/dashboard.js b/examples/partial-app-loading/dashboard.js index f910cd6ea5..efbc6ffbd2 100644 --- a/examples/partial-app-loading/dashboard.js +++ b/examples/partial-app-loading/dashboard.js @@ -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({ diff --git a/examples/query-params/app.js b/examples/query-params/app.js index 8ace6037d0..4011ef7ec1 100644 --- a/examples/query-params/app.js +++ b/examples/query-params/app.js @@ -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; diff --git a/examples/shared-root/app.js b/examples/shared-root/app.js index 05c6ba3f8a..afe0a9bd4d 100644 --- a/examples/shared-root/app.js +++ b/examples/shared-root/app.js @@ -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; diff --git a/examples/simple-master-detail/app.js b/examples/simple-master-detail/app.js index 6b57314e40..08b20b53bf 100644 --- a/examples/simple-master-detail/app.js +++ b/examples/simple-master-detail/app.js @@ -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; diff --git a/examples/transitions/app.js b/examples/transitions/app.js index 574fb8678e..315dfe3c45 100644 --- a/examples/transitions/app.js +++ b/examples/transitions/app.js @@ -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; diff --git a/goBack.js b/goBack.js new file mode 100644 index 0000000000..29dcf19584 --- /dev/null +++ b/goBack.js @@ -0,0 +1 @@ +module.exports = require('./modules/helpers/goBack'); diff --git a/index.js b/index.js new file mode 100644 index 0000000000..d2ccce8e4c --- /dev/null +++ b/index.js @@ -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'); diff --git a/modules/main.js b/modules/main.js deleted file mode 100644 index e5421c7371..0000000000 --- a/modules/main.js +++ /dev/null @@ -1,14 +0,0 @@ -exports.Link = require('./components/Link'); -exports.Route = require('./components/Route'); -exports.Routes = require('./components/Routes'); - -exports.goBack = require('./helpers/goBack'); -exports.replaceWith = require('./helpers/replaceWith'); -exports.transitionTo = require('./helpers/transitionTo'); - -exports.ActiveState = require('./mixins/ActiveState'); -exports.AsyncState = require('./mixins/AsyncState'); - -// Backwards compat with 0.1. We should -// remove this when we ship 1.0. -exports.Router = require('./Router'); diff --git a/package.json b/package.json index 8a6c64338d..c450c4b2cd 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "react", "router" ], - "main": "modules/main", + "main": "./index", "repository": { "type": "git", "url": "https://github.com/rackt/react-router.git" diff --git a/replaceWith.js b/replaceWith.js new file mode 100644 index 0000000000..b68cd041a5 --- /dev/null +++ b/replaceWith.js @@ -0,0 +1 @@ +module.exports = require('./modules/helpers/replaceWith'); diff --git a/script/build b/script/build index 77437c13d8..ae0d71c513 100755 --- a/script/build +++ b/script/build @@ -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 diff --git a/transitionTo.js b/transitionTo.js new file mode 100644 index 0000000000..899b2e7efc --- /dev/null +++ b/transitionTo.js @@ -0,0 +1 @@ +module.exports = require('./modules/helpers/transitionTo');