Fork me on GitHub
#shadow-cljs
<
2020-05-14
>
plexus05:05:07

We've put out the first early releases of Chui, a new cljs test runner for the browser. Works best with Shadow for now, and integrates nicely with shadow's reloading. If that sounds interesting please do give it a spin and report back in #lambdaisland or #kaocha https://github.com/lambdaisland/chui

šŸ‘ 8
dominicm11:05:06

Was #?(:shadow/cljs) ever a thing / How can I do the equivalent of https://clojurescript.org/guides/javascript-modules in a portable (shadow & non-shadow) way?

dominicm11:05:56

https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js okay, I see you're aware of this conflict. So how can I write code which works for both?

dominicm12:05:00

One approach that seems to work is using goog.module with the latest versions of ClojureScript.

thheller14:05:23

@dominicm show me what you want to use in CLJS (thats actually working) and I'll make sure it works in shadow-cljs too

thheller14:05:49

but I've never seen the guide you linked lead to something that actually works in practice? šŸ˜›

thheller14:05:01

what do you mean? shadow-cljs itself uses exactly that approach?

thheller14:05:34

isn't that what I told you to do?

dominicm14:05:35

You didn't tell me anything, but you might have told @lilactown. I took his word that it didn't work in shadow, confirming for myself now.

dominicm14:05:03

(I decided to investigate getting this to work in figwheel for myself)

thheller14:05:37

goog.provide should be fully supported for all cases

thheller14:05:59

ESM might work differently but should also work. whatever works in standard CLJS should work in shadow-cljs

thheller14:05:20

with the exception of :foreign-libs meaning actual foreign-libs though, so files that aren't processed just prepended

thheller14:05:18

what classpath-js is referring to is requiring files by their actual filename, even allowing relative-paths. that was rejected from CLJS and won't work there.

dominicm14:05:40

Right you are, works perfectly. I'll wait for him to to tell me what particular scenario doesn't work I guess!

dominicm14:05:34

@thheller while I'm here, do you still not support providing imports via API (i.e. not via shadow-cljs.edn)?

thheller14:05:48

hmm? what are imports via API?

dominicm14:05:49

Sorry, multi-tasking. *builds.

dominicm14:05:00

Basically, using shadow-cljs without a shadow-cljs.edn file.

dominicm14:05:40

Ah, looks like shadow-cljs problem was something specific that's now been fixed: https://github.com/thheller/shadow-cljs/issues/638

thheller14:05:37

@dominicm that has always worked? you lose a bunch of features but that has always worked? I can't remember context if we talked about that before?

dominicm14:05:40

@thheller we did, you told me that using via api wouldn't be supported as I recall... There was something that errored if you used the api without shadow-cljs.edn file existing containing a particular parameter.

thheller14:05:52

you can't use the official API fns that refer to a build by id and have that load from something other than shadow-cljs.edn. that is true and won't be supported ever.

thheller14:05:17

but you can pass the entire build config instead to the underlying API fns. shadow-cljs does not need to know where it came from?

thheller14:05:54

sorry really can't remember this discussion

dominicm14:05:05

I'll have to revisit in order to remember. Me neither, it was a couple years ago.

dominicm14:05:23

I'm guessing there was an api that only existed in build id form.

dominicm14:05:05

I would guess that stop requires a build id maybe?

thheller14:05:35

says 3 years ago so it has been there a while šŸ˜›

thheller14:05:56

you must always supply a :build-id as part of the config anyways

thheller14:05:15

so you can stop it by that id later regardless

thheller14:05:22

thats 2 years ago so maybe that wasn't there when we talked about that last?

thheller14:05:47

basically the gist is that (shadow/release :some-id) will load the build config for :some-id from shadow-cljs.edn and call release* with it

thheller14:05:09

but you can call release* yourself if you want too

thheller14:05:16

but yeah its not something I recommend doing and if you want to do that as part of some tool moving configuration elsewhere I'll fight you šŸ˜› https://github.com/day8/re-frame-template/issues/128

dominicm15:05:10

This is what I want to do, yeah. I already have a config.edn where I can distinguish between dev/prod. I can also read from env, AWS or wherever else in it. I wouldn't be as evil as lein-shadow though, I mostly just want to pass through the user's arguments into shadow. Maybe one or two small tweaks for disabling anything that doesn't make sense in that context (e.g. for figwheel I disable open-url as you don't want that to happen on (reset) & I already have a mechanism for linking to auto-testing if it's enabled.)

thheller14:05:52

but if you want that as part of something your own projects build pipeline you can see this as fully supported

dima14:05:50

What has higher priority projectā€™s deps.edn or user-config ~/.shadow-cljs/config.edn ? Iā€™m trying to override dependency specified in projectā€™s deps.edn with shadow user config, but it doesnā€™t have any effect

thheller14:05:51

hmm? you use deps.edn to configure deps and give shadow-cljs the list of aliases?

thheller14:05:14

if you want more complex things you use clj directly without going through shadow-cljs?

dima14:05:38

Iā€™ve added

{:dependencies
 [[cider/cider-nrepl "0.25.0-SNAPSHOT"]]}
to .shadow-cljs/config.edn assuming it would override cider-nrepl dep from deps.edn , but itā€™s not

thheller14:05:59

yeah no that doesn't work

thheller15:05:25

specify it in ~/.clojure/deps.edn and enable that alias instead

dima15:05:41

thanks, iā€™ll try

thheller15:05:47

hmm bit it might merge in the wrong order too so you probably want to get rid of that in the project deps.edn?

dima15:05:27

one option is to remove it from project deps.edn, but iā€™m exploring other options

thheller15:05:51

user specific config really shouldn't be in the project deps.edn (eg. cider) IMHO

dima15:05:27

right, i also think it shouldnā€™t be there

beders15:05:12

Hey there, looks like there might be a juicy new compilation target for shadow: https://deno.land/v1 šŸ˜‰

dpsutton15:05:29

was just reading about that. doesn't seem useful? no npm support. its value add is native TSC which it calls "unsatisfyingly slow". eventually typechecking needs to happen in Rust but that "will be a massive undertaking and will not happen any time soon"

dominicm15:05:18

This is javascript land, you must jump on the latest! pssht.

thheller15:05:25

yeah its meant to fix the issues he talked about here https://www.youtube.com/watch?v=M3BM9TB-8yA

thheller15:05:44

seems useful but I don't see it replacing npm/node anytime soon

thheller15:05:29

this using urls for deps thing is not sometimes I think will work in practice but we'll see

rberger22:05:10

One of the worse ā€œfeaturesā€ of Go

beders15:05:05

it provides enough justification so everything can be re-written to make things "better" šŸ˜‰

thheller15:05:10

I don't know what the eval situtation is like for deno so don't know about hot-reload or REPL but creating output that is consumable by it is trivial

lilactown16:05:13

hey thheller, re: ^:const - what did you mean by ā€œdoesnā€™t do what everyone thinks it doesā€ ?

lilactown16:05:25

are there any docs on what the behavior is in modern CLJS?

lilactown16:05:30

Iā€™m seeing this error still using latest shadow-cljs: https://github.com/thheller/shadow-cljs/issues/643

thheller16:05:54

please don't refer to old tickets. that ticket is talking about react-native. you are not doing react-native are you?

lilactown16:05:59

Iā€™m not

thheller16:05:13

do you load the code from the REPL or is it part of the regular build?

lilactown16:05:21

this is a part of a regular build

thheller16:05:29

I think that is the underlying problem though

thheller16:05:37

try with :compiler-options {:output-feature-set :es6}

thheller16:05:34

https://recoiljs.org/ looks like react-world found re-frame šŸ˜‰

lilactown16:05:02

good luck to them šŸ˜›

lilactown16:05:21

I can confirm that changing the output feature set to :es6 fixes it

