From d713463978ec0bbd34fc0da9f443d5242eabee9f Mon Sep 17 00:00:00 2001 From: commiterate <111539270+commiterate@users.noreply.github.com> Date: Mon, 29 Jul 2024 20:46:15 -0400 Subject: [PATCH] Add support for the Bun and pnpm package managers --- src/main/clojure/cljs/cli.clj | 6 +++--- src/main/clojure/cljs/closure.clj | 10 ++++++++-- src/test/clojure/cljs/foreign/node_test.clj | 6 +++--- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/main/clojure/cljs/cli.clj b/src/main/clojure/cljs/cli.clj index da4f2761f..27344ce51 100644 --- a/src/main/clojure/cljs/cli.clj +++ b/src/main/clojure/cljs/cli.clj @@ -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 " @@ -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 @@ -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 " diff --git a/src/main/clojure/cljs/closure.clj b/src/main/clojure/cljs/closure.clj index dffd923fc..708ae03a0 100644 --- a/src/main/clojure/cljs/closure.clj +++ b/src/main/clojure/cljs/closure.clj @@ -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))) @@ -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)) diff --git a/src/test/clojure/cljs/foreign/node_test.clj b/src/test/clojure/cljs/foreign/node_test.clj index 926ccd03a..3e5a7e0e2 100644 --- a/src/test/clojure/cljs/foreign/node_test.clj +++ b/src/test/clojure/cljs/foreign/node_test.clj @@ -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))) @@ -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)