-
Notifications
You must be signed in to change notification settings - Fork 128
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
browserify 2 support #13
Comments
Everything rewire needs is bundler-independent, so it basically "just" has to be adapted to the new browserify api. But since I'm not using browserify anymore I'm currently not implementing it. |
you prefer webpack, i guess .. (i see you developed an adapter) |
Did you use the browserify plugin? Did it work with browserify 2 as well? Or do you still use browserify 1? Personally I prefer webpack, because it is more flexible. It comes with many loaders (like CoffeeScript, LESS, style, mocha) and supports different styles (commonjs, amd, components). But since browserify 2 a lot has changed, so browserify might be as good as webpack. webpack's documentation is still in progress, but the maintainer @sokra is responding fast so this was not an issue for me. |
I was mentioned... (Just to prove that I'll respond fast 😄) |
👍 |
3 similar comments
👍 |
👍 |
👍 |
Because I really needed something like Rewire for Browserify I went ahead and did the port, so far it's been working out nicely: https://github.com/i-like-robots/rewireify |
👍 |
@i-like-robots Cool! Since I'm not using browserify anymore I'm not too motivated to write a plugin 😉. Your implementation is simple and straight-forward. It doesn't work exactly like rewire, but that's ok for client-side modules. It will be a problem for isomorphic modules that run in node.js and in the browser. That's why I decided to stick straight to the node-rewire API for my webpack plugin. If you're planing to rewrite rewireify to be compatible to the node-rewire API here's some advice: Rewire circumvents the Back in the browserify 1 days I hacked a browserify plugin for rewire. May that's some inspiration (although there were some crazy hacks necessary because browserify didn't provide an useful api). |
@jhnns Thanks for more information, that's really helpful. I put this together extremely quickly as a proof of concept but I plan on working on it to make it more robust. I studied your implementation thoroughly and it was interesting working out how to lever it into Browserify. Unfortunately Browserify does not readily expose a |
Well, you could just take my browserify 1 middleware and adjust it to the new transform api of browserify > 2. All the magic/crazy client-side stuff should still work. You just need to find the browserify-2-equivalents of |
That covers a lot of the things I've been thinking about, glad to see some of this stuff has already been solved! Thanks for digging that out for me. |
Could you make any progress yet? |
👍 |
👍 |
👍 |
1 similar comment
👍 |
Thanks @i-like-robots!! Your rewireify works perfectly! I simply added it to my karma.conf and presto! Thanks again!
|
Yep, it's cool. Just wanted to point out that the implementation differs a bit (see above). |
👍 Ah as you stated, I see that rewire is clearing the require cache each time and returning a fresh instance. This is very important when developing unit tests. Rewireify is really close, but my unit tests are failing using because they are all using the same "required" instance and my mock call counts are not as expected when running multiple tests together. If I run the tests one at a time they run fine. Rewire is exactly what browserify needs, but I don't see any way to clear the require cache in browserify.
I can easily add moduleA as a dependency in Browserify by calling bundler.require('/moduleA.js', {expose: './moduleA.js'). |
👍 |
There's no |
i want browserify support |
Browserify support would be great. Thanks! |
Pretty much interested by this feature to reuse my tests in karma as well 👍 |
👍 |
how about requirejs? |
+1 EDIT: I found https://github.com/i-like-robots/rewireify, which does the job for me. Thanks @i-like-robots ! |
👍 Yes, please. A fully compatible browserify transform would be awesome. |
@mik01aj Please be aware that rewireify doesn't mimic rewire exactly. Code that runs in node might break in the browser. However, if it's working for you, that's just fine 😁 |
Hi, I am working in some isomorphic code with rendrjs and stumble with this issue of using rewirefy with browserify 3 and karma. Any one was able to make this work on karma? By the way, nice job with this module it's seems to work really nice on node. |
+1 |
3 similar comments
+1 |
+1 |
👍 |
👍 I think we need an official browserify support... |
Edit: This would be cool, but I found that webpack actually does the job a bit cleaner. All you have to do is add the few lines to your config file. If you are using Node you'll also need to specify empty modules for fs, etc. This is my config file.
|
+1 |
1 similar comment
👍 |
|
+1 |
9 similar comments
👍 |
+1 |
+1 |
+1 |
+1 |
+1 |
+1 |
+1 |
+1 |
No matter how many +1s, it'll never happen ;) I've seen the +1s for months now... I believe rewirify uses rewire now? |
+1 |
3 similar comments
👍 |
+1 |
+1 |
If anyone wants to have browserify 2 support, let me know.
The text was updated successfully, but these errors were encountered: