-
Notifications
You must be signed in to change notification settings - Fork 12k
How do I resolve dependencies of 3rd party libs for testing? #1125
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
Comments
Off the top of my head, to resolve dependencies of 3rd party libs you'd need to have SystemJS configured to find them and If you provide me with a repo where this happens, I can try to debug, but from the info here I don't think I can figure it out without digging into it. |
@filipesilva I have it doing that. But the import / require statements aren't finding them. |
Can you give me either a repo or a set of repro steps I can follow where that happens? |
Yeah, all you have to do is:
the error happens on I can't give a repo cause for some reason this is a closed source project, but all the information you need is in the original post, (as well as knowing that the error is triggered by |
Can you make a bare bones repo with the minimum code needed to reproduce the problem? I don't really know any of these libraries, and I can't really say I have time to read up on them to try and figure out how they are installed, configured and used. There's also a lot of configuration that you listed that seems tangential to the problem, so copy pasting those files might end up causing more issues in and of itself. I know it's a bit of a bother but if you don't do it, then it means that I have to do it, and at that point I have to decide if this issue is really worth the time that I could be spending on other, more well defined and reproducible issues. |
kk, I'll post a link here when I get a repo up |
Cheers, and thanks! |
I'm getting a slightly different error now, but here is the repo (and teh diff from a new ng new): NullVoxPopuli/angular-cli-3rdparty-nested-dependency-issue@0d16d31 |
Think I've found the issue. For karma, you were adding files in Note: you were missing I think I was able to configure some of the dependencies:
At this point though, karma warns of other missing dependencies:
So more configuration would be needed. Which is a hassle, as you said, but I kinda don't see how that can be avoided while loading Angular 2 using SystemJS and using stuff that just has a lot of dependencies. Maybe there's some advanced SystemJS-fu of the likes used in JSPM that help in this. We are experimenting with webpack, and considering moving to it if it proves to be viable. That could help in this case, I hope. |
How does ember-cli handle this problem? (with ember addons, I've never had to worry about an addon's dependencies)
cool thanks for looking in to my repo! |
I think ember-cli has a mechanism for adding 3rd party libs to the broccoli build as well, and then it bundles them all up into a Is it ok for me to close this issue btw? |
Yeah, this specific issue is at least mostly resolved with an absurd amount of hacks (really just the same one, until I stop getting errors). I'd like to know your opinion on a couple things though, and if they deserve their own issues:
|
I think the CLI should figure them deps out, yes. That's the reason that led us to invest a considerable amount of time in the ongoing webpack experiment. I'm not sure how that could be done with SystemJS+broccoli, but maybe that was just a sign that they don't play that well together in some scenarios. There is discussion about it here #882. The build setups is a more complicated question. You did have to add code that talks about these libs in the SystemJS config and the vendorNpmFiles array - but production builds will bundle everything that is used, and apply tree shaking. So none of those libs ends up in a production build, although your SystemJS config will still talk about them. But I do believe the question of environments is a bit more complicated than that:
At the moment the CLI implements a mix of both. If you do |
ok, cool. thanks for explaining the build environment stuff. re: SystemJS + Broccoli, I know ember-cli uses broccoli and babel (just looking through their package.json ), and that works really well, though they are only transpiling ES6 to ES5, and not Typescript to ES5. so... idk. Also, tree shaking is pretty cool. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Env Info
Steps
@angular/http
, but uses axios for async http. An example of how this is done can be seen with ember-cli-mirage. Previously, I tried pretender, but had similar problems with nested dependencies.ng test
Uncaught error: Could not find module 'methods' from 'path/to/xhr-interceptor/index.js'
All I want to do is mock JSON responses from a fake server (one that isn't actually running, but is just scoped to an individual test).
Here are some relevant configuration things I've done:
screenshot of dist/

So, things are getting copied to
dist/vendor
, but becausedist/vendor/xhr-interceptor
has some requirements of things that aren't in its node_module's directory,require
is barfing.Any ideas?
The text was updated successfully, but these errors were encountered: