This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-06-10
Channels
- # announcements (1)
- # babashka (178)
- # beginners (216)
- # bootstrapped-cljs (1)
- # brompton (5)
- # calva (3)
- # chlorine-clover (1)
- # clj-kondo (2)
- # cljdoc (37)
- # cljfx (4)
- # cljs-dev (2)
- # clojure (360)
- # clojure-chile (8)
- # clojure-europe (3)
- # clojure-italy (5)
- # clojure-nl (9)
- # clojure-spec (2)
- # clojure-sweden (1)
- # clojure-uk (61)
- # clojuredesign-podcast (1)
- # clojurescript (83)
- # clr (2)
- # conjure (4)
- # core-async (14)
- # cursive (20)
- # data-science (2)
- # datomic (15)
- # docker (11)
- # emotion-cljs (1)
- # figwheel-main (28)
- # find-my-lib (1)
- # fulcro (46)
- # helix (16)
- # honeysql (14)
- # jobs (10)
- # jobs-discuss (17)
- # joker (1)
- # juxt (9)
- # kaocha (8)
- # leiningen (3)
- # meander (3)
- # news-and-articles (1)
- # off-topic (110)
- # pathom (7)
- # pedestal (4)
- # protojure (2)
- # re-frame (12)
- # reagent (25)
- # ring (4)
- # shadow-cljs (109)
- # spacemacs (9)
- # specter (1)
- # sql (3)
- # tools-deps (23)
you don’t need to specify the version of shadow-cljs in shadow-cljs.edn. you specify it package.json
I'm looking into splitting my cljs code into modules, and using shadow.lazy
to load the code dynamically on my SPA. In production I have static assets fronted by nginx and served by a CDN. After digging into it a little I can't figure out how a call to shadow.lazy/load
translates into a web request, and I can't confirm whether or not it's still going to play well with my setup in production. Any pointers are greatly appreciated!
I'm seeing $jscomp
errors on 2.10.5, with :output-feature-set :es6
set. I'm able to work around it by setting :output-feature-set :es-next
although that seems like a less-than-ideal workaround?
The $jscomp
errors appear to be linking back (through sourcemaps) to places where my NPM depdendencies are using async
or other later-than-ES6 features in their original (not distributed) source -- a specific example of this from my dependencies is react-hook-form
.
On that hunch I switched to the :es-next
feature set, but I assume this is some kind of issue with polyfills being used?
I'll try to reduce this example down at some point, but hopefully the tracing back to the use of async is at least somewhat informative!
Potentially relevant to https://github.com/thheller/shadow-cljs/issues/709 ?
@schpaencoder the version is printed on every startup?
run shadow-cljs watch app
or whatever and paste the output. I'd be very surprised if it didn't print the info on startup 😛
@guaqueta shadow.lazy basically just figures out which module the namespace is in your are referencing and then loads that via :asset-path + <module-id>.js
using shadow.loader
. you may set :module-loader-init false
in your build config but then must call (shadow.loader/init "
before actually using the loader anywhere (eg. first thing in :init-fn
)
Thanks for the reply, I think this is exactly what I needed (also, thanks for shadow-cljs, it's been super helpful).
so if you set that to a full URL at build time it will be used. eg :asset-path "
will end up loading your modules from there. so :modules {:main ...}
would be
Oh, neat. How would I configure :asset-path
to have different values for dev vs prod builds?
https://shadow-cljs.github.io/docs/UsersGuide.html#_release_specific_vs_development_configuration
Also, just for context: I was trying to catch the loader in action, so to speak. So in dev I added a middleware to my ring app to priint out all requests, and then I was hoping to see the request for the new module come through at the appropriate time (i.e. when I interact with my app in a way that should trigger the load). My app works as expected, so the new code clearly is getting loaded, but I just don't see the request that actually fetches the js file. I dug around a bit and saw that shadow.loader
uses google module manager which in turn uses bulkloader which in turn uses Xhrio, so it should just come down to a web request for that asset. I'm probably just missing something obvious and now I've rambled for too long, but anyways that's where I was coming from.
but yes they are regular xhr requests fetching the sources. "when" depends entirely on how you use it.
Indeed, I do see the requests in the browser console happening when I expect them. I must have done something dumb in my logging middleware.
@tekacs for starters it would help to know which npm package is causing the issue. might give me something reproducible.
sorry if I wasn't clear -- it's the use of react-hook-form
-- specifically when it uses any later-than-ES6 features like async
functions.
I am doing something wrong again. I ran into this issue: https://github.com/bhauman/devcards/issues/168 tried to add the config that fixes it, and I get IllegalArgumentException: Wrong number of args passed to keyword: :ns-aliases
I tried to search for the docs for ns-aliases in both the shadow-cljs user guide, shadow-cljs github repo, and in clojurescript docs, I didn't see it anywhere.
I reverted to 0.2.6 devcards and that works fine still, so I am not stuck with this, to be honest, if devcards is this troubling, I think I should move to a different lib that has similar features, I think I saw a couple.
the devcards thing I about getting :bundle
to work I think. there isn't really any clear guidance on how that is supposed to work with foreign-libs in regular CLJS yet. not sure how that will turn out.
workspaces is the one I remember clearly as an alternative, yes. I am all for reducing configuration. When I have to use undocumented config options to make something work, that's exactly when I know my colleagues will complain.
I think I saw it somewhere mentioned that you also don't want to encourage people using ns-aliases, I suspect that's the reason I couldn't find it. Or that I missed it, but it's there, which is always an option : )
trying to debug why I’m getting a “No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code.” message from shadow-cljs. It works in my dev environment, but I’m trying to debug something in my test env, so my app is started up in test mode on a different port.
I’ve read this: https://shadow-cljs.github.io/docs/UsersGuide.html#missing-js-runtime
which makes sense… but not sure how to debug what is missing
I can see main.js
is served in my test app, and it appears to be the same one that is built for dev app… as moving it causes it to 404
ahh its ok I’ve fixed it
I'm embedding shadow components with a modularized build as cross - origin. In the dev-setup (containerized hosts), the page tries to load its source-maps from the embedding host, instead of the origin. Probably because shadow loads its code via eval, in this mode. :devtools-url
doesn't show any difference either, so I'm creating a route in the embedding service, as a workaround for development. Does shadow also want a ticket for this?
@bendlas I don't quite understand what you are asking. if the eval-loader is a problem you can use :devtools {:loader-mode :script}
in your build config to go back to regular script
tags or fetch
Can I get the main.js (or other entry js files) javascript source code from the shadow compiler state map after compiling? I can't seem to find where it would be
:devtools-url
only really controls the websocket connection. it doesn't have anything to do with how the code is loaded into the page initially
I mean switching to deno
would just give you deno_modules
or whatever the name for the directory it uses is
well security is rather useless given that you need to give all the permissions if you want websocket REPL and hot-reload to work
deno is interesting but I don't quite see the point for CLJS given how restrictive it is
do you have many of these 300mb node_modules? I think I got to some GBs in all my repos together, but it's not terribly overwhelming, not even on a smallish laptop ssd
have you heard about tink? https://github.com/npm/tink
No, because at the time I heard about it was at the very beginning. I didn't realize that the development seemingly stopped last year.
Switching to the script-loader actually made it worse, because now it attempts to load the scripts from the first party host as well, and also trips over my :asset-path "/"
config XD
So when embedding into a page from
embedding.host
• eval loader basically works, but can't find its source maps: DevTools failed to load SourceMap: Could not load content for
• script loader tries to load code from the embedding host, but source maps presumably would work, if that was fixed (and maybe the asset-path issue): GET
I understand, that this may not be a supported use case, yet, so am working around it with adding proxy routes, but if you'd want to support this for shadow, I'd be happy to help with that as well, @thheller
why are you serving the files from a different host though? its just static files, whyt not just serve them from the regular host?
to do with our current deployment structure and an in-progress refactoring, where we use shadow modules in a legacy application
but OTOH, legacy has just the loader stubs, which don't change that often and there hardly a case for not including these advanced-compiled, even during development, so your idea is probably still the better one ... I'll go with that.
Is there some documentation that enumerates all of the keywords and their definitions available in shadow-cljs.edn?
If an index.html
exists in the shadow http server root paths and :push-state/index
is set to other-index.html
, shadow will still serve index.html
by default, not other-index.html
. Is this the desired behavior?
@kenny I guess that could be considered a bug. index.html always is picked first since it is picked way before the push-state handler is ever called.
Not sure if this is already know/reported, but I'm trying out shadow-cljs 2.10.5. I have a cljs browser repl open, when I eval an aliased ns I get Invalid keyword error:
; in ns form: (:require [com.fulcrologic.fulcro.application :as app])
(-> app1 ::app/runtime-atom)
(-> app1 ::app/runtime-atom)
dummy.cljs [line 1, col 28] Invalid keyword: ::app/runtime-atom.
Tried using 2.9.8 and there is no issue there(println ::foo)
(println (keys (app/fulcro-app)))
(println ::app/hi)
;; repl window:
(println ::foo)
:app.devcards-play/foo
=> nil
(println (keys (app/fulcro-app)))
(:com.fulcrologic.fulcro.application/id :com.fulcrologic.fulcro.application/state-atom :com.fulcrologic.fulcro.application/config :com.fulcrologic.fulcro.application/algorithms :com.fulcrologic.fulcro.application/runtime-atom)
=> nil
(println ::app/hi)
dummy.cljs [line 1, col 18] Invalid keyword: ::app/hi.