Fork me on GitHub

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.


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


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


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


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, but the es6 files are not ont the default dist folder but dist/es6 folders. Anyone got the issue before?


@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


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!


well for one gives you an error which is never good


ok nevermind I guess. checked the wrong package 😛


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.


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


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?


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


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


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


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


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


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


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


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


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?


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


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


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


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).


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.


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.


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.


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.


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


not much to do other than learning to recognize the errors


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


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


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


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