funcool/decimal

Compilation fails under shadow-cljs

achikin opened this issue · 2 comments

Compilation fails while trying to compile the library with shadow-cljs.
The following error is shown.

The required namespace "decimal.extern.decimaljs" is not available, it was required by "decimal/core.cljs".

shadow-cljs does not support foreign libs inside cljs libraries. As per Thomas Heller advice - you should fetch decimal.js from npm separately and create the following namespace to make the npm version available to funcool/decimal

;;file: src/cljs/decimal/extern/decimaljs.cljs adjust according to your code layout
(ns decimal.extern.decimaljs
  (:require ["decimal.js" :as decimal-js]))
(js/goog.exportSymbol "Decimal.noConflict" (fn [] decimal-js))

While @achikin's solution works, would it be a good idea to support compilation with shadow out of the box? Shadow is somewhat popular these days and it might be a best practice for a small useful library like this to work with at least the most common cljs build tools without having to add an additional namespace.

There is a good writeup on packaging cljs libs here:
https://widdindustries.com/cljs-npm-libraries/