This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-05-21
Channels
- # announcements (3)
- # babashka (26)
- # beginners (45)
- # calva (10)
- # chlorine-clover (9)
- # cider (4)
- # clj-kondo (7)
- # cljs-dev (10)
- # clojure (95)
- # clojure-europe (33)
- # clojure-france (5)
- # clojure-nl (3)
- # clojure-spec (2)
- # clojure-sweden (3)
- # clojure-uk (33)
- # clojurescript (54)
- # conjure (101)
- # core-async (14)
- # cursive (1)
- # data-science (91)
- # datascript (3)
- # datomic (16)
- # figwheel (3)
- # figwheel-main (15)
- # fulcro (35)
- # ghostwheel (5)
- # graalvm (13)
- # helix (29)
- # java (5)
- # jobs (6)
- # kaocha (6)
- # leiningen (1)
- # meander (12)
- # off-topic (54)
- # pathom (13)
- # re-frame (16)
- # reagent (8)
- # reitit (4)
- # rum (3)
- # shadow-cljs (49)
- # spacemacs (2)
- # sql (5)
- # tools-deps (10)
- # xtdb (8)
- # yada (3)
I am trying to get source maps working, but having trouble This is my shadow-cljs.edn file:
;; shadow-cljs configuration
{:source-paths ["src"]
:dev-http {8081 "public"}
:nrepl {:port 55555}
:dependencies [[reagent "1.0.0-alpha2"]]
:builds {:app { :target :browser
:output-dir "public/scripts/"
:modules {:core
{:init-fn com.ghufran.core/run }}
:compiler-options {:source-map true
:source-map-detail-level :all
:source-map-include-sources-content true
}}}}
and this is the error I’m getting in the browser console (chrome) on first loading the page:
DevTools failed to load SourceMap: Could not parse content for : Unexpected token < in JSON at position 0
and this is the error in the firefox console:
Source map error: Error: request failed with status 404
Resource URL:
Source Map URL: com.ghufran.core.js.map
I’m actually getting around 30 such errors, one for each file in /cljs-runtime/
whose source map the browser can’t find
It looks like the browser is expecting the source map to be in /js/cljs-runtime/
when it should be /scripts/cljs-runtime/
based on the shadow-cljs.edn
file, if I’ve understood that correctly. I’ve confirmed that com.ghufran.core.js.map
is in fact in /scripts/cljs-runtime/
Any idea what might be going on? Is there some other config I need to tweak?@ghufran you don't need to set any of the :compiler-options
, you are just relying on the default :asset-path "/js"
which is incorrect in your case.
{:source-paths ["src"]
:dev-http {8081 "public"}
:nrepl {:port 55555}
:dependencies [[reagent "1.0.0-alpha2"]]
:builds {:app {:target :browser
:output-dir "public/scripts"
:asset-path "/scripts"
:modules {:core {:init-fn com.ghufran.core/run}}
}}}
@thheller is there a shortcut in shadow-cljs to automatically require some namespaces in all or some files when compiling?
my use case: I would like to have my framework namespaces always available without a require block in every file that has to duplicate the same block of code, currently I have some front end stuff and our ui library has ~30 namespaces
{:require {#{app.ui} [[hoplon.core :as h]]}}
something like that in shadow-cljs.edn would be great as a build option
that would be pretty surprising and wouldn’t transfer to any other build tool 😕 dislike
I’ve included the preload in my build:
:devtools {:preloads [day8.re-frame-10x.preload
shadow.remote.runtime.cljs.browser
devtools.preload]}
in my editor, I’ve a CLJS REPL open:
shadow.user> (shadow/watch :app)
[:app] Configuring build.
[:app] Compiling ...
[:app] Build completed. (1202 files, 4 compiled, 7 warnings, 13.32s)
shadow.user> (shadow/repl :app)
To quit, type: :cljs/quit
[:selected :app]
cljs.user> (tap> 123)
true
however, I see no output in the inspect tab of the shadow UIStrange, works for me. Do you see anything if you use the cljs.user
prompt at the bottom to do the tap>
?
@U4YGF4NGM check the networks websockets tab. there should be a dedicated websocket for the remote stuff
if all else fails just try shadow-cljs browser-repl
and then (require 'shadow.remote.runtime.cljs.browser)
@flyboarder yea I've thought about that too, I think something like that is a good idea for the ns
macro. Best place would be in ClojureScript, but that will never happen, unfortunately
In your case, maybe a decent workaround would be to re-export things from another namespace? Wouldn't work for :refer
s, though
@isak what do you mean by re-exporting?
can I def a ns as a symbol? and then refer that symbol?
@flyboarder you can have one namespace that require’s all 30 of your other namespaces, then re-exports them
For example, re-frame does this so you don't need to import so many namespaces: https://github.com/day8/re-frame/blob/master/src/re_frame/core.cljc#L576-L597
ah yes I do this already, but I need to be able to resolve namespaced keywords ::card/card
So you can point to a function, but I guess you need to copy the docstring and any other meta
where ::card
is one of my ui libs
thats why I think an auto included list of requires would be a good fit here
(ns
(:require-shadow :exclude [some.unwanted.ns]))
(:require [[the.usual :as whatever]])
hm, I wonder if I can hack the ns macro and extend it with this
oh for sure, but I also wouldnt expect this to work outside of shadow
Here is convo about this from before, Thomas commented: https://clojurians-log.clojureverse.org/shadow-cljs/2019-10-21/1571698320.305600
hey yall. I have a macro that spits out some cljs code and I'd like to configure the output of the macro based on a var that, ideally, the user can pass in. Anyone have any ideas how to go about that? I guess in the worst case I could deal with the config at runtime in cljs instead
so letting user specify it as a macro argument is not convenient? you want something to configure this once externally?
yea, it's for a library - a wrapper around emotion css-in-js. it would be a global config to determine if the library assigns the component name as part of the className for the generated component. you'd specify :full to get ns/symbol :short for symbol or nil to not apply it. I have it using metadata for each individual call so you can override at the single level, but I'm thinking you could have a release build disable all className assignment, but you'd keep it for dev to see your components in the elements tab in devtools