Fork me on GitHub
#shadow-cljs
<
2024-03-16
>
Rei18:03:43

Hey there. How would one import a JS file before everything else in SCLJS? I'm trying to setup https://reactnavigation.org/docs/drawer-layout/#installation and it requires having this import 'react-native-gesture-handler'; before everything else in index.js or App.js. Any help is highly appreciated. Thanks in advance.

thheller18:03:37

why does it need to be before anything?

thheller18:03:33

I mean the best place is probably the locations you mentioned since they run before any CLJS output?

Rei18:03:08

> why does it need to be before anything? I have no idea. My best answer is "because React Native?" > I mean the best place is probably the locations you mentioned since they run before any CLJS output? You mean index.js? Wouldn't it be overwritten by SCLJS on hot-reload?

thheller18:03:09

its been years since I looked at anything react-native, so what does that look like nowadays?

thheller18:03:24

there used to be a index.js that would then just import the CLJS output file

thheller18:03:39

so just had something like import "./app/index.js" or whatever you called the file?

thheller18:03:57

or is there no extra JS file getting loaded anymore?

thheller18:03:36

like that example

thheller18:03:27

that file isn't generated, so you can just put the import there manually

Rei18:03:06

that file is no longer required. RN now uses Expo, and you can configure expo to use index.js directly within whatever the :output-dir of SCLJS is

thheller18:03:39

well, the trick still works probably though right?

thheller18:03:49

so just recreate that indirection?

Rei18:03:27

yeah I'll prob try that tomorrow since I'm out of ideas at this point

thheller18:03:56

otherwise you can just maybe require it first in your entry namespace?

thheller18:03:17

so just (:require ["that-thing"] ["react-native" ...])

thheller18:03:31

the order is respected, so it should still end up first

Rei18:03:18

I just tried that and it didn't work unfortunately. But as there are no errors, and "didn't work" is simply an observation of "I don't see anything happening".

Rei18:03:46

Brain's fried at this point so I'll revisit this tomorrow to have another go at it. Thanks for the help 🙂