* Add a :load-fn for js libs on globalThis. Fixes #95. * Update changelog.
This commit is contained in:
parent
ab527ad5a1
commit
7aebb5bbb0
|
@ -9,6 +9,8 @@
|
||||||
<!-- - Create Github release with updated links from `doc/links.md` -->
|
<!-- - Create Github release with updated links from `doc/links.md` -->
|
||||||
<!-- - `bb gh-pages` -->
|
<!-- - `bb gh-pages` -->
|
||||||
|
|
||||||
|
- [#95](https://github.com/babashka/scittle/issues/121): support string requires of `globalThis` js deps ([@chr15m](https://github.com/chr15m))
|
||||||
|
|
||||||
## v0.7.26 (2025-08-20)
|
## v0.7.26 (2025-08-20)
|
||||||
|
|
||||||
- [#121](https://github.com/babashka/scittle/issues/121): add `cjohansen/dataspex` plugin ([@jeroenvandijk](https://github.com/jeroenvandijk))
|
- [#121](https://github.com/babashka/scittle/issues/121): add `cjohansen/dataspex` plugin ([@jeroenvandijk](https://github.com/jeroenvandijk))
|
||||||
|
|
|
@ -53,13 +53,19 @@
|
||||||
'sci.core {'stacktrace sci/stacktrace
|
'sci.core {'stacktrace sci/stacktrace
|
||||||
'format-stacktrace sci/format-stacktrace}})
|
'format-stacktrace sci/format-stacktrace}})
|
||||||
|
|
||||||
|
(defn load-fn [{:keys [ctx] :as opts}]
|
||||||
|
(when-let [lib (and (string? (:namespace opts))
|
||||||
|
(gobject/get js/globalThis (:namespace opts)))]
|
||||||
|
(sci/add-js-lib! ctx (:namespace opts) lib)))
|
||||||
|
|
||||||
(store/reset-ctx!
|
(store/reset-ctx!
|
||||||
(sci/init {:namespaces namespaces
|
(sci/init {:namespaces namespaces
|
||||||
:classes {'js js/globalThis
|
:classes {'js js/globalThis
|
||||||
:allow :all
|
:allow :all
|
||||||
'Math js/Math}
|
'Math js/Math}
|
||||||
:ns-aliases {'clojure.pprint 'cljs.pprint}
|
:ns-aliases {'clojure.pprint 'cljs.pprint}
|
||||||
:features #{:scittle :cljs}}))
|
:features #{:scittle :cljs}
|
||||||
|
:load-fn load-fn}))
|
||||||
|
|
||||||
(unchecked-set js/globalThis "import" (js/eval "(x) => import(x)"))
|
(unchecked-set js/globalThis "import" (js/eval "(x) => import(x)"))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue