Fork me on GitHub
#clojurescript
<
2019-09-05
>
Janne Sauvala11:09:07

If I’m starting a new project, should I choose Shadow-cljs over Figwheel-main? Is Shadow-cljs going to be a replacement for Figwheel or does it target a different use case, like better npm-integration and targeting Node and React native platforms?

flowthing14:09:44

For what it’s worth, if you want to use NPM dependencies, shadow-cljs makes it really easy.

Janne Sauvala14:09:03

That’s a really big selling point

danieroux12:09:43

I feel that’s the wrong question. The question is: Do you want to use shadow-cljs or the vanilla cljs.main as your compiler for the project? If you choose cljs.main (the ClojureScript compiler), then using figwheel for your auto-building while developing is cool.

Janne Sauvala12:09:35

Thanks Danie. Is there a comparison somewhere between the two compilers? I was listening The REPL -podcasts where Heller was talking about shadow-cljs and compiling process but most of that stuff went over my head 🙂

danieroux12:09:21

(to be more correct: To only use cljs.main, since shadow obviously leverages it) - https://code.thheller.com/blog/shadow-cljs/2019/03/01/what-shadow-cljs-is-and-isnt.html

danieroux12:09:28

If you are choosing cljs.main, then https://clojurescript.org/guides/webpack is how you would be adding npm packages

Leon12:09:06

figwheel is harder to set up, (at least that was my experience). as soon as someone here recommended shadow-cljs to me, i was set up and ready to go, and i dont see any weak points ;D

Janne Sauvala12:09:23

That’s good to know. I was working previously in a project where the Figwheel was setup before I joined it, so I didn’t get experience about that part

Janne Sauvala12:09:35

Thanks Danie. Is there a comparison somewhere between the two compilers? I was listening The REPL -podcasts where Heller was talking about shadow-cljs and compiling process but most of that stuff went over my head 🙂

dnolen13:09:45

to be clear shadow-cljs is really a build tool

dnolen13:09:43

there's only one compiler - ClojureScript - it does have basic build tool facilities as that's fundamentally necessary

Janne Sauvala13:09:10

Thanks David. Maybe I should just take both of them for a ride and see how they compare in practice 🛠️

dnolen13:09:09

I don't personally think anything but ClojureScript + Figwheel for REPL niceties is really necessary to be productive and to ship software. shadow-cljs is more of a complete package and that's nice.

8
cap10morgan17:09:00

How does one use core.async in a CLJS macro? The macro is written in CLJ but needs to output CLJS code. So I'm confused by what the require form should look like. In CLJ it would be something like (:require [clojure.core.async :refer [chan]]) but needs to output code that refers to cljs.core.async. I feel like I'm missing something simple, but it's not clicking.

souenzzo17:09:12

just (:require [clojure.core.async :as async]) and use (async/go (async/<! (async/chan))) ...

cap10morgan17:09:59

Hmm... I stumbled onto (:require [cljs.core.async]) and just using fully-qualified names in a CLJC file. That seems to work, but I was hoping to find a way to make :refer work. Oh well, not a big deal.

dnolen17:09:24

@cap10morgan it's not actually simple

dnolen17:09:33

ClojureScript macros are Clojure code

dnolen17:09:54

so var resolution is Clojure resolution - not ClojureScript

cap10morgan17:09:28

right, hence my confusion 🙂

dnolen17:09:51

means you need to explicit - so writing macros in ClojureScript really isn't quite as easy

dnolen17:09:00

namespace aliasing can make things less verbose

dnolen17:09:06

it's possible we could make that work more smoothly - but not sure

dkrieger17:09:09

Is there a straightforward and/or reliable way to require a clojurescript module from npm? I know the reverse is trivial. I would like to avoid the need to commit build artifacts

dkrieger18:09:05

Perhaps the "prepare" npm script is the right way to go about committing build artifacts if that's unavoidable

dnolen18:09:56

not really unless you're using Lumo or something

dnolen18:09:16

but I'm not sure I see much value esp. with git deps

dkrieger18:09:40

Have a need for using cljs for state management, packaged for use by js devs across agency lines who don't have cljs build tools or experience. I think I'm going to go with the npm option as a standardized way to go about building and checking in. Thanks for bringing up lumo though, that could be useful

dnolen18:09:14

@dougkrieger you're likely to run into issues w/ that

dnolen18:09:55

well at least not w/o a lot of effort

dkrieger18:09:10

@dnolen I figured that may be the case, can you elaborate?

dnolen18:09:48

yeah I would say impractical unless you can sink a couple of months into setup

dnolen18:09:04

first question is this for Node development or browser?

dnolen19:09:20

fundamentally ClojureScript doesn't have anything to do w/ Node.js or NPM conventions

dnolen19:09:30

so it's a completely non-fit for distribution

dnolen19:09:56

that is you can't really use the compiled out in this way

dnolen19:09:07

(out of the box)

dnolen19:09:48

@dougkrieger it really depends on whether you want to distribute multiple artifacts - if the answer is no, you can probably make it work w/o much hassle

dnolen19:09:57

if the answer is yes - then you're going to run into problems

dkrieger19:09:11

Not interested in code splitting. One artifact per clojurescript module

dnolen19:09:55

yeah not talking about code splitting - I understand what you're trying to do

dnolen19:09:08

one artifact per ClojureScript module will create a lot of problems

dnolen19:09:02

because ClojureScript module mechanism is based on namespacing in a global context

dnolen19:09:06

but that's not true for Node.js modules

dnolen19:09:20

so you actually need a custom loader

dkrieger21:09:42

Ah ok... I will investigate a bit more, thanks for calling this out

skuttleman22:09:05

Anyone seen this before?

# cljsbuild once prod
Compiling ClojureScript...
Unrecognized option: -J-Xmx750M
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Subprocess failed

skuttleman23:09:52

And out of nowhere, the problem is back.

thheller22:09:39

@skuttleman looks like you are passing a deps.edn style JVM arg via lein?

thheller22:09:08

check your :jvm-opts

skuttleman22:09:35

There are no :jvm-opts declared in project.clj.

thheller22:09:08

search for -Xmx750M. must be coming from somewhere 😛

skuttleman22:09:42

I took an alternate path of nuking from orbit and re-cloning. Working now. No clue how it broke.