Fork me on GitHub
#shadow-cljs
<
2020-01-31
>
David Pham07:01:36

Try to compile into es6 by setting the argument in your shadow-CLJS.edn file

David Pham07:01:58

(Maybe update to 2.83?)

thheller09:01:44

@jmckitrick that is caused by you using project.clj or deps.edn and not having the correct closure-compiler version (ie. dependency conflict). you need to resolve this, you should have

[com.google.javascript/closure-compiler-unshaded "v20191027"]

   [org.clojure/google-closure-library "0.0-20191016-6ae1f72f"]
   [org.clojure/google-closure-library-third-party "0.0-20191016-6ae1f72f"]

thheller09:01:14

I think its time I write this down somewhere ... getting tired of repeating it ... why does everyone insist on using lein/deps.edn?

thheller10:01:58

(note that the version changes between shadow-cljs versions, so if you have one pinned you must make sure it matches) ... or just use shadow-cljs.edn ....

David Pham10:01:37

deps.edn allows local libraries or git libraries

thheller10:01:47

yeah I know

Jakub Holý (HolyJak)11:01:21

Hi! In JS I can do const logo = require('../../media/logo.svg'); and then use logo as html (e.g. in React's dangerouslySetInnerHTML={{ __html: logo }). What to people do in Cljs / shadow? I guess it is not supported to require a non-cljs resource. Thank you!

4
Jakub Holý (HolyJak)12:01:45

@U05224H0W I have been searching the Dev Guide for how to embed non-code resources but couldn't find anything. Is shadow.resource/inline not mentioned there or have failed to search well? Perhaps "Table 1. ES6 Import to CLJS Require " could be extended to point to a description of this as people use in JS import/require for non-code resources? Or add a section between 12.2 and 12.3 (12.25 :)) called "Embedding resources from files"?

thheller12:01:07

what you are looking for isn't about embedding

thheller12:01:55

the require('../../media/logo.svg') pattern is something from webpack and not supported by shadow-cljs in any way

👍 4
thheller12:01:49

yes, the inline stuff can be used to inline svg but that only works for svgs

Jakub Holý (HolyJak)13:01:57

Wouldn't it work also for CSS? I.e. anything text-based? IF it was an image I guess I would also need to run it through base64 and thus write my own include macro anyway?

thheller13:01:06

yes and no. in the case of webpack it will collect all the required css files and then create one final css file with all of them combined

thheller13:01:13

the source is rarely inlined into the build

thheller13:01:58

the images in general it usually just returns the path and copies to actual file to the path it returned

thheller13:01:30

inlining actually only happens if you configure webpack to do so

jmckitrick12:01:27

I’m perfectly happy using a better method, as long as I can build an uberjar with the result. Is there a better way?

jmckitrick12:01:51

I had removed the shadow code from the project.clj, but put it back for building the uberjar.

thheller12:01:43

@jmckitrick shadow-cljs release app && lein uberjar would be my recommendation. I really don't see the point lein doing everything but some people prefer that.

jmckitrick12:01:53

Hmm, that’s what I was doing.

jmckitrick12:01:48

Let me try again, and post the results here.

jmckitrick12:01:39

~/d/b/bank1 ❯❯❯ shadow-cljs release app                                                                                                                                ⏎ master ✱
shadow-cljs - config: /Users/jmckitrick/devel/bank/bank1/shadow-cljs.edn  cli version: 2.8.69  node: v13.7.0
shadow-cljs - running: lein run -m shadow.cljs.devtools.cli --npm release app
NPM version conflict for "react" in deps.cljs (will use A)
A: "16.8.6" from jar:file:/Users/jmckitrick/.m2/repository/re-frame/re-frame/0.10.9/re-frame-0.10.9.jar!/deps.cljs
B: "16.9.0" from jar:file:/Users/jmckitrick/.m2/repository/reagent/reagent/0.9.0-rc3/reagent-0.9.0-rc3.jar!/deps.cljs
NPM version conflict for "react-dom" in deps.cljs (will use A)
A: "16.8.6" from jar:file:/Users/jmckitrick/.m2/repository/re-frame/re-frame/0.10.9/re-frame-0.10.9.jar!/deps.cljs
B: "16.9.0" from jar:file:/Users/jmckitrick/.m2/repository/reagent/reagent/0.9.0-rc3/reagent-0.9.0-rc3.jar!/deps.cljs
[:app] Compiling ...
IllegalArgumentException: No matching field found: getSourceName for class com.google.javascript.jscomp.JSError

thheller12:01:39

as I said before. you are running through lein. so YOU must ensure that the shadow-cljs version in project.clj gets the matching closure-compiler version it expects

thheller12:01:09

from the looks of it you actually have a newer version of shadow-cljs in project.clj, not .69.

jmckitrick12:01:16

Ok, let me fix that.

jmckitrick12:01:29

But I wasn’t using lein there…

jmckitrick12:01:33

I used it for setup

thheller12:01:35

> shadow-cljs - running: lein run -m shadow.cljs.devtools.cli --npm release app

thheller12:01:52

if :lein is configured in shadow-cljs.edn it will use lein to run things

jmckitrick12:01:24

I see… lein true

thheller12:01:44

if you remove that it will run shadow-cljs directly without lein

thheller13:01:02

BUT then you must move your dependencies and source-paths into shadow-cljs.edn as well

jmckitrick13:01:37

Ok, I think that’s the next step. I thought it was solved when I just deleted the shadow keys from project.clj

jmckitrick13:01:12

I will come back to this. As long as I know I can get an uberjar for prod deployment, I can revisit the topic later.

jmckitrick13:01:24

Thanks for you help, meanwhile!

thheller13:01:07

uberjar will just copy all the files in the paths you have configured

jmckitrick13:01:13

The build did get farther, but broke looking for the correct namespace. I assume that’s what you were referring to, with setting up shadow-cljs.edn correctly with dependencies and paths.

thheller13:01:17

so if you have shadow-cljs output the files into a dir you want packaged

thheller13:01:21

then it'll just work

thheller13:01:35

yes, source-paths

jmckitrick13:01:14

I think I’ll start over, and begin with reading the manually entirely 😉

rberger18:01:56

Are there any examples or articles on building :chrome-extension with shadow-cljs? I couldn't find any so far. Thanks!

thheller20:01:59

the fulcro-inspect extension uses it

rberger20:01:17

Thanks, saw the issues but will check out the fulcro-inspect, that should help... Also want to thank you so much for shadow-cljs. It really makes Clojurescript work wonderfully! Really helped in allowing us to take advantage of things like AWS Amplify: https://dev.to/rberger/aws-amplify-and-clojurescript-re-frame-part-1-3d3f

👀 4
👍 8
🙌 4
rberger20:01:33

Couldn't have made that work without shadow-cljs