Namespace recognition
piotr-yuxuan opened this issue · 2 comments
Hiya,
Thank you so much for such the amazing tool you give us :-)
I recently stumbled upon a behaviour I'm not sure about: is it a bug? whose bug is it? Possible culprits are likely to be:
- the chair/keyboard interface if I'm misunderstood something about file naming rules;
- Figwheel if it's too lax about naming rules;
- Dirac if it makes too strong assumption about file names;
- anybody else?
Minimum working example
src
├── clj
│ └── example
│ └── core.clj
└── cljs
└── example
├── core.cljs
├── stuff.cljs
└── stuff
└── utils.cljs
src/cljs/example/stuff/utils.cljs
(ns example.stuff.utils)
(defn func [] (println "called"))
src/cljs/example/stuff.cljs
(ns example.stuff
(:require [example.stuff.utils :refer [func]])
Minimum non working example
src
├── clj
│ └── example
│ └── core.clj
└── cljs
└── example
├── core.cljs
├── stuff.cljs
- └── stuff
- └── utils.cljs
+ └── stuff.utils.cljs
Anything else keeps the same. In such a situation Dirac says:
Internal Dirac Error Could not load content for http://localhost:3450/js/compiled/out/example/stuff/stuff.utils.cljs?rel=1488395299320 : HTTP status code: 404
Dirac v1.1.6, Chrome/58.0.3026.3, Mac/10.12.2, Backend API/external/465, Backend CSS/external/415
An error was logged into the internal DevTools console:
| Could not load content for http://localhost:3450/js/compiled/out/example/stuff/stuff.utils.cljs?rel=1488395299320 : HTTP status code: 404
---
To inspect the problem in internal DevTools => https://goo.gl/0FkZ1o
Consider reporting the issue here: https://github.com/binaryage/dirac/issues
I think some other person reported a similar issue in #dirac channel in Clojurians Slack, I don't know what the real issue is. Just today one person hit a (probably unrelated) issue that out/something
was created as a file for some reason and that blocked ClojureScript compiler from creating generated files under namespace (folder) with the same name. He was getting the same "Could not load content" errors in Dirac, because out was partially populated with some files, but other cljs files were missing.
The problem you have seems to be a mismatch between naming files in filesystem and namespace structure. In that case the behaviour is undefined. ClojureScript compiler might work and do something reasonable, but for example Figwheel could have troubles or source-maps won't refer to correct paths, etc.
Why do you think that a file named stuff.utils.cljs
with (ns example.stuff.utils)
should work? I believe this is not supposed to work. Namespace names and folder structure must match exactly.
Why do you think that a file named stuff.utils.cljs with (ns example.stuff.utils) should work? I believe this is not supposed to work. Namespace names and folder structure must match exactly.
OK got it. Indeed my assumption is false: folder and namespace structures must match. Sorry for the disturbance! You can close this issue if you want as it's nothing to do with Dirac.