This article is written to explain how the above gif works in the chrome (and other) browser consoles. A quick disclaimer: this whole thing is a huge hack, it shouldn't be used for anything seriously, and there are probably much better ways of accomplishing the same.
My inspiration for building this was Max Ogden's Requirebin, which allows users to use a browser based editor to run custom javascript in the browser (including javascript that had require() statements that would normally need to be pre-processed using browserify).
Requirebin is a great site, but I found myself wondering if it was possible to do something like this with an interactive REPL.
After browsing the source code for requirebin, I found that the key to making it work was a project called browserify-cdn, an HTTP-based service which given a URL, will return in the response body a string of javascript representing a browserified bundle of an npm library.
That is, given a URL like
/standalone/concat-stream@latest
browserify-cdn will bundle up concat-stream and all of its dependencies in the same way that browserify would if we were doing require('concat-stream') in a client side project. So this should be a great tool to use for my interactive version of requirebin too...
At some point we are going to have to define a request() function for the browser. Let's skip over the details of this for right now, and assume it looks something like


nice