Fork me on GitHub

An unrelated question - have you ever tried making build report into a visual graph? Feels like it would be useful to figure out not only where something came from (which I already can do, but in a somewhat tedious way), but also what something brings with it. Handy when you're trying to decide how to split your sources into modules.


I have tried, but didn't find anything useful at all. just visual mess. the table just ended up the cleanest and most useful


and this radial thing


> but in a somewhat tedious way


whats tedious about it?


I'm open to suggestions or examples, just didn't find anything that wasn't completely useless yet


which was the closest to useful, but still overall less useful than just a table


The first and the second links wouldn't work for what I'm describing because they show only the "contains" relationship, without "requires". And the third one... I don't even know. Why would laying a graph on a flat line be more useful than just showing the graph? Of course, I might be overly optimistic, but I think there should be a set of parameters that would allow for a neat and useful layout of such a graph. Pretty sure I've seen things like it before, although can't remember exactly. > whats tedious about it? Compared to a clean visualization, table data containing relationships is harder to read. Might be a personal thing, of course, and it assumes a clean visualization, which might not be possible here. Is there a public project where, you think, having a clean diagram would be a proper showcase that such a feature is useful? If I end up experimenting, don't wanna deal with synthetic or private projects.


the shadow-cljs ui itself comes to mind, not very large but public 😉


thats the data the report is generated from, if you want to experiment I'd start there.


otherwise larger public projects would be logseq and penpot, both use shadow-cljs already


I have never seen a good visualization for dependency graph for ANY system/language that scales properly, ie. doesn't become incomprehensible in larger projects. I assume if it was easy there'd be more examples online.


totally curious to see what you come up with though. Table for me just was the "good enough" compromise and I don't particularly like frontend work, so I stopped there.


Is it possible to import a class from a js file? More concretely the JS file has something like

export default class Foo {
  // ...
I seem to be able to import the class from CLJS but I simply get an empty object returned, and (new Foo) returns an exception


you are likely just not accessing the default export properly


otherwise yes, you can access JS classes like that


Okay, it looks like I’ve narrowed down my problems further. It seems that shadow-cljs has trouble with some auto-generated JS files from ANTLR v4, but I’m not sure why. There is an antlr4 module that has named exported and default exports. In particular, there is an atn symbol exported from antlr4 . In a REPL, I can see it just fine:

cljs.user> antlr4/atn
{"ATN" #object[t$jscomp$0],
 "ATNDeserializer" #object[t$jscomp$1],
The auto-generated JS file I am requiring from CLJS starts with something like this
import antlr4 from 'antlr4';
// ...
const atn = new antlr4.atn.ATNDeserializer().deserialize(serializedATN);
and for some reason antlr4.atn is undefined in the JS file. Yet in CLJS when I (require '["antlr4$default" :as antlr4]), I can access atn just fine.


I do not follow


please provide the full error you get, and the code that code you there. those snippets mean nothing without context


an example repo would help


are you trying to include the generated JS file via


That is correct. I’ll create a tiny repo with an example soon


note that this is still a rather experimental feature and has a gazillion issues when trying to interface with npm packages directly, especially if its ESM code. if you can convert that code to commonjs you might have more luck


Here is the example — it has some auto-generated JS and a very tiny CLJS namespace. Also tried keeping the shadow-cljs.edn as small as possible


what am I supposed to see? I only see a hello world in the console?


Uncomment the require s in


The first commented require is sufficient to uncomment. It will demonstrate the error I described above


yeah, this is what I mean. the trouble is that commonjs/esm interop


can you tell antlr to generate commonjs code?


I’ll try looking into that. Otherwise, I will attempt using webpack to output CJS code. I know one CLJS library does this (parcera)


in general it doesn't look like you are going to need access to CLJS code from these generated files


so I suggest a different strategy


create a packages/my-generated-code directory. put all generated code there, also create a package.json there. just npm init -y is fine


then in your build config :js-options {:js-package-dirs ["node_modules" "packages"]}}


in cljs then just (:require ["my-generated-code/theFile" :as x])


this basically sets the code up to be treated like any other npm package


and won't keep into in the advanced compiled parts of the build


I’ve just tried your suggestions and they work flawlessly. Thank you so much!


Hours of debugging alone did nothing and now everything works perfectly. I’m okay with lack of advanced optimization because all of the auto-generated files are being used and there is nothing to tree-shake out of them 🙂