Welcome! Please see the About page for a little more info on how this works.

0 votes
in ClojureScript by

It is increasingly common that people want to use JS packages not provided by {{:foreign-libs}}. Many CLJS libs however are built on the assumption that you are using {{:foreign-libs}}.

Om, Reagent and others expect {{cljsjs.react}} to provide a global {{js/React}}. Currently users need to work around (link: 1) those {{:foreign-libs}} dependencies by using {{:exclusions}} in {{lein}} or {{boot}} and by creating empty stub files to ensure that the {{cljsjs.react}} namespace still exist so the libraries can be compiled

This CLJSJS pull request (link: 2) wants to provide those empty stub files in a surrogate package since work around this has become to common. As detailed in the PR comments I think this is a dangerous precedent and that we should come up with a better solution.

The simplest way forward would be to add a compiler option to just keep all (or some) {{:foreign-libs}} from being included in the build. The externs are still useful but the JS could just be ignored.

The better solution probably involves using the JS packages by their actual name (via https://dev.clojure.org/jira/browse/CLJS-2061) so the need for {{cljsjs}} alias packages goes away.

(link: 1) http://blob.tomerweller.com/reagent-import-react-components-from-npm
(link: 2) https://github.com/cljsjs/packages/pull/1192

1 Answer

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJS-2074 (reported by thheller)
...