Skip to content

Commit

Permalink
Add support for the Bun and pnpm package managers
Browse files Browse the repository at this point in the history
  • Loading branch information
commiterate committed Jul 30, 2024
1 parent 47a7bfd commit 418d878
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/main/clojure/cljs/cli.clj
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ present"
:doc (str "Set the output directory to use. If "
"supplied, cljsc_opts.edn in that directory "
"will be used to set ClojureScript compiler "
"options") }
"options")}
["-w" "--watch"] {:group ::compile :fn watch-opt
:arg "paths"
:doc (str "Continuously build, only effective with the "
Expand All @@ -617,7 +617,7 @@ present"
:doc "Set the output compiled file"}
["--deps-cmd"] {:group ::compile :fn deps-cmd-opt
:arg "string"
:doc "Set the node dependency manager. Only npm or yarn supported"}
:doc "Set the node dependency manager. Only npm, bun, pnpm, and yarn are supported"}
["-O" "--optimizations"] {:group ::compile :fn optimize-opt
:arg "level"
:doc
Expand All @@ -629,7 +629,7 @@ present"
:doc
(str "The JavaScript target. Configures environment bootstrap and "
"defaults to browser. Supported values: node or nodejs, "
"webworker, bundle, none") }
"webworker, bundle, none")}
["-ro" "--repl-opts"] {:group ::main&compile :fn repl-env-opts-opt
:arg "edn"
:doc (str "Options to configure the repl-env, can be an EDN string or "
Expand Down
10 changes: 8 additions & 2 deletions src/main/clojure/cljs/closure.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2621,7 +2621,11 @@
(let [proc (-> (ProcessBuilder.
(into (cond->>
[deps-cmd
({"npm" "install" "yarn" "add"} deps-cmd)
({"npm" "install"
"bun" "add"
"pnpm" "add"
"yarn" "add"}
deps-cmd)
"@cljs-oss/module-deps"]
util/windows? (into ["cmd" "/c"]))
(map (fn [[dep version]] (str (name dep) "@" version)))
Expand Down Expand Up @@ -2665,7 +2669,9 @@
(string/replace "CLJS_TARGET" (str "" (when target (name target))))
(string/replace "MAIN_ENTRIES" main-entries)
(string/replace "FILE_SEPARATOR" (escape-backslashes File/separator)))
proc (-> (ProcessBuilder. ["node" "--eval" code])
proc (-> (ProcessBuilder. (case (:deps-cmd opts)
"bun" ["bun" "--eval" code]
["node" "--eval" code]))
.start)
is (.getInputStream proc)
iw (StringWriter. (* 16 1024 1024))
Expand Down
6 changes: 3 additions & 3 deletions src/test/clojure/cljs/foreign/node_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
([f]
(test-util/delete-node-modules)
(doseq [f (map io/file
["package.json" "package-lock.json" "yarn.lock"
"yarn-error.log"])]
["package.json" "package-lock.json" "bun.lockb"
"pnpm-lock.yaml" "yarn.lock" "yarn-error.log"])]
(when (.exists f)
(io/delete-file f)))
(f)))
Expand All @@ -21,7 +21,7 @@
([lib version]
(install :npm lib version))
([cmd lib version]
(let [action ({:npm "install" :yarn "add"} cmd)]
(let [action ({:npm "install" :bun "add" :pnpm "add" :yarn "add"} cmd)]
(sh/sh (name cmd) action (str lib "@" version)))))

(test/use-fixtures :once cleanup)
Expand Down

0 comments on commit 418d878

Please sign in to comment.