Fork me on GitHub

Has anyone here had any luck requiring .js or .jsx files from Krell? I cannot figure out what path the bundler wants me to give it.


The Juxt blog post here shows a directory structure:


But reproducing what they’re describing doesn’t seem to work for me; no matter where I put the file or reference it, I see errors from the bundler (i.e., the output of yarn start) like:

ERROR  Could not evaluate  [TypeError: undefined is not an object (evaluating 'require("../src/file_for_later/ios/js/Test.jsx").default')]


I’ve essentially spammed every combo I can think of, with no luck.


I can start a blank project for a bare repro, but if someone here has been through this and can give me the secret before I try, happy to listen to ideas.


by "spammed every combo" do you mean doing this at the REPL?


JS dependencies need to be processed via metro which can't be done at the REPL. so JS deps in general are only available via a regular build


otherwise it should be a path relative to the output file of your CLJS. unless krell rewrites that in some way. not sure about that part.


Did it by changing and saving the file, then doing a reload from the simulator, which generated a new error with a different path from metro, so I’m pretty sure the changes are being picked up.


Relative to CLJS is what I tried first. The Juxt blog seems to imply it’s not that:

// src/app/components.cljs
(def utils (js/require "../src/stories/utils.js"))


I’ve confirmed in the output JS in target/ generated from my CLJS that the relative path refers to the place my JS file lives.


I’m wondering if I’m doing something wrong in writing the JS itself? I.e., the require(...) is returning undefined, so maybe it finds the file but doesn’t actually get anything out of it?


Having the same issue with assets (i.e., a png file), so I don’t think the issue is the JS.


Are you recompiling each time?


Also do you have your path in the deps.edn?


It does appear to be recompiling (i.e., the output JS in target/ changes)


I’m not sure what you mean about paths in deps.edn, so maybe I’m missing that?


In your deps.edn you need a :paths keyword. Here’s an example of mine:

:paths     ["src" "resources" "js" "components" "constants"]