Fork me on GitHub
#cljsrn
<
2023-02-10
>
Paco06:02:30

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.

joshmiller16:02:38

@U06UBQ4TH Are you using Krell?

joshmiller16:02:04

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'),

Paco16:02:50

Yes krell

Paco16:02:03

Sorry I did not mention that haha

joshmiller16:02:15

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.

Paco16:02:34

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

joshmiller16:02:48

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

Paco16:02:40

I’ve tried all the forms hahaha

Paco16:02:33

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

joshmiller16:02:03

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

Paco16:02:17

Interesante

joshmiller16:02:02

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.

Paco16:02:12

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

Paco16:02:51

Im Paco Jajaj just noticed my name is not here

joshmiller16:02:12

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

Paco07:02:00

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

🙌 2