-
-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Usage from Shadow-CLJS? #64
Comments
Hi @teodorlu. Thanks for raising this issue. I would love to be able to be able to support Shadown-CLJS if possible. However, I'm a bit surprised and dismayed that it does not support CLJSJS. I know very little about Shadow-CLJS, aside from the basics, so I'm not really the person to work on this. But if someone comes up with a good way of supporting it, I'd be all ears. Does anyone know why CLJSJS isn't supported in Shadow-CLJS? Thanks again for posting |
Glad to hear you'd like to support Shadow-CLJS! I think his point is that Shadow can use NPM directly, thus doesn't need to go through Clojars. There's some discussion on this in the guide. For the record, this prompted me to swap out Shadow-CLJS for Figwheel, which I got working. From what I can understand in the Shadow CLJS guide, the user might be able to fix this by providing namespaces for A possible path to a fix could be to create the required mappings, try to get them merged into the shadow-cljsjs repo, and add a section on usage from Shadow-CLJS in the README. |
Great! Glad that you have things working with Figwheel. Looking over some of those library mappings, they seem rather straightforward. Your suggestion seems like a great path forward towards providing Shadow-CLJS support. Thanks again! |
No problem! Glad to be able to contribute. And thanks a lot for Oz -- I think you're really getting how Vega interaction from Clojure(Script) should be.
Keep up the good work! Teodor |
Hi :)
but I can live with that for the stage of my current experiments :) |
@ivanminutillo That sounds fantastic! I'll check it out when I get the chance. Do you have an opinion on how this should be presented to new users? Edit: downloaded and took it for a test run. Looks good to me, thanks for the effort!
No issues! I think it sounds reasonable to create a PR to thheller/shadow-cljsjs and create a "Usage from Shadow-CLJS README section. |
I think it is a good way to go 👍 |
Another question, if you don't mind. In your shadow-cljs.edn, you include your dependencies without ;; from shadow-cljs.edn
:dependencies [[binaryage/devtools "0.9.10"]
[proto-repl "0.3.1"]
[metasoarous/oz "1.6.0-alpha2"]
[reagent "0.8.1"]] From the reagent readme, they show how to provide "your own react version": ;; ...
[reagent "0.x.x" :exclusions [cljsjs/react cljsjs/react-dom]]
;; ... I'm asking because I really don't know. Might be able to fix that if I throw some time on it. |
Hey, sorry for late answer... I used this template to get started and as you can see there is no trace of |
No problem, open source takes time. I think my hypothesis above is right, checking now. |
@metasoarous I'm starting to feel that Oz in reality covers two use cases:
I'm going to assume that (1.) mostly is a pure data transformation. Please correct me if that isn't the case. Splitting (1.) and (2.) into separate packages would allow using (1.) without pulling in dependencies from (2.) Do you think there's any feasibility to this? Vega and React would still have to be provided. To be clear, I'm not proposing we (?) start work on this, but I'd like to know your opinion. Use case I'm thinking from: As a user, I'd like to use Oz from a normal Clojure REPL interactively, and re-use those visualizations on the web. |
@ivanminutillo, I've got some results, and a question. CLJSJS dependency exclusion
See my changes for details. shadow-cljsjs mappingsI'll create a PR to shadow-cljsjs. @ivanminutillo, this is your work, so if you'd rather have your own name in the shadow-cljsjs repo, I can delete the PR. Edit: Created the pull request. |
great work @teodorlu ! it works like a charm with :exclusions! |
Definitely interested! I can't promise that I'll a lot of time to spare, but I think ClojureScript + Vega really makes sense for data visualization. I'm experimenting with the role of the database as well -- what does it feel like to use a data model in datascript connected to visualizations in Oz? I imagine that workflow could be a nice place to work. Feel free to tag me, and we can take it from there! |
As for this thread, this is my plan:
|
Update: as of Shadow-CLJS 2.8.37 (pushed a few days ago), CLJSJS mappings for Vega and Vega-lite are provided upstream. I've updated the example project to reflect the changes. Proposal for usage instructions suitable for documentation follows below. @metasoarous feel free to copy the text below where you find it suitable in the Oz docs, and edit as you will. Thanks for the discussion with you and @ivanminutillo! With this, I'm closing the issue. Using Oz from Shadow-CLJSJSIt is possible to use Oz with Shadow-CLJSJS, but care must be taken that the right Vega and Vega-lite dependencies are provided to Oz. The Oz project depends on Vega and Vega Lite as packaged in CLJSJS. This enables Oz to be able to spin up a web server with Vega loaded from a normal Clojure application. Shadow-CLJS does not support CLJSJS, and requires JavaScript dependencies to be loadable with NPM. To use Oz from Shadow-CLJS,
Optionally, check out this example project. |
@teodorlu @ivanminutillo Epic! Thank you both so much for hashing things out with each other! Love seeing the open source juices flowing :-) I'll put these docs up on the README for now I think. May do some more detailed docs organization eventually, but while it can all fit on one page, may as well. (FWIW, the
I don't think I'm inclined to do this, at least for now. There's some benefit to having everything in one repo while things are still actively developing. I've burned myself on breaking things into too many subprojects before. And it sounds like using exclusions has solved the issues which came up above. Could perhaps use a note in the docs though.
I've been thinking about this! We've been more or less extending markdown with Vega-Lite & Vega, so why not also extend Vega-Lite & Vega with Datalog? Imagine datalog queries in your various Thanks again! |
Thanks to @teodorlu and @ivanminutillo in #64!
Sounds good, keep up the good work! On the splitting issue, I'm not so sure after a few nights of sleep. Checking out the source code for your reagent component, it's really minimal. Currently, users who would like just that part could copy out that part of the code. |
Thanks for the update. You're right, those components are pretty minimal and can be copied pretty easily for now. I do have some plans for extending the configurability of the plots via the vega-view api (plugging into Vega signal chans and the like), but also expect all of that to be pretty minimal. Once that's smoothed out, if there's enough substance there and demand for pulling out a separate lib, I'm open to revisiting. Thanks again! |
Hey @teodorlu , I attempted to load your example project, but shadow-cljs is giving me an error. I wonder if this is something you have run into before? I'm not really sure what to do to get Oz working.
|
Hey @simongray ! I don't think I've seen your error, though I haven't used Shadow-CLJS with Oz in a while. Guess: it seems like Shadow can't find |
@teodorlu But in your last commit to that example project you removed all of the shims since shadow-cljs should handle it, right? |
With some help from Thomas Heller, I managed to get it to compile by adding these two explicit dependencies to the package.json file:
They were required by other vega packages, but the latest versions of the packages (4.3.3 and 1.2.5) are both missing a file, causing the error. |
@simongray Thanks so much for poking at this. It looks like this example project is still using Thanks again! |
np! I think the problem occurs with the latest Oz too. The reason I went looking for an example project is because I have a Clojure newbie intern who ran into the same missing file error while trying to set up Oz with shadow-cljs. |
@simongray I can reproduce the error message you're getting. The example hasn't aged well! ...
[:app] Configuring build.
[:app] Compiling ...
[:app] Build failure:
override to file that doesn't exist
{:tag :shadow.build.npm/invalid-override, :require-from #object[java.io.File 0x4bd68097 "/home/teodorlu/dev/teodorlu/reagent-shadow-oz-example/node_modules/vega-dataflow/build/vega-dataflow.js"], :require "vega-loader", :file #object[java.io.File 0x6d02f66d "/home/teodorlu/dev/teodorlu/reagent-shadow-oz-example/node_modules/vega-loader/build/vega-loader.node.js"], :override "./build/vega-loader.js", :override-file #object[java.io.File 0x62851a71 "/home/teodorlu/dev/teodorlu/reagent-shadow-oz-example/node_modules/vega-loader/build/vega-loader.js"]}
ExceptionInfo: override to file that doesn't exist
shadow.build.npm/find-resource (npm.clj:735)
shadow.build.npm/find-resource (npm.clj:661)
shadow.build.resolve/find-npm-resource (resolve.clj:123)
shadow.build.resolve/find-npm-resource (resolve.clj:94)
shadow.build.resolve/fn--12497 (resolve.clj:257)
shadow.build.resolve/fn--12497 (resolve.clj:226)
... |
I can reproduce with latest versions of Oz and Shadow-CLJS too.
Yeah, that was because we got the shims merged into Shadow-CLJS itself. The Shadow-CLJS repo then contained manual mappings that allowed Clojars-libraries (like Oz) to use NPM directly rather than CLJSJS (Javascript files hosted on clojars). Not sure if Shadow-CLJS still handles CLJSJS dependencies this way. Edit: |
@simongray @teodorlu OK; Thank you both. First off, Oz uses Shadow-cljs now (as of something like Secondly, I tried adding vega-loader & vega-canvas directly to the I opened an issue over at thheller/shadow-cljs#790, and put the dep updates in the Thanks again! |
@simongray I figured out what was causing this issue. I misinterpreted your comment about about versions, and was just using the latest I've just released @simongray Did you happen to report this issue to the vega folks? Thanks again folks! |
Glad to hear that you got it working. I'll try out your new release next week and report back. I haven't contacted the Vega folks. |
@metasoarous Got it working. The intern is very happy now ;-) |
@simongray Wonderful! Happy interns are a good thing :-) I'll leave an issue for the vega folks. Thanks again folks! |
Hello!
I'm hitting some problems trying to use Oz in a Shadow-CLJS project, and I've got a question or two.
Questions
Problem description
When I added
(:require [oz.core :as oz])
to myns
form in a .cljs file, I got this error message:From what I can tell from the linked section from the Shadow-CLJS user guide,
I don't understand all the implications of the section in the guide. I guess it might be possible to install Vega and Vega-lite directly with NPM in my project and point Oz to those.
Teodor
The text was updated successfully, but these errors were encountered: