-
Notifications
You must be signed in to change notification settings - Fork 30
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
npm modules are loaded from wrong path #17
Comments
Hmm, but this would require us to parse package.json and it would be the same as #16. We could extend the current behaviour to better match http://nodejs.org/api/modules.html#modules_file_modules by trying out different matches (index.js, index.json etc.). In this sense But to load In short: I don't think we can resolve |
Yes, I think you're right. We could work around this issue by looking for However, the current behavior is for Perhaps we should disable support for |
@jamesshore there are use-cases for the current behaviour, it is part of the spec and I'm using it in my projects (I think some other Karma tests depend on this as well). The use-case is very simple - you want to test your project written CommonJS-style where there is a bunch of files. So we definitively shouldn't disable this. The problem with require("foo/bar") is that we don't know if bar is a file or a folder (module) with index.js / file specified in package.json and we need to try-out all the possibilities. For now what we can easily make sure that we test "foo/bar/index.js" in response to require("foo/bar"). The current behaviour isn't buggy, it is incomplete. But even in this incomplete form is still very useful so IMO we shouldn't be taking anything out, we should just be adding things toward full node.js module loading spec, if this is makes sense in a browser context of course. |
@pkozlowski-opensource I'll defer to you on this one. I don't use npm modules with my client-side code, so this doesn't come up for me. Sorry for my ignorance. :-) |
@jamesshore I'm in the exactly the same situation, I'm using CJS module for browser code but not to load npm modules as-they-are. I mean, I'm loading my own code written CJS-style but not existing npm ones. I think we can improve current support for the node module loading spec, it is just that this is not my use-case so wasn't digging into this too much. Certain things are easy to do but other are more involved (parsing all the package.json for example). |
Going to close this one as it is exactly the same issue as in #16 . Looking at the lodash repository we can see that the built version is stored in the The |
@abbakym you are right, I've meant to close this one as duplicate of #16, thnx for the heads up! |
As @abbakym mentioned in #16:
This makes npm modules pretty much impossible to use with karma-commonjs.
The text was updated successfully, but these errors were encountered: