Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better handling of root or a core_modules for unqualified requires. #106

Open
AshHeskes opened this issue Nov 29, 2014 · 0 comments
Open

Comments

@AshHeskes
Copy link

AshHeskes commented Nov 29, 2014

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. 

Where app.js would look like

var backbone       = require ( 'backbone' ),
    foo_model      = require ( './models/foo-model' ),
    foo_controller = require ( './controllers/foo-controller' );

module. exports = function (  ) { // do stuff maybe..... };

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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant