Fork me on GitHub

Hi, @borkdude. I'm trying to do something quite bizarre, so let me check if there's a better way with you here đŸ™‚. I want to use SCI on a CLJS project. The problem is that I'll need to alter the source a little bit before I interpret it. In my case, I want to convert every instance of (js/require "some-filename.js") that appears on my code to a string (specifically, I'll replace to the contents of some-filename.js). Does exist a simple way to do this, to make this transformation?


Originally, I was thinking on using rewrite-cljs to make the change, just so you know what are my ideas đŸ˜„


@mauricio.szabo yes, you can do this quite easily, by using the lower level API, by first parsing the expressions using sci/parse-next, then rewrite them and then evaluating using eval-form.


@mauricio.szabo I'm doing something similar in grasp, where I parse expressions and only evaluate the namespace forms after a bit of rewriting.


However, why don't you just use :load-fn so users can use the normal require?


Ah you are not loading normal CLJS code. Yes, the above approach should then be ok


Alternatively you can override another function into js/require possibly


Yes, and I have to bundle the JS lib too, and other strange things đŸ˜„