reduce really works?" or "Is
splice mutating that array?". Sometimes I have to replay a real case scenario with less code to understand it better. One of those moments when we isolate code blocks and debug them.
What I'm doing in such cases is pretty much the following:
- I open the Chrome's console and start typing code there or if it is something really small I run Node's repl directly in my terminal.
- As a last approach I end up creating a folder locally. I often use create-react-app and my test starts from there. This however takes time. Not much but still.
There should be a better tool.
I started my research by checking tools like Babel CLI and Bublé. Those however are just transpilers. I need something that also bundles my code. Then I moved to Parcel and Rollup which are bundling and behind the scenes also transpiling (in fact I ended up using Rollup). After having the bundle however I want to also run it and see the result. There is Webpack dev-server which does run the code but behind a http server. I can also use Nodemon together with babel-node and achieve almost the same. In most of the cases though this is an overkill. What I need is a Webpack on-demand with a watcher and code runner. No server.
So I built it. It is called Hopa and looks like that:
After installing it with
npm i hopa -g you get a globally available command
hopa. You navigate to a folder and run it. The library shows you the current files and you pick one. Then internally Rollup bundles the file and spawns a node process then runs it. It shows you the result and also watches for changes in the files involved into the bundle. You can close it with
Ctrl+X or pick another file by hitting
Hope you find it useful. If yes share this article and don't forget to give it a like here github.com/krasimir/hopa. 😏