Fork me on GitHub
#shadow-cljs
<
2020-08-13
>
flowthing07:08:00

I think I’m having the same issue as @adam678. I have src/cljs/user.cljs, and in shadow-cljs.edn, I have :preloads [cljs.user ,,,]. Using :after-load pointing to cljs.user/start in shadow-cljs.edn doesn’t work, nor does setting ^:dev/after-load meta on the var.

flowthing07:08:21

If I put the after-load function into a namespace that’s not in preloads, it works.

thheller07:08:22

ah. you can't have hooks in cljs.* files. they are filtered.

thheller07:08:42

use a regular namespace. cljs.user is special and should not be used for this.

flowthing07:08:44

Aha! Good to know, thanks.

Adam Helins07:08:25

@thheller Thanks! A small indication in the docs might be useful since it seems to happen at least once in a while

👍 6
David Pham13:08:32

I am sorry if this is documented somewhere: how can use files from npm packages that are located in different folders than the usual ones. I am trying to use this library, https://github.com/projectstorm/react-diagrams but the es6 files are not ont the default dist folder but dist/es6 folders. Anyone got the issue before?

thheller13:08:45

@neo2551 that library does not look usable but you can access any file you want via (:require ["the-npm-package/path/to/whatever.js" :as x]) which would be node_modules/the-npm-package/path/to/whatever.js

thheller13:08:05

just needs to be a real JS file so not typescript, flow, JSX or whatever other dialects there may be

David Pham13:08:04

Thanks a lot! My issue is the cross dependency call the correct path so I would need to rewrite the source code... how do you know it is not usable? Thanks a lot for your answer!

thheller13:08:02

well for one https://unpkg.com/react-diagrams gives you an error which is never good

thheller13:08:47

ok nevermind I guess. checked the wrong package 😛

thheller13:08:35

why do you want the ES6 files in the first place?

David Pham16:08:36

Because I get an error whenever I import the package in typescript otherwise.

thheller18:08:23

what does that mean? the output shadow-cljs produces will be almost identical

misha15:08:10

a bit of e newbie question: I am getting compilation error with no details, and ns is 1kloc

shadow-cljs - starting via "clojure"
------ ERROR -------------------------------------------------------------------
 File: /<...redacted...>/foo.cljc
Error in phase :compilation

-------------------------------------------------------------------------------- 
what can I do to narrow it down?

misha16:08:46

clj -Sdeps "{:deps {org.clojure/clojurescript {:mvn/version \"1.10.758\"}}}" --main cljs.main --compile bug.core
Caused by: clojure.lang.ExceptionInfo: failed compiling constant: 1/4; clojure.lang.Ratio is not a valid ClojureScript constant. {:constant 1/4, :type clojure.lang.Ratio, :clojure.error/phase :compilation}
weirdly enough, if literal is just ratio 1/4 shadow shows (other) ns errors and warning, but if it is vector with ratio [1/4] - error is blank, as in previous message

thheller16:08:22

@misha I think I fixed that error message recently. which shadow-cljs version do you have? try 2.10.21

misha16:08:21

thheller/shadow-cljs             {:mvn/version "2.8.40"}

thheller16:08:43

yeah that definitely doesn't have the fix. think its fixed in 2.10.18 or so

misha16:08:40

do you want me to check it out now? (I'd rather not opieop)

thheller16:08:59

check it out? if you want to narrow down the issue use the newer version 😉

misha16:08:55

I already did. But if you'd like a confirmation newer version would narrow it down too – I'll try it out now opieop

misha17:08:06

yep, that prints ratio error, sweet. ♥️ thank you

neilyio17:08:29

In Chrome DevTools, my "Sources" panel and all Console errors are pointing to files in , most commonly the core.cljs file there. Is this normal, or is there a further layer of "source-mapping" I could be enabling to actually get errors to reference my own source files?

neilyio17:08:39

Yes, curious! Are there any screenshots or anything I can post to clarify?

thheller18:08:41

I don't know what you mean by "own source file"? you mean like on disk?

neilyio18:08:34

I think that's what I mean. My Sources panel in Chrome DevTools is showing this core.cljs file.

neilyio18:08:17

All my runtime errors in the Chrome Console also point to this core.cljs file, which makes it very difficult for me to track them down in my own source code (e.g. src/app/core.cljs).

neilyio18:08:24

I feel like I'm doing something fundamentally wrong, and I've been trying to grind through guessing where errors come from for a couple months.

neilyio18:08:06

This is definitely coming from a place of inexperience with Chrome DevTools. Upon digging through the explosion of error messages in DevTools, I guess I'm able to pick out a file name that looks familiar (only because I happened to have named it views.cljs, which I recognize). I've highlighted that one in the image below.

neilyio18:08:32

And upon clicking on that one, it does indeed take me to the correct source file in the Chrome DevTools. I guess I've just been finding this to be a very harrowing user experience, especially when there are multiple runtime errors and I have to scan through lots of stack trace noise to find where I made the error.

neilyio18:08:54

Apologies if this became off-topic, I posted this here because I thought I was doing something wrong with my shadow-cljs configuration. But perhaps I just need some debugging tips, and I can ask elsewhere.

thheller18:08:43

it has nothing to do with shadow-cljs as far as I can tell. its chrome just stripping the "folders" from the filename so you just see a bunch of core.cljs instead of cljs/core.cljs or so

thheller18:08:53

not much to do other than learning to recognize the errors

neilyio18:08:20

Thanks! Sorry to pollute the thread with this, I appreciate your response.

thheller18:08:23

like the error you see is @foo when foo is nil

thheller18:08:02

and you identified the correct place of the error in views.cljs

thheller18:08:14

maybe there is an option in chrome to show more of the filename? not sure