cljsrn

Paco 2023-02-10T06:11:30.712029Z

I am trying to require a JS component in the path ./componnts/Foo.js of my project and no matter what I try js/require always gets nil. @joshmiller I sqw your template uses requires stuff from js path but I cant figure our how that even works hahaha. I am not using your template I wanted to start a fresh project with newer libs and thought I could reverse engineer some of shat you do in your template I am stumped.

joshmiller 2023-02-10T16:44:38.995379Z

@kidpollo Are you using Krell?

joshmiller 2023-02-10T16:47:04.346699Z

The paths for that are a little bit non-intuitive and it took me a while to figure it out. What happens is Krell generates a file called target/krell_npm_deps.js where it requires everything it found in your cljs files. It looks like this:

module.exports = {
  krellNpmDeps: {
    "../js/src/Icons.js": require('../js/src/Icons.js'),
    "../js/src/SafeBackground.js": require('../js/src/SafeBackground.js'),
    "../js/src/AddPlace.js": require('../js/src/AddPlace.js'),

Paco 2023-02-10T16:47:50.727749Z

Yes krell

Paco 2023-02-10T16:48:03.269739Z

Sorry I did not mention that haha

joshmiller 2023-02-10T16:48:15.183709Z

So the path when you do (js/require) needs to be relative to there. I keep my JS files in a top-level js/ directory, so they all look like (js/require "../js/src/Icons.js") regardless of where in the directory tree they live.

Paco 2023-02-10T16:49:34.672539Z

Hmm yea I saw that file and it Definitely does not include my files

joshmiller 2023-02-10T16:50:48.154289Z

Hm, in that case it might not be the path, but that Krell isn’t finding it on its compiler pass… What does the js/require form look like? I have noticed it needs to be a .js file for example, Krell isn’t looking for .jsx

Paco 2023-02-10T16:53:40.985669Z

I’ve tried all the forms hahaha

Paco 2023-02-10T16:54:33.377509Z

So it happens at first pass of compiler? Do I need to restart the repl every time I add a new one?

joshmiller 2023-02-10T16:55:03.803219Z

Yeah, I don’t believe it’ll hot reload.

Paco 2023-02-10T16:55:17.250739Z

Interesante

joshmiller 2023-02-10T16:56:02.637389Z

It’s part of the setup Krell does to get the whole environment together. You can see when it happens by just seeing when that krell_npm_deps.js file is touched.

Paco 2023-02-10T16:57:12.288569Z

Ok that gives some stuff to check! Thanks @joshmiller we should have a meet up again :D

Paco 2023-02-10T16:57:51.009709Z

Im Paco Jajaj just noticed my name is not here

joshmiller 2023-02-10T16:58:12.777649Z

Yes definitely! I need to check with Puppet to see if they’ll still host. And yeah, recognized the avatar heh.

Paco 2023-02-10T16:59:06.639249Z

:)

Paco 2023-02-11T07:47:00.728449Z

yup it works the problem is I was testing my requires post compile. It wasnt clear to me :S

🙌 1