Fork me on GitHub
#shadow-cljs
<
2022-05-03
>
pinkfrog13:05:38

Question on npm package import. Specifically for this package: https://www.npmjs.com/package/react-deep-force-update. I imported it with:

(ns app.util.dev
  (:require
   [reagent.core :as r]
   ["react-deep-force-update" :as deep]
   ,,,))
I checked the js-keys in deep, but found nothing. How could this happen?

thheller14:05:55

@i why do you expected keys? maybe you just do (deep)? maybe deep is just a function? or maybe see the usage examples here https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages

pinkfrog14:05:09

Isn’t (.-default deep) equal to "react-deep-force-update$default ?

thheller14:05:49

in theory yes. but the package may not be published as actual esm. in which case it might not have default export

thheller14:05:49

but for those kinds of packages often react-deep-force-update$default and react-deep-force-update yield the same thing

pinkfrog14:05:11

It is: https://github.com/gaearon/react-deep-force-update/blob/843afa2c7fcc820c079144c3948bed2784b36f12/src/index.js#L56. My fundamental question is how to invoke the deepForceUpdate function. react-deep-force-update$default gives a nil.

thheller14:05:39

don't ever look at the source of a npm package to make guess how about how it is actually published

thheller14:05:04

my guess is as I said (:require ["react-deep-force-update" :as deep]) and then just (deep) somewhere

thheller14:05:26

this is the content of the actual npm package https://unpkg.com/[email protected]/lib/index.js

thanks3 1
thheller14:05:38

esm nowhere to be found, published as commonjs as expected

thheller14:05:55

it seems to expect an argument. dunno what that is or how you get it though