shadow-cljs

https://github.com/thheller/shadow-cljs | https://github.com/sponsors/thheller | https://www.patreon.com/thheller
2020-12-23T09:06:32.101300Z

Hello, How can I conditionally use different :source-paths for dev and release? thanks.

thheller 2020-12-23T10:01:13.102500Z

@kimi.im with shadow-cljs.edn you can't. I consider this an anti-pattern that should be avoided so its not supported out of the box. you can do it when using deps.edn or project.clj if you really need to

2020-12-23T10:04:16.103700Z

then I should use two different files in the same source path for dev and prod? Is that ok?

thheller 2020-12-23T10:11:21.104200Z

what are you trying to do? what do you mean by "two different files"?

thheller 2020-12-23T10:12:14.105Z

this is usually an anti-pattern in shadow-cljs because it does things differently then other tools. so the problem that this pattern is trying to fixed is already fixed. see https://code.thheller.com/blog/shadow-cljs/2018/02/08/problem-solved-source-paths.html

👍 1
2020-12-23T10:41:22.105900Z

Hi, the REPL problem we discussed occured to me right now and I noticed the following output in browser console:

thheller 2020-12-23T11:22:04.106700Z

sorry I talk to too many people. which problem? 😛

thheller 2020-12-23T11:23:23.107100Z

that looks like a regular repl load sequence so I don't see the issue?

2020-12-23T13:05:52.109400Z

the bug where requires are lost, occurs sometimes

2020-12-23T13:07:17.109900Z

[reposting the original report] Hi, it happens to me quite frequently (several times every day) that while doing changes in the code, Shadow-cljs REPL stops working correctly and I have to restart Shadow to make it working again. [4:09 PM] For instance, I get the following in Cursive nREPL:

(clojure.string/join ["ab" "cd"])
Timeout while waiting for result.
[4:10 PM] And shadow-cljs outputs this into console:
[2020-12-16 16:07:58.625 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:op :cljs-load-sources, :sources [[:shadow.build.classpath/resource "cljs/spec/gen/alpha.cljs"] [:shadow.build.classpath/resource "cljs/spec/alpha.cljs"] [:shadow.build.classpath/resource "cljs/repl.cljs"] [:shadow.cljs.repl/resource "cljs/user.cljs"]], :call-id 6, :from 71}}
ExceptionInfo no output for id: [:shadow.cljs.repl/resource "cljs/user.cljs"] {:resource-id [:shadow.cljs.repl/resource "cljs/user.cljs"]}
        shadow.build.data/get-output! (data.clj:197)
        shadow.build.data/get-output! (data.clj:193)
        shadow.cljs.devtools.server.worker.impl/fn--15184/fn--15187 (impl.clj:813)
        clojure.core/map/fn--5866 (core.clj:2753)
        clojure.lang.LazySeq.sval (LazySeq.java:42)
        clojure.lang.LazySeq.seq (LazySeq.java:51)
        clojure.lang.RT.seq (RT.java:535)
        clojure.core/seq--5402 (core.clj:137)
        clojure.core.protocols/seq-reduce (protocols.clj:24)
        clojure.core.protocols/fn--8146 (protocols.clj:75)
        clojure.core.protocols/fn--8146 (protocols.clj:75)
        clojure.core.protocols/fn--8088/G--8083--8101 (protocols.clj:13)
[4:10 PM] Any idea what could be causing this or how I could debug where is the problem? [4:12 PM] Also, all previous requires are lost when this happens. So for instance, I run the following code before:
(require '[orgpad.client.db.get :as db-get])
=> nil
I can use functions from db-get perfectly fine. After this, I can't call them and I get this error in REPL:
------ WARNING - :undeclared-ns ------------------------------------------------
 Resource: <eval>:1:2
 No such namespace: db-get, could not locate db_get.cljs, db_get.cljc, or JavaScript source providing "db-get" (Please check that namespaces with dashes use underscores in the ClojureScript file name)
--------------------------------------------------------------------------------

------ WARNING - :undeclared-var -----------------------------------------------
 Resource: <eval>:1:2
 Use of undeclared Var db-get/latest-editor
--------------------------------------------------------------------------------

thheller 2020-12-23T13:08:00.110800Z

please open a github issue if you want to get any kind of progress on this. there is far too much going on in slack for me to keep track of it all.

2020-12-23T13:08:32.111100Z

ok, I will do that 🙂

thheller 2020-12-23T13:08:48.111500Z

I do remember this now but still don't have a clue what is going on and also still can't reproduce it

thheller 2020-12-23T13:09:03.111700Z

seems similar to this maybe https://github.com/thheller/shadow-cljs/issues/788

2020-12-23T13:11:05.112400Z

Seems to be related, I will put it there

GGfpc 2020-12-23T15:46:52.115400Z

This might be a super dumb question but I'm not familiar with frontend. I'm using reagent with shadow-cljs, when I do shadow-cljs release should I be able to serve the app just from my browser by opening index.html or will I always need a webserver?

dpsutton 2020-12-23T15:50:03.116Z

you'll need a webserver. in that index.html will be a reference to your js bundle that the browser will attempt to fetch. without a webserver that fetch will fail

dpsutton 2020-12-23T15:50:28.116300Z

among likely other things like css and images

thheller 2020-12-23T15:51:53.117100Z

thats not entirely true. you can load it directly from the filesystem but you are going to be limited in what you are allowed to do since browsers restrict some stuff if loaded from disk

thheller 2020-12-23T15:52:58.118300Z

its best to use a server

GGfpc 2020-12-23T15:53:05.118500Z

ok so basically I can't host it on github pages or S3?

thheller 2020-12-23T15:53:10.118800Z

yep

dpsutton 2020-12-23T15:55:14.119600Z

i thought github pages and s3 both can do this. that yep meant those things will work? also, netlify makes this amazingly easy

thheller 2020-12-23T15:55:41.120100Z

haha didn't see the "can't". just read "can". sorry. yes of course those are fine.

👍 2
thheller 2020-12-23T15:55:54.120400Z

anything that speaks http and knows how to serve files is fine.

nivekuil 2020-12-23T20:45:22.120700Z

hello, I'm trying to use https://github.com/kunukn/react-collapse imported like #?(:cljs ["@kunukn/react-collapse" :default Collapse]) but when it's rendered this happens:

ERROR [com.fulcrologic.fulcro.react.error-boundaries:31] - Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
first time I've run into an error like this, not sure if there's something special about importing this module into shadow-cljs?

nivekuil 2020-12-23T20:46:51.120900Z

version is shadow-cljs 2.11.10

thheller 2020-12-23T20:49:28.121400Z

likely means that Collapse is nil. might be :as Collapse or :refer (Collapse)

nivekuil 2020-12-23T20:49:58.121500Z

oh, it was :as Collapse

nivekuil 2020-12-23T20:50:13.121600Z

I only tried :refer; didn't even know you could import a whole class like a ns

nivekuil 2020-12-23T20:51:30.121700Z

is there some rule for when that needs to be done? I see export default Collapse in the library, so I thought it'd be a default export

nivekuil 2020-12-23T20:51:50.121800Z

thanks a lot though :)

2020-12-23T20:59:18.122300Z

Yeah, what is the rule? I usually have to make trial and errors haha