Skip to content

Commit b4aaa40

Browse files
authored
Merge pull request #117 from clojure/cljs-3345/pkg-json-exports-main
CLJS-3345: package.json exports can be a dupe of main
2 parents 3b59bb8 + 8edcebe commit b4aaa40

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

src/main/clojure/cljs/closure.clj

+20-16
Original file line numberDiff line numberDiff line change
@@ -2791,22 +2791,26 @@
27912791
(add-exports [pkg-jsons]
27922792
(reduce-kv
27932793
(fn [pkg-jsons path {:strs [exports] :as pkg-json}]
2794-
(reduce-kv
2795-
(fn [pkg-jsons export _]
2796-
;; NOTE: ignore "." exports for now
2797-
(if (= "." export)
2798-
pkg-jsons
2799-
(let [export-pkg-json
2800-
(io/file
2801-
(trim-package-json path)
2802-
(trim-relative export)
2803-
"package.json")]
2804-
(cond-> pkg-jsons
2805-
(.exists export-pkg-json)
2806-
(assoc
2807-
(.getAbsolutePath export-pkg-json)
2808-
(json/read-str (slurp export-pkg-json)))))))
2809-
pkg-jsons exports))
2794+
;; "exports" can just be a dupe of "main", i.e. a string - ignore
2795+
;; https://nodejs.org/api/packages.html#main-entry-point-export
2796+
(if (string? exports)
2797+
pkg-jsons
2798+
(reduce-kv
2799+
(fn [pkg-jsons export _]
2800+
;; NOTE: ignore "." exports for now
2801+
(if (= "." export)
2802+
pkg-jsons
2803+
(let [export-pkg-json
2804+
(io/file
2805+
(trim-package-json path)
2806+
(trim-relative export)
2807+
"package.json")]
2808+
(cond-> pkg-jsons
2809+
(.exists export-pkg-json)
2810+
(assoc
2811+
(.getAbsolutePath export-pkg-json)
2812+
(json/read-str (slurp export-pkg-json)))))))
2813+
pkg-jsons exports)))
28102814
pkg-jsons pkg-jsons))]
28112815
(let [
28122816
;; a map of all the *top-level* package.json paths and their exports

0 commit comments

Comments
 (0)