thheller16:05:18

yeah the issue is polyfills. CLJS doesn't do any polyfill handling for :none builds. maybe I should do that too?

thheller16:05:41

kinda annoying to deal with this mess šŸ˜›

lilactown16:05:47

šŸ˜ž it is a mess

lilactown16:05:41

> CLJS doesnā€™t do any polyfill handling forĀ `:none`Ā build

lilactown16:05:23

> what would that mean for users of my lib?

thheller16:05:41

nothing? I will figure out how to deal with this ... even if I just bail on polyfills for dev builds like CLJS does

lilactown16:05:26

does ā€œbailingā€ mean you always load them? or donā€™t transpile to ES5 for dev builds?

lilactown16:05:28

Iā€™m a bit confused

thheller16:05:37

don't transpile language features . I'm pretty sure CLJS doesn't, will verify when I have some time

thheller16:05:00

polyfills have been a pain forever so I want to figure this out cleanly once and for all

lilactown16:05:01

and right now, doing a release build w/ goog.provides I see no jscomp error. so the polyfills must be loaded in the correct order there

lilactown16:05:25

I think I understand now

dominicm17:05:25

Which sources correctly load polyfills? Is there a workaround where we could force-load the polyfills earlier somehow (maybe via an npm or esm?)

thheller17:05:59

all release builds should handle them correctly (now)

thheller17:05:24

during dev closure-js doesn't handle them correclty (so goog.provide/goog.module on the classpath)

thheller17:05:34

everything else should assuming they aren't initially added by the REPL

thheller17:05:43

since the REPL doesn't add them dynamically at the moment

Wilson Velez20:05:06

when to choose note-test over browser-test targets? only when the thing to test is not related with a ā€œDOM/Browserā€? what if I want to test a re-frame handler?

thheller21:05:47

tried to capture everything I could think of but not sure its actually helpful šŸ˜›

thheller21:05:53

@wvelezva :browser-test is currently rather limited and doesn't work great for automated testing env. :node-test generally works better if you can live without the DOM/browser APIs

Wilson Velez21:05:19

thanks @thheller, and karma is only suitable if I'm planning to use continuous integration, right?

vinnyataide23:05:31

hello folks, I hope all is well

vinnyataide23:05:45

I have an issue in windows, just installed clojure and shadow-cljs

vinnyataide23:05:56

this is my package.json

{
  "dependencies": {
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "shadow-cljs": "^2.9.3"
  }
}
and this is my deps.edn
{:paths   ["src/main" "resources"]
 :deps    {org.clojure/clojure    {:mvn/version "1.10.1"}
           com.fulcrologic/fulcro {:mvn/version "3.0.10"}}

 :aliases {:dev {:extra-paths ["src/dev"]
                 :extra-deps  {org.clojure/clojurescript   {:mvn/version "1.10.742"}
                               thheller/shadow-cljs        {:mvn/version "2.8.107"}
                               binaryage/devtools          {:mvn/version "0.9.10"}}}}}
this is my shadow-cljs.edn too
{:deps     {:aliases [:dev]}
 :dev-http {8000 "classpath:public"}
 :builds   {:main {:target     :browser
                   :output-dir "resources/public/js/main"
                   :asset-path "/js/main"
                   :modules    {:main {:init-fn app.client/init
                                       :entries [app.client]}}
                   :devtools   {:after-load app.client/refresh
                                :preloads   [com.fulcrologic.fulcro.inspect.preload]}}}}
it's giving the message
Execution error (FileNotFoundException) at clojure.main/main (main.java:40).
Could not locate shadow/cljs/cli__init.class, shadow/cljs/cli.clj or shadow/cljs/cli.cljc on classpath.

vinnyataide23:05:16

am I missing something?

thheller23:05:47

thheller/shadow-cljs {:mvn/version "2.8.107"} but "shadow-cljs": "^2.9.3"

thheller23:05:49

these should match. either downgrade the package.json version or update deps.edn