ender-js/Ender — Issue #120: Multiple includes with relative require()s
Author: rvagg
Created: 2012-02-09 03:26:21+00:00
State: open

Just recording this while I think of it.

Since people seem to assume that Ender supports `require('./relative')` and can bundle multiple files into a single build, why not support it?

Some package.json adjustments would be required. maybe:

```
"main": [ "dist/module1.js", "dist/module2.js", "dist/module2.js" ]
```

or

```
"ender": {
include: [ "dist/module1.js", "dist/module2.js", "dist/module2.js" ],
bridge: "dist/ender.js"
}
```

If you have multiple includes then it wraps the whole lot with a version of `require()` that can resolve local names but those names aren't available outside of the bundle. e.g. dist/module1.js could call `require('./module2.js')` but you couldn't do the same from another ender package. It could even be made aware of the relative locations of the files so you can `require('../lib/file.js')` from one location and `require('./file.js')` from the same directory as file.js and resolve to the same module depending on what module it was called from -- making it pretty much the same as what people expect from Node.