Skip to content

Commit

Permalink
Merge pull request #117 from clojure/cljs-3345/pkg-json-exports-main
Browse files Browse the repository at this point in the history
CLJS-3345: package.json exports can be a dupe of main
  • Loading branch information
swannodette authored Dec 28, 2021
2 parents 3b59bb8 + 8edcebe commit b4aaa40
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions src/main/clojure/cljs/closure.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b4aaa40

Please sign in to comment.