This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-08-22
Channels
- # babashka (2)
- # beginners (81)
- # calva (5)
- # chlorine-clover (3)
- # cider (1)
- # cljsjs (1)
- # cljsrn (24)
- # clojure (67)
- # clojure-europe (3)
- # clojurescript (37)
- # code-reviews (2)
- # conjure (12)
- # core-async (4)
- # datalog (1)
- # datomic (6)
- # emacs (2)
- # figwheel-main (1)
- # graalvm (12)
- # java (4)
- # kaocha (9)
- # meander (3)
- # other-lisps (1)
- # pathom (14)
- # re-frame (2)
- # sci (32)
- # shadow-cljs (77)
- # sql (88)
- # xtdb (54)
Hi, I am using shadow-cljs via leiningen. Everything works perfectly, except when I do lein uberjar
I get the following error
Can't find 'shadow.cljs.devtools.cli' as .class or .clj for lein run: please check the spelling. Syntax error (FileNotFoundException) compiling at (/tmp/form-init11854498876761345265.clj:1:74). Could not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath.
:cljs {:source-paths ["src/cljs"]
:dependencies [
[org.clojure/clojurescript "1.10.773" :scope "provided"]
[com.google.javascript/closure-compiler-unshaded "v20200719"]
[org.clojure/google-closure-library "0.0-20191016-6ae1f72f"]
[thheller/shadow-cljs "2.10.22"]
[reagent "0.8.1"]
[re-frame "0.10.7"]
[kibu/pushy "0.3.8"]
[fork "2.0.0"]
[vlad "3.3.2"]
[day8.re-frame/http-fx "v0.2.0"]]}
:uberjar
{:resource-paths ["resources" "resources/sql"]
:source-paths ^:replace ["src/clj" "src/cljc"]
:prep-tasks ["compile"
["run" "-m" "shadow.cljs.devtools.cli" "release" "app"]]
:hooks []
:omit-source true
:aot :all}})
here are the profiles entries in my project.clj. If I run lein run -m shadow.cljs.devtools.cli release app
manually in a console, everything works fine.i think i know what's wrong, i need to activate the cljs profile, using with-profile...tried this :prep-tasks ["compile" ["with-profile" "+cljs" "run" "-m" "shadow.cljs.devtools.cli" "release" "app"]]
`
Solved: I just had to :prep-tasks ["compile"
["with-profile" "cljs"
["run" "-m" "shadow.cljs.devtools.cli" "release" "app"]]]
The app I've been working on for a while is getting a bit big (19MB...) I decided to try out the release
so closure compiler can do its thing. Brought it down to 11MB, still not great. Running gzip on that brings it down to 1.6MB, which I find acceptable for the interactive app that it is.
Was expecting to run into a lot of trouble with advanced compilation but after a few minor issues it actually seems to go well. The only thing I'm not sure about is some es6 files that I ran through babel, closure doesn't like em:
Closure compilation failed with 4 errors
--- kr/models/ronde-tempel-compiled.js:6
Cannot import Closure files by path. Use either import goog:namespace or goog.require(namespace)
..
@bbss yeah there seems to be an issue with handling .js
files. still haven't figured out what the problem is though.
alright, well if there's anything I can do to test let me know. Other .js
files seem to load okay, but the ones I ran manually through babel don't, they work in watch
build though.
These files that don't load are https://github.com/react-spring/gltfjsx output of this. After which I run it through babel. They turn a webGL file into a react class.
@thheller Q for you about packaging a cljs dependency for shadow-cljs compatibility if you have a second - I previously had packaged "fraction.js" in cljsjs, using your advice, and that is working great
but the npm package has a bigfraction.js
living inside of it too, that I'd love to package up as a different dependency
When I built the fraction.js package you had noted I needed a :global-export
entry that matched the NPM package, which I did and again that works great: https://github.com/cljsjs/packages/blob/master/fraction/build.boot#L35
but what to do for an NPM dependency that packages up TWO files, with two identical namespaces? Do I make them... both export "fraction.js", and then this is on the user to only include one of
cljsjs/fraction` vs cljsjs/bigfraction
?
that would work, but I wanted to check before I contribute to someone else's dependency issues down the road. Thanks anyone who has insight here!
@sritchie09 your question is confusing. I'm assuming there is a fraction.js
npm package and a bigfraction.js
? thats all shadow-cljs needs to know. it doesn't even look at :foreign-libs
for anything
Thereโs not a bigfraction.js
@thheller I think he just packages that file inside fraction.js
and then tests it like this
maybe it's a work in progress, and the answer is to publish it separately using cljsjs and alias it as bigfraction?
oh, nice, amazing
@thheller I suspect I can do this trick:
https://github.com/cljsjs/packages/blob/master/fraction/resources/package.json#L32
but bundle bigfraction.js
instead, and then do this in build.boot
:
(deps-cljs :provides ["fraction.js/bigfraction.js", "cljsjs.bigfraction"]
:requires []
:global-exports '{fraction.js/bigfraction.js Fraction
cljsjs.bigfraction Fraction})
if that works, with the funky provides, then that should be shadow-cljs compatible, yeah?
I would go all shadow-cljs, but I haven't converted our build yet
and it would be nice if non-shadow folks could use my library as a dependency
yes, that's right
astonishingly it works
For sure - I think my aliases cover this
oh I see you mean in the bundle phase
Yes good call, Iโll rename the bigfraction to BigFraction when I run the bundler
Thanks @thheller !
Hi, I'm using d3.js (third party js lib from npm)
I'm using its line
function but I'm getting error curve is not a function
in line 23
https://github.com/d3/d3-shape/blob/master/src/line.js#L23
However, I can see that it is defined in line 10
https://github.com/d3/d3-shape/blob/master/src/line.js#L23 (just few lines above its usage)
Is this related to shadow-cljs?
Here is snippet of how I use the line function
line (-> d3
(.line)
(.curve (.curveNatural d3))
(.defined #(not (js/isNaN (.-value %))))
(.x #(x (.-date %)))
(.y #(y (.-value %))))
_ (-> svg
(.append "path")
(.datum data)
(.attr "fill" "none")
(.attr "stroke" "green")
(.attr "stroke-width" 1.5)
(.attr "d" line))
EDIT:
Looking at the file generated by shadow for d3.js. The error is in line 349
in the attached snippet@jaime.sangcap you are looking at something completely irrelevant ๐
curve = curveLinear,
means its just a rename for some reason and the actual function is coming from import curveLinear from "./curve/linear.js";
or I don't follow your problem ... d3 went through a whole lot of changes in the various versions
so without seeing an actual full example I can only assume that you are using it wrong
Fair point ๐ I might be doing it wrong. I will try to create a repo to reproduce the issue
@thheller The error changed a bit when I try to reproduce it in this repo https://github.com/jaimesangcap/repro-cljs-d3
app.js:2226 failed to load shadow.module.app.append.js TypeError: curve is not a function
at SVGPathElement.line (d3-shape.js:349)
at SVGPathElement.eval (d3-selection.js:399)
at Selection.each (d3-selection.js:366)
at Selection.attr (d3-selection.js:423)
at Object.repro_cljs_d3$core$init [as init] (core.cljs:77)
at eval (shadow.module.app.append.js:4)
at eval (<anonymous>)
at Object.goog.globalEval (app.js:836)
at Object.env.evalLoad (app.js:2224)
at app.js:2404
Probably I'm missing some configuration?I mean d3 got split up into a lot of smaller packages quite a while ago. are you sure that fn isn't supposed to be in one of those instead of the generic d3
?
curveBasis: (...)
curveBasisClosed: (...)
curveBasisOpen: (...)
curveBundle: (...)
curveCardinal: (...)
curveCardinalClosed: (...)
curveCardinalOpen: (...)
curveCatmullRom: (...)
curveCatmullRomClosed: (...)
curveCatmullRomOpen: (...)
curveLinear: (...)
curveLinearClosed: (...)
curveMonotoneX: (...)
curveMonotoneY: (...)
curveNatural: (...)
curveStep: (...)
curveStepAfter: (...)
curveStepBefore: (...)
I saw the curve
example in the readme https://github.com/d3/d3-shape#curves
When using the generic d3
lib and use the line, I can draw a line chart, but the connection between the line/path are sharp. So I tried applying the curve
function, but I'm getting the error above.
Using the d3-shape
gives the same error.
I probably need to spend some time reading the docs and code
Requiring the d3-shape
as mentioned above throws error as well when calling the (.curve)
line (-> (d3s/line)
(.curve (.curveNatural d3))
(.defined #(not (js/isNaN (.-value %))))
(.x #(x (.-date %)))
(.y #(y (.-value %))))
app.js:2226 failed to load shadow.module.app.append.js TypeError: curve is not a function
at SVGPathElement.line (d3-shape.js:349)
at SVGPathElement.eval (d3-selection.js:399)
at Selection.each (d3-selection.js:366)
at Selection.attr (d3-selection.js:423)
at Object.repro_cljs_d3$core$init [as init] (core.cljs:76)
at eval (shadow.module.app.append.js:4)
at eval (<anonymous>)
at Object.goog.globalEval (app.js:836)
at Object.env.evalLoad (app.js:2224)
at app.js:2427
If I understand the d3-shape
code in line 10
https://github.com/d3/d3-shape/blob/master/src/line.js#L10, it creates a var curve=curveLinear
, which will be called later in the closure line 23
, but it seems like by the time the closure get invoked, it throws an error that var curve
declared in line 10
is not a function.I added breakpoint here https://github.com/d3/d3-shape/blob/master/src/line.js#L23
and the value of var curve
is Natural
which is this file https://github.com/d3/d3-shape/blob/master/src/curve/natural.js
I made a dumb interop mistake. I was invoking the function instead of property access ๐
What I'm doing (just dot)
(.curve (.curveMonotoneX d3))
Correct way (dot hyphen)
(.curve (.-curveMonotoneX d3))