Fork me on GitHub
#shadow-cljs
<
2020-01-12
>
knubie16:01:40

Anyone using shadow-cljs with react-native? In my project every time I make a change to a cljs file it will update quickly (using Fast Refresh I assume?), but then a couple seconds later it will rebuild/re-download the bundle.

knubie16:01:26

I’m wondering if there’s some configuration I can change, or a different way to set up the project that will avoid the re-downloading every time

thheller16:01:38

you need to turn off all react-native reloading

thheller16:01:17

no clue how to do that but it interferes with the reloading shadow-cljs does

knubie18:01:00

i see, i’ll give it shot thanks

Eric Ihli22:01:03

I ran into this problem. Ctrl-M in the emulator brought up the menu for me where I could disable fast-refresh.

Eric Ihli22:01:13

If you're new to CLJS/RN like I am, I made a repo with a single commented file that has the bare-minimum setup. It helped me and if you're new too you might find it useful. https://github.com/eihli/cljs-react-native-starter/blob/master/src/example/core.cljs

thheller22:01:40

@UJP37GW2K you never require devtools.core. if you need it you add it to your build config :devtools {:preloads [devtools.preload]}

thheller22:01:49

otherwise it'll be included in your release bbuilds

Pavel Klavík21:01:44

Hi, I am trying to make TextInput from Material-ui working within our project, where the problem was reported by my colleagues couple days back: We require this:

["@material-ui/core/TextField" :default TextField]
We get the following error in the console:
js.js:74 shadow-cljs - failed to load module$node_modules$$material_ui$core$Select$SelectInput
shadow.js.jsRequire @ js.js:74
shadow$provide.module$node_modules$$material_ui$core$Select$Select @ Select.js:21
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$material_ui$core$Select$index @ index.js:16
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$material_ui$core$TextField$TextField @ TextField.js:37
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$material_ui$core$TextField$index @ index.js:16
shadow.js.jsRequire @ js.js:66
shadow.js.require @ js.js:100
(anonymous) @ orgpad.client.views.widgets.text_field.js:3
js.js:74 shadow-cljs - failed to load module$node_modules$$material_ui$core$Select$Select
shadow.js.jsRequire @ js.js:74
shadow$provide.module$node_modules$$material_ui$core$Select$index @ index.js:16
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$material_ui$core$TextField$TextField @ TextField.js:37
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$material_ui$core$TextField$index @ index.js:16
shadow.js.jsRequire @ js.js:66
shadow.js.require @ js.js:100
(anonymous) @ orgpad.client.views.widgets.text_field.js:3
js.js:74 shadow-cljs - failed to load module$node_modules$$material_ui$core$Select$index
shadow.js.jsRequire @ js.js:74
shadow$provide.module$node_modules$$material_ui$core$TextField$TextField @ TextField.js:37
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$material_ui$core$TextField$index @ index.js:16
shadow.js.jsRequire @ js.js:66
shadow.js.require @ js.js:100
(anonymous) @ orgpad.client.views.widgets.text_field.js:3
js.js:74 shadow-cljs - failed to load module$node_modules$$material_ui$core$TextField$TextField
shadow.js.jsRequire @ js.js:74
shadow$provide.module$node_modules$$material_ui$core$TextField$index @ index.js:16
shadow.js.jsRequire @ js.js:66
shadow.js.require @ js.js:100
(anonymous) @ orgpad.client.views.widgets.text_field.js:3
js.js:74 shadow-cljs - failed to load module$node_modules$$material_ui$core$TextField$index
shadow.js.jsRequire @ js.js:74
shadow.js.require @ js.js:100
(anonymous) @ orgpad.client.views.widgets.text_field.js:3
js.js:75 Uncaught TypeError: Cannot read property 'isRequired' of undefined
    at Object.shadow$provide.module$node_modules$$material_ui$core$Select$SelectInput (SelectInput.js:453)
    at shadow.js.jsRequire (js.js:66)
    at Object.shadow$provide.module$node_modules$$material_ui$core$Select$Select (Select.js:21)
    at shadow.js.jsRequire (js.js:66)
    at Object.shadow$provide.module$node_modules$$material_ui$core$Select$index (index.js:16)
    at shadow.js.jsRequire (js.js:66)
    at Object.shadow$provide.module$node_modules$$material_ui$core$TextField$TextField (TextField.js:37)
    at shadow.js.jsRequire (js.js:66)
    at Object.shadow$provide.module$node_modules$$material_ui$core$TextField$index (index.js:16)
    at Object.shadow.js.jsRequire (js.js:66)
