funcool / decimal

An arbitrary-precision Decimal type for ClojureScript
http://funcool.github.io/decimal/latest/
BSD 2-Clause "Simplified" License
13 stars 6 forks source link

Unable to require library with re-natal / React Native #2

Closed gnl closed 7 years ago

gnl commented 7 years ago

I was really excited to finally find a quality native math library for cljs, but we don't seem to be getting along just yet.

After adding the library to my project.clj dependencies and trying to require it in a namespace, the app throws the following exceptions on launch:

ExceptionsManager.js:71 Error: Uncaught ReferenceError: global is not defined
    at syncImportScripts (figwheel-bridge.js:119)
    at importJs (figwheel-bridge.js:146)
    at goog.writeScriptTag_ (figwheel-bridge.js:245)
    at Object.goog.importScript_ (base.js:907)
    at Object.goog.writeScripts_ (base.js:1420)
    at goog.require (base.js:673)
    at figwheel-bridge.js:223
    at syncImportScripts (figwheel-bridge.js:124)
    at importJs (figwheel-bridge.js:146)
    at figwheel-bridge.js:218

ExceptionsManager.js:71 Error: Uncaught TypeError: Decimal.noConflict is not a function
    at syncImportScripts (figwheel-bridge.js:119)
    at importJs (figwheel-bridge.js:146)
    at goog.writeScriptTag_ (figwheel-bridge.js:245)
    at Object.goog.importScript_ (base.js:907)
    at Object.goog.writeScripts_ (base.js:1420)
    at goog.require (base.js:673)
    at figwheel-bridge.js:223
    at syncImportScripts (figwheel-bridge.js:124)
    at importJs (figwheel-bridge.js:146)
    at figwheel-bridge.js:218

I suspect it has something to do with it being unable to find the underlying JS library, but really not sure how to troubleshoot this.

I tried installing decimal.js from npm and doing this:

(def decimaljs (js/require "decimal.js"))
(set! js/window.Decimal decimaljs)

It didn't change anything.

jespino commented 7 years ago

I have to take a look on it. Thanks for your feedback.

jespino commented 7 years ago

Ok, I know the problem, works with the "node" version but not with the "browser" version, I have to fix how is exported the js underlaying code.

Thanks again for your feedback, I hope to have time to fix it tomorrow.

jespino commented 7 years ago

Fixed on master (I think) @niwinz must create a new release that with this, anyway, tomorrow I will test it a bit more.

gnl commented 7 years ago

Just tested, looking good! Thank you

niwinz commented 7 years ago

released 1.0.1 with the last fix ;)