fwouts / bazel-javascript

JavaScript and TypeScript rules for Bazel (React friendly)
MIT License
65 stars 17 forks source link

Does hot reloading push? #45

Open shmish111 opened 5 years ago

shmish111 commented 5 years ago

I don't quite understand how you do hot reloading. When I use webpack with purescript and I change my code, webpack will recompile the code and then push the changes over a websocket to page I have open. If you use ibazel surely this is not possible? Wouldn't it restart the server every time?

Or do you have 2 processes running at the same time (in 2 terminals), ibazel to recompile the code and then a webpack sever that watches the result of that?

fwouts commented 5 years ago

Hi David, the key mechanism is a special tag added here which ensures that the webpack dev server does not get killed. Instead it watches the transpiled directory (see this script, sorry it's a bit hard to follow!).

There are indeed two processes running at the same time, but in a single terminal as ibazel takes care of them:

Does that somewhat make sense?

shmish111 commented 5 years ago

oh, the tags, cool thanks

shmish111 commented 5 years ago

Does this in theory work with any other rule that produces javascript? Is there a type of provider that my rule would need to use to work with this? At the moment my fork of rules_purescript produces many javascript files but it could be bundled into a single file using another layer of bundling which would produce a single javascript file to provide to your bundler. Would this make sense? Can your bundler already deal with a rule that produces many javascript files?

I tried to use rules_rollup but it seemed it couldn't handle my results.

fwouts commented 5 years ago

That's a good question. These rules weren't designed with this kind of usage in mind, but we might be able to tweak it to allow that. I think @enriched had some ideas about this too.

It'd be helpful if you had a very small example with rules_rollup that we could debug from.