Currently if you specify a root it makes all paths relative to it. IMO it would be better if unqualified requires were not made part of the relative entry point path. If the intention is to mimic the node environment node's core modules and anything in node_modules are the only requires that can have unqualified paths.
Since I expected cjs everywhere to use the root option for looking up unqualified requires only, if say for example you're using bower for dependency management I would want to specify my components dir as the source for unqualified requires. However I still want my entry point to be relative to the entry point dir.
for example in my typical directory structure....
+ js
+ components // unqualified requires come from here, just like node_modules.
+ backbone
index.js
+ libs
dummy-lib.js
+ models
foo-model.js
+ controllers
foo-controller.js
+ app.js // all requires outside of `components` need to use relative paths just like node.
currently relative paths in app.js are being converted to be relative to root.
It would be great if cjs-everywhere could be configured this way. I find it a much more flexible approach to using common js in the browser where the package manager is not always npm, yet retains the same require semantics as node.
---
Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/6622579-better-handling-of-root-or-a-core_modules-for-unqualified-requires?utm_campaign=plugin&utm_content=tracker%2F297897&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F297897&utm_medium=issues&utm_source=github).
Currently if you specify a root it makes all paths relative to it. IMO it would be better if unqualified requires were not made part of the relative entry point path. If the intention is to mimic the node environment node's core modules and anything in
node_modules
are the onlyrequires
that can have unqualified paths.Since I expected cjs everywhere to use the
root
option for looking up unqualified requires only, if say for example you're usingbower
for dependency management I would want to specify mycomponents
dir as the source for unqualified requires. However I still want my entry point to be relative to the entry point dir.for example in my typical directory structure....
Where
app.js
would look likecurrently relative paths in
app.js
are being converted to be relative toroot
.It would be great if cjs-everywhere could be configured this way. I find it a much more flexible approach to using common js in the browser where the package manager is not always npm, yet retains the same
require
semantics as node.