Fork me on GitHub
#shadow-cljs
<
2018-09-04
>
ghiden02:09:05

can a shadow-cljs project produce a jar file without js dependencies? What I want to do is from one project, I want to produce a NPM package for js projects and cljs jar package for cljs projects.

ghiden02:09:08

For cljs projects to fill out the js dependencies, I was thinking I could use the webpack method that described here https://clojurescript.org/guides/webpack

lilactown03:09:07

shadow-cljs doesn’t currently have a way of creating a jar AFAIK. I usually use a very minimal project.clj and use leiningen to create a jar + publish it

👍 4
thheller07:09:11

@ghiden CLJS packages are just uncompiled .clj(s|c) files. you never ship compiled CLJS code to other CLJS users. so any method of producing/publishing a jar file it valid you do not need shadow-cljs for that, although it will likely get support for it at some point.

ghiden07:09:32

i guess the last piece that i need to figure out is whether cljs projects can use webpack to load the npm dependencies required by the published package

thheller07:09:07

for now my recommended path is to use the cljsjs compatibility layer instead

thheller07:09:43

since the webpack part requires additional work on the lib consumer side

thheller07:09:30

its not an ideal solution either though

exit212:09:51

I have a node module that I’ve installed into an existing clj/cljs project that uses lein. I’m having some issues getting things to compile, would shadow-cljs be helpful for my scenario? I already have an existing build system, so I don’t want to replace that but if they could live in harmony together that would be ideal 🙂

thheller12:09:54

not sure I understand the question. shadow-cljs is a build tool so you are going to replace your existing build system if you use it. it is however fine to use it from lein.

exit212:09:33

right now Im trying to follow the https://clojurescript.org/guides/webpack guide, and things aren’t working out for me

exit212:09:43

my node module is a React component that I’ve built and put on NPM

exit212:09:13

so when I try to fire everything up I get some issues around React not being available

exit212:09:14

Uncaught ReferenceError: module$react is not defined

exit212:09:30

so I was wondering if some how including shadow-cljs can help me with these issues

thheller12:09:42

sorry can't help you troubleshoot the webpack setup. don't know anything about it.

thheller12:09:59

but with shadow-cljs you just npm install the-thing and (:require ["the-thing" :as x])

exit212:09:38

the only reason I think I was pointed to the webpack guide is because I’m using webpack to build my React component, but I don’t think those things should be related

exit212:09:10

do you have documentation on how I should integrate this with lein?

thheller12:09:35

I recommend first starting without lein

thheller12:09:43

figure out how things work. then integrate it into lein

thheller12:09:08

ie. npx create-cljs-project test-project cd test-project npm install your-thing

exit212:09:43

got it, so understand how things work in isolation before trying to integrate it into my existing stuff

thheller12:09:42

well you can use your actual code if you want to. that is not a problem

thheller12:09:01

just don't do it via lein

thheller12:09:09

FWIW you might be able to skip the publish to npm part completely and just consume the code directly via https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js

Hukka13:09:11

@thheller Late congrats on the clojurists together funding (I'm back from a break)

ikitommi13:09:05

much better perf out-of-the-box and supports optional byte[] responses, than enable NIO in some servers

kenny16:09:44

I started shadow-cljs fresh this morning and was receiving this message:

------ ERROR -------------------------------------------------------------------
09:29:53 cljs |  File: /home/kenny/compute_software/ui-frontend/src/compute/ui_frontend/components/constructors.cljs
09:29:53 cljs | Exception: No namespace: compute.ui-frontend.components.constructors found
The constructors ns follows the two ns pattern for exposing macros - there's a constructors.clj and a constructors.cljs. I had forgotten to remove a reader conditional from my constructors.clj file which caused that error. Once I fixed it the error went away. If I add the misplaced reader conditional back in after the initial compile, I get a much better error:
09:30:43 cljs | [2018-09-04 09:30:43.832 - WARNING] :shadow.cljs.devtools.server.reload-macros/macro-reload-ex - {:ns-sym compute.ui-frontend.components.constructors}
09:30:43 cljs | CompilerException java.lang.RuntimeException: Conditional read not allowed, compiling:(compute/ui_frontend/components/constructors.clj:9:3)

kenny16:09:02

It'd be nice if the latter error was printed instead of the obtuse first one.

Josh Horwitz20:09:57

I’m looking to use an Ant design library with my shadow app, would it be best to use the antd react package from NPM or https://github.com/priornix/antizer which is a clojurescript lib

lilactown20:09:06

antizer looks nice. the only thing to note is that you might have some additional steps since it uses cljsjs

Josh Horwitz20:09:40

Thanks! I’ll try and go the antizer route since I know it already

thheller20:09:09

I really don't recommend using wrappers like antizer. it'll pull in every single thing in antd. meaning your final JS grows by at least 1mb

thheller20:09:16

probably way more

thheller20:09:33

if that is not important to you than its totally fine to use of course

Josh Horwitz21:09:15

Here’s a quick starter I put together using the wrapper, I will work on using it without next. Thanks!

Nolan23:09:44

hey everyone, curious if anyone else has run into issues using test.check/defspec with the default :runner-ns shadow.test.browser. the workaround is easy, i just wrote a custom runner that calls clojure.test/run-tests in start, but curious if im missing something or what other solutions may be out there