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 Aug 14, 2024
1 parent c6a7a41 commit d713463
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 @@ -638,7 +638,7 @@ generic - the combinations must be explicitly supported"}
: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 @@ -649,7 +649,7 @@ generic - the combinations must be explicitly supported"}
: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 @@ -661,7 +661,7 @@ generic - the combinations must be explicitly supported"}
: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 d713463

Please sign in to comment.