Welcome! Please see the About page for a little more info on how this works.

0 votes
in ClojureScript by
The {{[cljs/bootstrap_graaljs.js|https://github.com/clojure/clojurescript/blob/bc6ecdd6e53ccff42315ed747e34ace465def986/src/main/cljs/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:

{{src/foo.cljs}}

(ns foo
  (:require [clojure.core.async :as async]))
(async/timeout 1000)



$ clj -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.10.520"} org.clojure/core.async  {:mvn/version "0.4.474"}}}' -m cljs.main -O simple -t graaljs -c foo
WARNING: foo is a single segment namespace at line 1 /Users/kommen/work/cljs-issues/graal-build/src/foo.cljs
$ js out/main.js
ReferenceError: setTimeout is not defined
    at <js> queue_delay(out/main.js:2201:905961-905970)
    at <js> timeout(out/main.js:2298-2299:948503-948718)
    at <js> timeout(out/main.js:2311:954258-954305)
    at <js> :program(out/main.js:2569:1074102-1074139)

$ js --version
GraalVM JavaScript (GraalVM CE Native 19.0.0)

2 Answers

0 votes
by

Comment made by: kommen

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.

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJS-3113 (reported by kommen)
...