Fork me on GitHub
#shadow-cljs
<
2020-12-23
>
kimim09:12:32

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

thheller10:12:13

@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

kimim10:12:16

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

thheller10:12:21

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

thheller10:12:14

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

👍 3
Pavel Klavík10:12:22

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

thheller11:12:04

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

thheller11:12:23

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

Pavel Klavík13:12:52

the bug where requires are lost, occurs sometimes

Pavel Klavík13:12:17

[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
--------------------------------------------------------------------------------

thheller13:12:00

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.

Pavel Klavík13:12:32

ok, I will do that 🙂

thheller13:12:48

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

Pavel Klavík13:12:05

Seems to be related, I will put it there

GGfpc15:12:52

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?

dpsutton15:12:03

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

dpsutton15:12:28

among likely other things like css and images

thheller15:12:53

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

thheller15:12:58

its best to use a server

GGfpc15:12:05

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

dpsutton15:12:14

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

thheller15:12:41

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

👍 6
thheller15:12:54

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

nivekuil20:12:22

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?

nivekuil20:12:51

version is shadow-cljs 2.11.10

thheller20:12:28

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

nivekuil20:12:58

oh, it was :as Collapse

nivekuil20:12:13

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

nivekuil20:12:30

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

nivekuil20:12:50

thanks a lot though :)

David Pham20:12:18

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