The cljs/bootstrap_graaljs.js file provides some basic functions like setTimeout which libraries take as given in a JS environment to work.
For GraalJS repl envs this is provided: https://github.com/clojure/clojurescript/blob/bc6ecdd6e53ccff42315ed747e34ace465def986/src/main/clojure/cljs/repl/graaljs.clj#L64
For optimized builds however, the file is not included and the functions are missing:
https://clojure.atlassian.net/secure/attachment/18669/CLJS-3113.patch would have been my first approach: It adds the bootstrap_graaljs.js file to inputs. This works for :optimiziations :simple, but not for :advanced. I this could probably be fixed with externs, but wanted to discuss the general approach first.
Yeah, in general, this makes sense to me: We have precedent with Node with respect to the notion of target-specific "support libs".
Perhaps a slight improvement would be to separate out the general runtime support functions (setTimeout etc.) into a separate GraalJS runtime support file, which :simple / :advanced builds could implicitly load along the lines that you suggest. (These could be separated out from those functions that really only exist to help bootstrap GraalJS in a mode supporting REPL development, loading using Closure infrastructure---those functions might not need to be there in :simple / :advanced builds.)
With respect to :advanced and externs: Functions like setTimeout may already be covered and, assuming the "support lib" is essentially treated as a foreign lib, not passed through Closure, Closure would know not to rename call call sites that go through Closure.
Thanks for your feedback Mike! I looked into advanced compilation, and the problem is not missing externs for setTimeout etc, but for the Java methods used: newScheduledThreadPool etc. As with the current patch, it thus seems the support lib is not treated as a foreign lib. I tried to figure out a way to treat it like a foreign lib, but did not succeed thus far. I’ll have another try, but in the meantime if somebody has a pointer on how to do that, that would help a lot.
This also can be closed since out of the box graaljs support has been removed ClojureScript compiler.