speedskater / babel-plugin-rewire

A babel plugin adding the ability to rewire module dependencies. This enables to mock modules for testing purposes.
843 stars 90 forks source link

Add failing test case for rewiring an unused dependency: it should not throw #177

Open stuartsan opened 7 years ago

stuartsan commented 7 years ago

Going back to this comment: https://github.com/speedskater/babel-plugin-rewire/issues/109#issuecomment-202531181

@joshnuss You are right, rewiring a dependency which is not used or does not exist causes an error at the moment. I think we should be able to ignore such cases, as rewiring not existing dependencies won't change anything. @TheSavior what do you think? Anyway @joshnuss could you please create a PR for a failing usage test? -- @speedskater

I'm running into this problem too, I'd like to be able to rewire something that hasn't been used yet without it exploding.

This PR adds a failing test case for the described use case, AFAICT this doesn't yet exist anywhere. If there's anything else I can provide please LMK. Happy to take a crack at a PR to fix as well if that would be useful.

stuartsan commented 7 years ago

I can also add a case for not throwing when something does not exist, LMK.

speedskater commented 7 years ago

@stuartsan thank your for your effort and your offer of helping out with a fix. This would actually be great, as i won't be able to work on it before mid/end of march. Thank you and sorry for the inconvenience. If you want to discuss this issue we can make a skype session.

speedskater commented 7 years ago

@stuartsan. Thanks for providing the test. I just had a look at your test. And its not as easy to fix, as we need to know in advance, whether we rewired the module at all. This is the same issue as regarding wildcard in/exports. We therefore decided to tackle all this in a new 2.0.0 branch. We also merged your test into this new branch, and will let you know as soon this is finished.

stuartsan commented 7 years ago

Hey @speedskater , thanks! Apologies, I dropped the ball, meant to respond here. I had intended to try and fix this myself but poking around in the code I realized it was a major change as well and I was in a bit over my head. Thanks for the update and for all your work on this super valuable plugin, much appreciated.