bower/bower.json-spec — pull request #9 by josh (2013-11-12 15:18:47+00:00)
Title: paths Proposal

The one line pitch, `paths` are aliases like `main` for subassets.

We've discussed this a bunch of times without putting forward any action. This has been on my wishlist for a while. Its definitely a new "feature" unlike `main` which has actually existed since the beginning.

`main` serves the majority of packages well that offer a simple single entry point into the package. However, theres a class of packages that want to expose many submodules to the user in a nice way. If you care about the ascetics of paths, you are forced to put all your assets at the root of the package. This is not ideal.

I'll use bootstrap as an example from here on.

``` js
{
"main": "styles/bootstrap.less",
"paths": {
"grid.less": "styles/grid.less",
"modals.less": "styles/modals.less",
"modals.js": "js/modals.js",
"scrollspy.js": "js/scrollspy.js",
"icons.eot": "fonts/glyphicons-halflings-regular.eot"
}
}
```

The syntax here is much like RequireJS's `paths` config. However, we need to be clear about file extensions since we aren't just deal with `.js`. Heres how [grunt-bower-requirejs](https://github.com/yeoman/grunt-bower-requirejs) would interpret this config and autogenerate the following.

``` js
requirejs.config({
baseUrl: './',
paths: {
'bootstrap/modals': 'bower_components/bootstrap/js/modals',
'bootstrap/scrollspy': 'bower_components/bootstrap/js/scrollspy'
}
});
```

### Resources

* [josh/rails-behaviors](https://github.com/josh/rails-behaviors) - I'm forced to put all my files at the root here since I actually want nice requires. Otherwise I'd put my files into `lib/` or `src/`.
* [Modernizr](https://github.com/Modernizr/Modernizr) - Most of the optional feature detects are under `feature-detects`. It might be nicer to expose them as `modernizr/geolocation` etc.