From 8edcebe1343318b6fb683f37dfd8f523900377ab Mon Sep 17 00:00:00 2001 From: davidnolen Date: Mon, 27 Dec 2021 14:43:10 -0500 Subject: [PATCH] CLJS-3345: package.json exports can be a dupe of main --- src/main/clojure/cljs/closure.clj | 36 +++++++++++++++++-------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/src/main/clojure/cljs/closure.clj b/src/main/clojure/cljs/closure.clj index edb0d1f17..34716156c 100644 --- a/src/main/clojure/cljs/closure.clj +++ b/src/main/clojure/cljs/closure.clj @@ -2791,22 +2791,26 @@ (add-exports [pkg-jsons] (reduce-kv (fn [pkg-jsons path {:strs [exports] :as pkg-json}] - (reduce-kv - (fn [pkg-jsons export _] - ;; NOTE: ignore "." exports for now - (if (= "." export) - pkg-jsons - (let [export-pkg-json - (io/file - (trim-package-json path) - (trim-relative export) - "package.json")] - (cond-> pkg-jsons - (.exists export-pkg-json) - (assoc - (.getAbsolutePath export-pkg-json) - (json/read-str (slurp export-pkg-json))))))) - pkg-jsons exports)) + ;; "exports" can just be a dupe of "main", i.e. a string - ignore + ;; https://nodejs.org/api/packages.html#main-entry-point-export + (if (string? exports) + pkg-jsons + (reduce-kv + (fn [pkg-jsons export _] + ;; NOTE: ignore "." exports for now + (if (= "." export) + pkg-jsons + (let [export-pkg-json + (io/file + (trim-package-json path) + (trim-relative export) + "package.json")] + (cond-> pkg-jsons + (.exists export-pkg-json) + (assoc + (.getAbsolutePath export-pkg-json) + (json/read-str (slurp export-pkg-json))))))) + pkg-jsons exports))) pkg-jsons pkg-jsons))] (let [ ;; a map of all the *top-level* package.json paths and their exports