Fork me on GitHub
#shadow-cljs
<
2020-01-20
>
Eric Ihli16:01:56

I'm trying to require a json object from a json file. (ns foo (:require ["test.json" as test-json])) compiles to SHADOW_IMPORT("module$src$test_json.js");, if I'm reading this correctly. Obviously that can't be found. I was expected this to work according to https://medium.com/technoetics/reading-data-from-json-files-in-react-native-3622744b75e3 saying import sample from '../dbstore/sample1.json'; would work.

thheller16:01:37

you need to provide an actual path

thheller16:01:00

so ["./test.json" :as test-json]

Eric Ihli16:01:27

Oh, sorry, I also have

:resolve {"test.json" {:target :file
                        :file "src/test.json"}}

thheller16:01:37

yeah thats not how that works

thheller16:01:47

if you are in react-native you should be using js/require

thheller16:01:50

so not inside the ns

thheller16:01:07

(def data (js/require "../path-to/file.json"))

thheller16:01:26

where the path is relative to the :output-dir

Eric Ihli16:01:46

Ah. Ok. Thank you so much.

thheller16:01:35

FWIW :resolve is typically only used in cases where you can't change the code that does the require (eg. in libraries)

thheller16:01:20

if you can change the require that should be your first option. :resolve doesn't give require any new options otherwise

Eric Ihli16:01:26

I see. Thanks. That seems logical in hindsight.

Adrian Smith22:01:00

I'm playing with uix: https://www.reddit.com/r/Clojure/comments/erdo6t/desktop_apps_in_clojurescript_and_qt/ but it doesn't exist on clojars appears it wants to be included with deps.edn via git shas: https://github.com/roman01la/uix I'd like to use hot code reloading with it so I'm looking at shadow

Adrian Smith22:01:24

Build error looks like https://i.imgur.com/81uErti.png though works ok if invoked via node out/main.js

Adrian Smith22:01:16

but not sure how to include uix as a dependency in shadow-cljs.edn

thheller22:01:22

just use deps.edn

Adrian Smith09:01:35

hmm uix library is specified in deps.edn - https://github.com/roman01la/proton-native-cljs/blob/master/deps.edn is that what you meant?

Adrian Smith10:01:14

That worked thank you it builds, I have another error now but suspect it's not related to shadow

thheller10:01:36

what is it? I know roman sometimes likes to write weird code that reaches deeply into the compiler that may cause issues with shadow-cljs 😛

Adrian Smith10:01:29

lol, there was an error coming out of react-proxy for this line: https://github.com/roman01la/proton-native-cljs/blob/master/src/app/core.cljs#L200 I've replaced that locally with the same code but behind a function called main! and updated my build's :main key to that function I now have a build without errors and running node out/main.js runs the app without error but there's no live reloading I can see shadow is recompiling though

Adrian Smith10:01:05

I think this line https://github.com/roman01la/proton-native-cljs/blob/master/src/app/core.cljs#L204 is supposed to be the line for reloading and it has meta data but I don't know if that's enough I haven't told shadow about it otherwise

thheller10:01:09

hmm yeah thats figwheel. its ^:dev/after-load in shadow-cljs

Adrian Smith10:01:15

ah cool I think it's working I can see println output from update! I was assuming I could change the numbers on the calculator and immediately see that I don't think the update-proxy! thing is updating the react components properly