Skip to content

Commit 4a753fc

Browse files
committed
helpers to generate file for runtime require of bundle modules
1 parent 0daf21e commit 4a753fc

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/main/clojure/cljs/closure.clj

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,6 +1673,19 @@
16731673
(and (= :nodejs (:target opts))
16741674
(false? (:nodejs-rt opts))))
16751675

1676+
(defn export-dep [dep]
1677+
(str "\""dep "\": require('" dep "')" ))
1678+
1679+
(defn deps-rt-js
1680+
"Returns the JavaScript code to support runtime require of bundled modules."
1681+
[node-requires]
1682+
(str
1683+
"module.exports = {\n"
1684+
" npmDeps: {\n"
1685+
(string/join ",\n" (map (comp #(str " " %) export-dep) node-requires))
1686+
" }\n"
1687+
"};\n"))
1688+
16761689
(defn output-main-file
16771690
"Output an entry point. In the non-modules case, opts is simply compiler
16781691
options. When emitting a module entry point, opts must contain :module-name."

0 commit comments

Comments
 (0)