Is this just a Node thing I should be aware of or is it peculiar to squint: I've got a .cljs file in a src/ directory in my project. If I eval this form
(fs/readFileSync "src/lib/assets/doc.org" "utf8")
It loads the file. But if I try "./lib/assets/doc.org" as the path, it return ENOENT. I just tried this directly in a Node REPL and...the opposite is true. Using a relative path works, using the same path as in CLJS throws.Did you mean "./src/lib/assets/..."?
If I type "./src/lib/assets/doc.org", that also works, but using "./lib/assets/doc.org" does not. Unless I am mistaken about how this stuff works in general (maybe a path expansion thing, idk), it seems to me that, given the location of the .cljs file (under src/), the second path should work, but not the first
if the CLJS file is in the src/ dir, how/why would prepending src to the path be correct?
Your code: (fs/readFileSync "src/lib/assets/doc.org" "utf8")
Seems like (fs/readFileSync "./src/lib/assets/doc.org" "utf8") should work too?
Does (fs/readFileSync "lib/assets/doc.org" "utf8") work?
(this feels like classpath vs regular filepath)
it does indeed, and that's precisely what is confusing to me: why does writing (in Node directly)
fs.readFileSync("./lib/assets/doc.org", "utf8")
load the file, but that same path throws in squint?It does not
Just look at the expansion of the code in the output
Could be a bug in squint but it's JS at the end anyway so you are able to look
The relative path is relative to the written JS file
So you have to also write the org file to the output dir, which you can do using. A squint.edn setting
Or you can set the output dir to src
filed an issue about the other thing
I didn't get chance to look at compiled output yet, sorry, but for context this issue was cropping up running npx squint repl in inf-clojure. I guess that does make it sort of a "classpath" problem, right? Because squint is considering the directory with my package.json to be the root?
@bhlieberman93 perhaps you can make a tiny github repro project with a repro in the README, then it's easier to talk about this
@bhlieberman93 how do you “connect” to the REPL from your editor? Which editor do you use?
Emacs
and inf-clojure
I'm going to reply to this but I'm working on a new bb release first
I looked more into this. One solution could be to use js/import.meta.url which is kind of the *file* equivalent of JS, but this doesn't always work in a REPL since there's no physicial file attached there.
The more robust solution in Node.js would be to look at the current working directory:
(fs/readFileSync (path/join (js/process.cwd) "src/lib/assets/sample.org") "utf8")
thanks for taking a look.