shadow-cljs

https://github.com/thheller/shadow-cljs | https://github.com/sponsors/thheller | https://www.patreon.com/thheller
RollACaster 2021-02-15T11:56:42.225500Z

Hi, I am trying to import http://kepler.gl, unfortunately the library is mixing esm & commonjs imports which results in an error when I try to import them. https://github.com/keplergl/kepler.gl/blob/master/src/localization/index.js#L30 I tried to manually specify the requirements with:

{
  ...
   :js-options
   {:resolve {"./fi" {:target :file
                      :require  "node_modules/kepler.gl/dist/localization/fi.js"}}
             ...}
}
Which resulted in another error: $jscomp.inherits is not a function Is there some way to import this library?

thheller 2021-02-15T12:17:57.226200Z

@thsojka you might need to use webpack. the lib seems to do stuff that shadow-cljs does not support

thheller 2021-02-15T12:18:16.226600Z

the inherits you can get rid of by setting :compiler-options {:output-feature-set :es6}

RollACaster 2021-02-15T12:20:04.227Z

thanks 👍 I’ll try that

zendevil 2021-02-15T13:14:12.229900Z

something that’s working in regular react native isn’t working in cljsrn run with shadowcljs, making me think that there must be something up with shadow that’s causing it. React Native:

<LottieView
      source={require('../components/img/animations/cat-loading.json')}
      style={{marginRight: 100, marginLeft: 50}}
      autoPlay
      loop
    />
In this case I’m seeing the LottieView animation. Cljs React Native:
[:> LottieView {:source (js/require "../resources/images/loading2.json")
                      :autoPlay true
                      :loop true
                      :style {:height 200
                              :marginright 200
                              :marginleft 50}}]
In this case I’m not seeing the LottieView animation. What might be causing this error?

zendevil 2021-02-15T13:42:28.230400Z

In the github of lottie files it’s imported like so:

import LottieView from 'lottie-react-native';

zendevil 2021-02-15T13:43:15.231400Z

which, according to the shadow user guide translates to: [“lottie-react-native” :default LottieView]

zendevil 2021-02-15T13:44:08.232500Z

But this gives an error. using :as instead of default doesn’t give an error (but the animation doesn’t show either). Why am I getting an error when using :default when I’m using the direct translation from shadow cljs user guide?

thheller 2021-02-15T14:13:09.233700Z

@ps I don't have a clue. I do not use react-native. this looks correct to me except maybe for the path used in the js/require call. that looks wrong. might also be the :style map. not exaclty sure how reagent converts that, if at all.