Skip to content

Commit e905fab

Browse files
committed
make load modules public
1 parent 9eb0650 commit e905fab

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/net/coruscation/js4clj/require.clj

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@
3232
(when alias-name
3333
(alias alias-name qualified-module-name)))
3434

35-
(defn- require-module-dynamic [module-name]
35+
(defn load-es-module
36+
"Load a module using `import()`, return the module object"
37+
[module-name]
3638
(let [name (if (.startsWith module-name ".")
3739
;; Some hacky things going on here:
3840
;; `import` isn't really supposed to be abled to import
@@ -65,7 +67,9 @@
6567
:error e}))))))
6668

6769

68-
(defn- require-commonjs-module [name]
70+
(defn load-commonjs-module
71+
"Load a module using `require`, return the module object."
72+
[name]
6973
(let [module (-> @*context*
7074
(.eval "js"
7175
(str "require('" name "')")))]
@@ -105,7 +109,7 @@
105109
it supports ECMAScript modules and legacy CommonJS modules."
106110
{:clj-kondo/lint-as 'clojure.core/require}
107111
[& module-specs]
108-
((require-helper require-module-dynamic) module-specs))
112+
((require-helper load-es-module) module-specs))
109113

110114
(defn require-cjs
111115
"Like `require-js` but use `require` internally instead of `import`
@@ -115,4 +119,4 @@
115119
Also check https://github.com/oracle/graaljs/pull/904, this function will be useless if the upstream issue is resolved."
116120
{:clj-kondo/lint-as 'clojure.core/require}
117121
[& module-specs]
118-
((require-helper require-commonjs-module) module-specs))
122+
((require-helper load-commonjs-module) module-specs))

0 commit comments

Comments
 (0)