Fork me on GitHub

I'm currently thinking about how I can implement a REPL based on es6 dynamic import. It's quite painful... What I currently do is write the expression to a file .repl/foo.js , then dynamically import that file. But you get back a module. If the expression is (+ 1 2 3) it gets compiled as 1 + 2 + 3. But if you evaluate foo.js you don't get 6, or an object with 6, just a module that contains exports (and just 1 + 2 + 3 doesn't export anything). So right now I'm wrapping the expression in var _repl = 1 + 2 + 3; export _repl. But this won't work for (defn foo []) since that compiles as var foo = function .... so wrapping it naively in var _repl = foo = function () ..... Bummer. So maybe every compilation unit should be handled specially for REPL usage. Which is quite annoying!


Annoying but probably there's nothing else that can be done.