Fork me on GitHub
#shadow-cljs
<
2022-01-29
>
Justin Roche01:01:01

Is there a way using a shadow-cljs build to get dependencies output as .cljs? I have a need for getting the original .cljs files but everything seems bundled in the app.js. My own project files are easy enough to find, but dependencies seem to live in the .jar files on the classpath.

tianshu07:01:09

I found it very common to run into issues when start a development REPL after a release build, or bulid a browser target after a node target. Deleting .shadow-cljs always solve the problem. Should the caches from different build be separated?

thheller08:01:27

@doglooksgood I have never deleted .shadow-cljs and I don't hear much of others doing that. what issues are you running into? deleting the caches should absolutely not be happening and caches are already separated, so they cannot affect each other.

thheller08:01:24

@jproche5 what do you need those files for? yes, dependencies live in .jar files. there is no direct way of having shadow-cljs output them for you. you can always get them yourself at any time if you need to

tianshu08:01:31

@thheller Errors in build, like $arr is not definded, $cljs is not defined.

thheller08:01:00

please do not shorten errors. stacktraces are extremely important.

thheller08:01:20

never seen those errors and no immediate idea what would cause them

tianshu08:01:36

Let me try reproduce

thheller08:01:56

are you outputting into different directories? each build should live in its own directory (eg. :output-dir). outputting into the same directory may cause files to be overridden and as such cause issues

tianshu08:01:58

Yes, I have different output directories, like resources/public/js and resources/public/js/workspaces.

tianshu08:01:20

Have I stop REPL when doing a release building?

thheller08:01:18

when the release build is outputting to the same directory yes, they will otherwise overwrite the watch files and watch may overwrite the release files

thheller08:01:31

releasing a separate build while another build watch is running doesn't matter

thheller08:01:48

only shadow-cljs watch app and then shadow-cljs release app may interfere with each other

thheller08:01:35

but none of this would break the caches either so deleting .shadow-cljs would not do anything other than cause a rebuild

tianshu08:01:38

I do not know how to reproduce yet, I'll bring the stacktrace when I ran into the issue again. Maybe it's caused by releasing and watching at the same time.

tianshu08:01:06

Thanks for explanation in details.

Justin Roche09:01:48

@thheller I need them for displaying stack traces in http://sentry.io. cljs isn’t well supported in it’s source-map upload system. If I turn source maps on, and turn off any source map includes, and the source code is in a separate file, it can show them correctly. But to do that for libraries I have to hard code a path to .m2, and then extract from the .jar file, and it’s a pain.

thheller09:01:49

uhm the source maps should contain all you need? they do include the sources if you create them for a release build?

thheller09:01:21

why not include the sources in the source map itself?

thheller09:01:07

I don't know what special handling sentry needs but it works fine in the browser so I'd assume it is fine in sentry too?

Justin Roche09:01:29

one would think so, but sentry won’t match them properly

thheller09:01:44

what does that mean?

Justin Roche09:01:53

it just shows the minified js in the stack trace

thheller09:01:38

and you uploaded the source maps properly?

Justin Roche09:01:02

Yeah I think so

thheller09:01:42

I have never used sentry so I really don't know much but you can easily look at the generated source maps

thheller09:01:26

it does include all sources and sourcesContent so it should be all fine assuming all the paths map and such

thheller09:01:12

also the paths shadow-cljs includes in the source map never refer to any file in .m2, so I don't know where that info would come from

thheller09:01:55

well unless you explicitely set the :source-map-use-fs-paths true, which you definitely should not be setting for browser builds

thheller09:01:42

paths are only refered to by their classpath resource name, never the actual file of the local disk

Justin Roche09:01:19

I will keep at it. with sourcesContent it works in the browser fine.

barrell13:01:25

Hey #shadow-cljs! I’ve set up a custom build script and added a build to my module. I’d like to see all the files available on the classpath (trying to find any .css files). Is there a way to access this information from a build hook - either from the build state or the general clojure environment? Or do I need to get the src dirs and read them myself? EDIT I sole and adopted a function from shadow.build.classpath which seems to do exactly what I want. Let me know if there is a better way out there thought!

(defn classpath-files
  "searches classpath source source files"
  [build]
  (let [cp (:classpath build)]
    (for [^File cp-entry (classpath/get-classpath-entries cp)
          :when (and (.isDirectory cp-entry)
                     (not (classpath/is-gitlib-file? cp-entry)))
          :let [root-path (.toPath cp-entry)]
          ^File file (file-seq cp-entry)
          :when (not (.isHidden file)
          :let [file-path (.toPath file)
                resource-name (-> (.relativize root-path file-path)
                                  (.toString)
                                  (rc/normalize-name))]
          :when (not (classpath/should-ignore-resource? cp resource-name))]
      resource-name)))

Timofey Sitnikov18:01:04

Hello all! I am running https://github.com/fulcrologic/fulcro-template and when reload the web application, it takes a long time for the page to reload. Specifically, it looks like the remote-relay?.... What can I do to make it quicker? Here is my network:

thheller19:01:03

remote-relay a websocket. it stays open. it does not affect the speed of your page load?

thheller19:01:21

what does "reload the web application" mean?

Timofey Sitnikov19:01:43

When I press this button:

thheller19:01:50

you are loading 13.9mb of JS so is that maybe the cause of the slow speeds? what kind of computer do you use?

Timofey Sitnikov19:01:15

2019 Macbook Pro

thheller19:01:43

hmm that should definitely handle that fine. assuming it has memory left and isn't swapping?

thheller19:01:17

could also be browser extensions slowing everything down. can't really say, this has very little to do with shadow-cljs

Timofey Sitnikov19:01:27

@thheller, OK, I will keep digging.

thheller19:01:12

could also be the JS doing a lot of stuff on load that everything else has to wait for

Rodrigo Mantica23:01:33

Can I customize how shadow resolves javascript files to support the module require syntax path/to/dir and have it load the index.js file at that path? In other words, I’m trying to override what happens when shadow detects a directory path? It currently fails and throws FileNotFoundException with a note that it’s a directory. I’m trying to compile an existing js project, but webpack handles that situation by default so I need a way to replicate that behavior

thheller07:01:01

if you are talking about https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js then no, there is no way to make that happen

thheller07:01:14

for regular npm node_modules requires that is already the default and should be fine