cljdoc

https://cljdoc.org/ & https://github.com/cljdoc/cljdoc
joelsanchez 2019-03-01T09:10:33.011100Z

hi πŸ‘‹ I'm requiring a namespace from an npm module loaded with shadow-cljs, what do I have to do to make it work with cljdoc?

joelsanchez 2019-03-01T09:10:41.011300Z

( https://circleci.com/gh/cljdoc/builder/2388 )

borkdude 2019-03-01T09:14:09.012600Z

(a bit off topic, but related: is shadow-cljs basically a different dialect of CLJS? what if you write a lib in that, can normal CLJS not consume it? feel free to respond on a thread)

martinklepsch 2019-03-01T09:24:00.012700Z

Hi Joel! πŸ‘‹ I think unless we switch the underlying analyzer to shadow's implementation there's nothing easy we can do here

martinklepsch 2019-03-01T09:25:07.012900Z

If this is a library I would recommend to use plain CLJS because otherwise all consumers will be required to use shadow-cljs as well (might be ok but certainly a smaller user-pool)

martinklepsch 2019-03-01T09:25:36.013100Z

Yeah, I think that's pretty much correct /cc @thheller

joelsanchez 2019-03-01T09:46:49.013400Z

it's not a library, the cljs files can be used by child projects but it's not their main usecase. in this case the cljs is the backoffice of an ecommerce site, and this dependency is only going to be used to build sites /extend the software

joelsanchez 2019-03-01T09:47:08.013600Z

but, can the cljs be ignored? so that my clj sources are analyzed and the documentation is picked up

joelsanchez 2019-03-01T09:47:19.013800Z

don't care that much about the cljs part, it's not documented anyway

joelsanchez 2019-03-01T09:49:25.014100Z

also can it stop using the dev profile?

martinklepsch 2019-03-01T09:54:42.014300Z

@joelsanchez there's no concept of profiles in cljdoc's analyzer. We look at a projects pom file (http://repo.clojars.org/ventas-core/ventas-core/0.0.13/ventas-core-0.0.13.pom) and try to include some additional dependencies that a project might need. Eg. some namespace might need core.async but it's expected that the user provides it. Often these kinds of dependencies can be found in the pom with <scope>test</scope> etc

joelsanchez 2019-03-01T09:55:14.014500Z

ah sorry. so can the cljs files be ignored?

martinklepsch 2019-03-01T09:55:19.014700Z

selecting platforms isn't supported for users at this stage but I can hardcode it for you if you want

joelsanchez 2019-03-01T09:55:33.014900Z

well, sure πŸ™‚

martinklepsch 2019-03-01T09:55:34.015100Z

(have done so for other projects, would be no problem)

martinklepsch 2019-03-01T09:56:05.015300Z

"ventas-core/ventas-core" is correct?

joelsanchez 2019-03-01T09:56:20.015500Z

no, just ventas-core

joelsanchez 2019-03-01T09:56:46.015700Z

I should have called it joelsanchez/ventas-core but I haven't. so...

martinklepsch 2019-03-01T09:56:48.015900Z

ok (that's the same)

martinklepsch 2019-03-01T09:57:27.016100Z

Maven has group and artifact IDs. In Clojure when you have a project ID that doesn't contain a / it implies that they're both the same

joelsanchez 2019-03-01T09:58:41.016500Z

learning every day... πŸ˜›

martinklepsch 2019-03-01T10:01:33.016700Z

πŸ˜„

martinklepsch 2019-03-01T10:01:57.016900Z

didn't know this for a long time either (and it's not really all that useful to know hahaha)

thheller 2019-03-01T10:44:58.017100Z

no that is incorrect. shadow-cljs is a build tool for clojurescript. the language stays the same with one little exception: https://dev.clojure.org/jira/browse/CLJS-2376 this is already implemented

borkdude 2019-03-01T10:46:03.017300Z

And this is the exception Joel runs into I guess?

thheller 2019-03-01T10:46:26.017500Z

reading ...

thheller 2019-03-01T10:49:14.017700Z

nope that is completely standard. I'm guessing that the npm dependencies just aren't installed?

borkdude 2019-03-01T10:54:01.017900Z

^ @joelsanchez

thheller 2019-03-01T10:57:29.018100Z

@martinklepsch this should work fine if you respect deps.cljs and install the dependencies listed there

martinklepsch 2019-03-01T10:58:34.018300Z

yeah, I guess that's the issue then

martinklepsch 2019-03-01T10:59:09.018500Z

Sorry for the confusion here @thheller and thanks for chiming in

thheller 2019-03-01T10:59:55.019Z

this might work?

thheller 2019-03-01T11:00:30.019200Z

the problem is that CLJS needs to index the node_modules directory to understand that "react-color" is a npm dependency.

thheller 2019-03-01T11:01:16.019400Z

I'm not sure if there is a setting to just make it ignore any string deps? I think :target :nodejs does something to that extent? I'm not actually sure how any of this works in default CLJS anymore

thheller 2019-03-01T11:01:54.019600Z

since you only analyze and not actually compile it would be fine to just ignore the string deps and treat them as a plain JS object

thheller 2019-03-01T11:07:29.019800Z

you could probably add something that doesn't actually require installing the deps

joelsanchez 2019-03-01T11:08:06.020Z

node_modules is gitignored so they won't be installed by default

joelsanchez 2019-03-01T11:08:17.020200Z

there is a package.json with react-color and the other deps though

borkdude 2019-03-01T11:08:38.020400Z

I guess cljdoc would have to install them?

joelsanchez 2019-03-01T11:09:17.020600Z

sorry, git is irrelevant, but node_modules is not inside resources and not in the artifact at all

thheller 2019-03-01T11:09:17.020800Z

I should have some time tomorrow, maybe I can figure something out that cljdoc parses these properly

martinklepsch 2019-03-01T11:09:18.021Z

Thomas gave some more context on that in the other thread

martinklepsch 2019-03-01T11:09:44.021200Z

that would be super nice πŸ™‚ otherwise I might get to it eventually πŸ™‚

borkdude 2019-03-01T11:10:27.021400Z

πŸ‘

joelsanchez 2019-03-01T11:11:40.021600Z

thank you both @thheller @martinklepsch for your help and for your outstanding projects

thheller 2019-03-01T11:12:31.021800Z

@martinklepsch can you point me to the code that does the analysis? the function that starts it all?

martinklepsch 2019-03-01T11:15:32.022300Z

That namespace has a -main. What you'll need to do to play with that is: 1. Unpack the contents of the dependency's jar into a directory 2. Add it as a dependency to the local deps.edn then you should be able to run something like clj -m codox.main clojurescript jar-contents-dir

martinklepsch 2019-03-01T11:15:54.022600Z

It's a little fiddly, let me try to push a commit with some inline docs/pointers for this

thheller 2019-03-01T11:20:03.022800Z

its fine. already saw what I needed πŸ˜‰

thheller 2019-03-01T16:26:34.023200Z

finally finished writing that blog post I've been thinking about for a while ... maybe it clears up some of the confusion: https://code.thheller.com/blog/shadow-cljs/2019/03/01/what-shadow-cljs-is-and-isnt.html

borkdude 2019-03-01T17:30:37.023500Z

One thing I didn’t get is that you’re referring above to CLJS-2376 which introduces this string syntax in require, and that shadow-cljs already implements this. But CLJS-2376 is not yet in CLJS master it seems, so the language is in that aspect still different?

thheller 2019-03-01T17:37:45.023800Z

CLJS-2376 introduces :default not the string requires. string requires have been implemented for a while

borkdude 2019-03-01T17:39:05.024Z

ok thanks

thheller 2019-03-01T19:23:44.025100Z

@martinklepsch I made some adjustments to the codox stuff so that string requires work without actually having to install npm dependencies. https://gist.github.com/thheller/5bc57a7571cf83fd12190ab7165cdb46

thheller 2019-03-01T19:24:16.025800Z

the main difference is that the compiler state is only created once in read-namespaces instead of re-creating it all the time

thheller 2019-03-01T19:24:29.026100Z

as that re-analyzes all the deps all the time

thheller 2019-03-01T19:25:40.026600Z

problem is that it won't fix (:require [react-color ...]) since its a symbol

thheller 2019-03-01T19:26:07.027200Z

another strategy could be reading all deps.cljs files for :npm-deps and creating the fake :js-module-index entry for each (maybe package.json too)

thheller 2019-03-01T19:26:23.027500Z

then the symbol would work too