Intro
I wanted a way to play with the pieces of my code to understand better how to put them together.

That’s was a repl is great for. I Got some code to start working off of, here's a link to it from my pals @entria and the link to my final repl code, so you can just look at that instead of reading the whole thing. Kinda like a tl;dr.
Initial thoughts

Monkey patch on eval on original code
Wanted to use Typescript, and that code is JavaScript
Monkey patch on eval to support async/await
Babel, do I need this if using tsc to compile?
Started working on it, fixing type errors first. Found some really great code online in stackoverflow, restructured things a lot and removed several parts. At this point I had it working and decided to add code reloading.
Reloading

It was pretty painless to get code to reload seamlessly, just needed to add decache, an awesome and simple lib that allows require to reload code. Then added fs.watch from node to fire a callback when the file is saved.

It fires the reload function that is basically a try-catch around a decache call and a require. If it throws, the error get assigned to a global object lastReload that can be inspected in the repl.
Adding code

Needed to import my code into the repl. To do that the CONFIG array hosts the information needed to require the code, the name of the global reference to be assigned in the repl context, and a help message. This project uses a yarn workspace monorepo and works well so far.

It gets run through a reduce that sends the info to reload so the code is loaded, and the greeting message is built.
Async/await

Turns out async await with ts-node isn’t ready yet, and I didn’t want to go babel. I may help the team to deliver it actually, but honestly, the current solution isn’t bad at all. Used a function called save or s, a simple helper to handle promises that will save the promise result to __ in repl context. It also pushes it to an array called __history or _h, for inspection later. Just need to wrap the async funcion with s:

ES Modules
I played around with node’s new es module support, but it doesn't work with this repl, because apparently es modules don’t have a mutable cache. Too bad. Sticking with common js for now.
It has more stuff
Repl history works well too, just with node. Did some work to make the output feel more polished with the print helper. Some things I like about this repl:
Minimal & Simple
Typesafe
Very neat DX with auto-reloading
Final code with comments and other files like package.json and tsconfig.json is open sourced at the github gist

Pretty happy with this DX utility :) Peace out people, tet me know if this is useful to you!