Skip to content

CLJS-3345: package.json exports can be a dupe of main #117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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