Fork me on GitHub
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 saying import sample from '../dbstore/sample1.json'; would work.


you need to provide an actual path


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

Eric Ihli16:01:27

Oh, sorry, I also have

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


yeah thats not how that works


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


so not inside the ns


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


where the path is relative to the :output-dir

Eric Ihli16:01:46

Ah. Ok. Thank you so much.


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


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: but it doesn't exist on clojars appears it wants to be included with deps.edn via git shas: I'd like to use hot code reloading with it so I'm looking at shadow

Adrian Smith22:01:24

Build error looks like 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


just use deps.edn

Adrian Smith09:01:35

hmm uix library is specified in 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


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: 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 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


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