Fork me on GitHub
#shadow-cljs
<
2021-03-17
>
Robert Schulte08:03:42

I have some trouble regarding source maps in combination with client-side routing in my development build: • When I access my SPA via localhost:<dev-http-port>, everything works as expected. • When I enter via localhost:<dev-http-port>/some/path/within/spa, the browser console is flooded with warnings regarding unresolvable source maps. In Chrome these warnings look like this:

DevTools failed to load SourceMap: Could not parse content for :<dev-http-port>/some/path/within/<:asset-path>/cljs-runtime/<cljs-ns>.js.map: Unexpected token < in JSON at position 0
I have looked into the generated code and reviewed the source maps v3 specification; shadow-cljs writes relative sourceMappingUrl (and sourceURL). According to the spec the browser should resolve sourceMappingURL relative to the "page's origin" for evaled code. As it stands, the only chance I have to make this work is to pass a custom :dev-http :handler that strips /some/path/within from the URL before handing it to the default :handler, correct? Would it make sense to provide an option to have shadow-cljs create absolute URLs for sourceMappingUrl and sourceURL? This would probably only make sense with a single port :dev-http ...

thheller09:03:01

@rlschulte21 use an absolute :asset-path. so "/js" instead of "js" or whereever you have your files

🙌 1
Robert Schulte09:03:26

Thank you so much @U05224H0W! Prepending :asset-path with / has lead to the creation of absolute // # sourceURL and everything works as expected now. Thank you for debugging my configuration without me even sharing it.. Thank you for your quick response and your great work on shadow-cljs:raised_hands:

👍 1
thheller09:03:58

no it doesn't make sense to configure this in :dev-http. :asset-path is the config option that controls this.

laurent17:03:25

Hi all! I'm trying to set up a cljs project but when I try to add chakra-ui I get a compile error. I tried to figure it out for about an hour but I did not get very far as I'm a newbie. I would appreciate it if a good soul would send me in the right direction. Thanks! (i added @emotion/react but that did not help)

FileNotFoundException: .shadow-cljs/builds/app/dev/shadow-js/module$node_modules$$emotion$react$isolated_hoist_non_react_statics_do_not_use_this_in_your_code$dist$emotion_react_isolated_hoist_non_react_statics_do_not_use_this_in_your_code_browser_cjs.js (File name too long)
	java.io.FileOutputStream.open0 (FileOutputStream.java:-2)
	java.io.FileOutputStream.open (FileOutputStream.java:298)
	java.io.FileOutputStream.<init> (FileOutputStream.java:237)
	java.io.FileOutputStream.<init> (FileOutputStream.java:187)
	shadow.build.cache/write-file (cache.clj:24)
	shadow.build.cache/write-file (cache.clj:24)
	shadow.build.closure/convert-sources-simple/fn--12171/fn--12173 (closure.clj:2139)
	clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
	clojure.core/reduce (core.clj:6827)
	clojure.core/reduce (core.clj:6810)
    ....

thheller20:03:17

@laurent wow that is indeed a long filename. what OS are you on?

laurent04:03:56

Hi! I’m using Ubuntu 20.10

thheller09:03:15

seems like the maximum filename length is 255 bytes for ext4

thheller09:03:36

which this ridiculous packages manages to use up

thheller09:03:55

unfortunately I don't have an easy fix for you. this is the first time I see such a long name

laurent12:03:54

Thanks @U05224H0W! I search replaced the file name with a shorter name across the project and it works.