It was suggested that the problem is with a conflict of dependencies. Any ideas how to do debugging?

Pavel Klavík21:01:38

these are all the dependencies we currently use:

"dependencies": {
  "@material-ui/core": "^4.8.0",
  "bezier-js": "^2.4.4",
  "create-react-class": "^15.6.3",
  "deps": "^0.1.2",
  "process": "^0.11.10",
  "react": "^16.12.0",
  "react-dom": "^16.12.0",
  "react-motion": "^0.5.2",
  "webfontloader": "^1.6.28"
},

thheller21:01:32

quick look at the code suggest prop-types is the problematic package

thheller21:01:56

check which one material-ui expects and which one you have in node_modules/prop-types

thheller21:01:36

might go deeper than that package too

thheller21:01:51

can't really tell where the isRequired is supposed to be coming from

thheller21:01:07

or rather it is trying default.isRequired and default is undefined

Pavel Klavík21:01:02

in the minimal working example, we have "[email protected]"

thheller21:01:25

I also have 15.7.2

thheller21:01:43

you can also check node_modules/@material-ui/core/node_modules

thheller21:01:51

thats usually a clue if there are packages in there

thheller21:01:06

shadow-cljs doesn't read those

Pavel Klavík21:01:03

ya, there is on

Pavel Klavík21:01:26

so what is the solution? adding this dependency directly into our project?

thheller21:01:56

no clue. might be.

thheller21:01:18

material-ui is one of those packages that constantly breaks

Pavel Klavík21:01:21

I have tested to add it and it runs fine 🙂

thheller21:01:24

I really wouldn't recommend using it

Pavel Klavík21:01:07

hmm, what are the alternatives? we basically want to get reasonable UI elements without spending much time with it

Pavel Klavík21:01:32

anyway, thx a lot for help, I will have to learn to read JS packages better

Pavel Klavík21:01:45

hopefully we get everything running soon

Pavel Klavík21:01:30

how the npm modules have versions chosen? why did we got the older version for prop-types?

thheller21:01:01

its a common package. some other package you installed also depended on the older version

thheller21:01:19

npm list or something shows all installed packages

Pavel Klavík21:01:10

why is not the largest needed version installed? it seems that also react and react-motion depended on it

thheller22:01:40

don't ask me .. I don't know how they handle this anymore

Pavel Klavík22:01:17

ok, complexity lurks everywhere out there 🙂 anyway thx a lot

JonR22:01:38

Hi Folks, wondering if anyone has by chance tried using Rete.js with shadow-cljs?

JonR22:01:14

I'm trying shadow-cljs out for the first time and hoping to use this lib. Installs fine via npm but when I try to require and use as in the examples the object import is empty

JonR22:01:36

I can import other deps from node which are installed in the project just fine

JonR22:01:31

From what I can see the library is a TS project using Rollup.js and ES

JonR22:01:19

So in short, hoping someone has tips in using an npm lib using babel, ts and rollup.js (most of which I generally understand but don't have experience with)

just.sultanov17:01:55

@UQR2E9W15 Hi! I’m setting up shadow-cljs with monaco-editor and rollup.js too. Change the config a little bit and that will work with typescript. Maybe it can help you. https://github.com/just-sultanov/clj-monaco

JonR18:01:27

Hey @U1EQNSHL4 thanks so much for the tip! I ended up getting around rollup etc. by requiring the min file directly like so:

["rete/build/rete.min.js" :as rete]