This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-05-30
Channels
- # babashka (7)
- # beginners (25)
- # calva (22)
- # cljs-dev (1)
- # clojure (62)
- # clojure-europe (118)
- # clojure-hamburg (4)
- # clojure-israel (2)
- # clojure-nl (2)
- # clojure-uk (6)
- # clojured (1)
- # clojurescript (23)
- # conjure (11)
- # cursive (3)
- # datomic (14)
- # duct (2)
- # emacs (12)
- # figwheel-main (1)
- # gratitude (1)
- # hyperfiddle (4)
- # joyride (72)
- # lsp (46)
- # luminus (1)
- # malli (1)
- # off-topic (54)
- # pathom (19)
- # polylith (11)
- # releases (2)
- # sci (22)
- # shadow-cljs (4)
- # vim (11)
- # xtdb (52)
RE: possible node module indexing bug in CLJS compiler
> I think “node module indexing” is what it’s called 😬
If you use an NPM library which specifies a :main
file with a .cjs
ext in its package.json (see https://github.com/reactchartjs/react-chartjs-2/blob/master/package.json#L27) CLJS can’t find it during the https://github.com/clojure/clojurescript/blob/e30e26dbd221b5d7c4bbc567d10d0c3c01cf5f98/src/main/clojure/cljs/closure.clj#L2871 process. This issue seems to have also been mentioned on https://clojurians.slack.com/archives/C03S1L9DN/p1634583387258500.
To verify this, I went into my project’s local node_modules
package for react-chartjs-2
and updated the main
from ./dist/index.cjs
to ./dist/index.js
. This resolved the issue.
Once I confirmed the above, I then modified CLJS itself: https://github.com/clojure/clojurescript/blob/e30e26dbd221b5d7c4bbc567d10d0c3c01cf5f98/src/main/clojure/cljs/closure.clj#L2854 from
(into [(str entry-path ".js") (str entry-path "/index.js") (str entry-path ".json")])))))))
to
(into [(str entry-path ".js") (str entry-path "/index.js") (str entry-path ".json") (string/replace entry-path #"\.cjs$" ".js")])))))))
And the above change also resolves the issue (without needing to manually update your node_modules
).
It would be great if more experienced CLJS compiler devs could let me know if this is indeed an issue and would a minimal repro be useful?