This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-03-31
Channels
- # announcements (4)
- # aws (1)
- # babashka (52)
- # beginners (178)
- # boot (4)
- # cider (2)
- # clj-kondo (10)
- # cljs-dev (39)
- # clojure (744)
- # clojure-europe (12)
- # clojure-germany (6)
- # clojure-india (56)
- # clojure-italy (5)
- # clojure-nl (60)
- # clojure-spec (9)
- # clojure-sweden (14)
- # clojure-uk (36)
- # clojuredesign-podcast (6)
- # clojurescript (11)
- # community-development (5)
- # core-async (4)
- # data-science (6)
- # datomic (6)
- # emacs (7)
- # events (4)
- # exercism (33)
- # fulcro (11)
- # funimage (2)
- # graalvm (29)
- # java (1)
- # joker (3)
- # lambdaisland (15)
- # malli (2)
- # meander (55)
- # mid-cities-meetup (1)
- # nrepl (8)
- # observability (4)
- # off-topic (2)
- # pathom (5)
- # re-frame (31)
- # shadow-cljs (73)
- # spacemacs (18)
- # sql (27)
- # test-check (14)
- # testing (1)
- # tools-deps (5)
- # xtdb (13)
I guess the only way for shadow-cljs to find out about them, is to access the resources.
I'm trying to serve a web worker but I'm running into Content Security Policy issues when the browser tries to init the worker. It appears the Content-Security-Policy
header is not being sent. Am I using :push-state/headers
wrong?
{:source-paths ["src"]
:dependencies [[binaryage/devtools "0.9.7"]
[reagent "0.8.0-alpha2"]]
;; serve the public directory over http at port 8700
:dev-http {8700 {:root "public"
:push-state/headers {"Content-Security-Policy" "default 'self'"}}}
:builds
{:app {:target :browser
:output-dir "public/js/compiled"
:asset-path "/js/compiled"
:modules
{:common {:entries []}
:main {:entries [pwa.core]
:depends-on #{:common}}
:service-worker {:web-worker true
:depends-on #{:common}
:init-fn pwa.service-worker/init}}}}}
@ctamayo the server doesn't set any CSP by default so you are likely setting it in your HTML?
@thheller no, it's just the default generated index.html from lein new shadow-cljs pwa +reagent
@hoertlehner each library can have its own deps.cljs
in the .jar
it ships. they won't conflict.
in case of web servers that serve from embedded resources, they ar eonly able to serve one version.
but instead of asking for one thing by name you can also ask for all the things using that name
so there can always be multiple versions, there are just simple rules to determine which one is the "winner" when looking up a single one by name
I'm trying to use the auth0 SinglePageApp client library like this
"dependencies": {
"@auth0/auth0-spa-js": "^1.6.5",
and then from within cljs
(:require ["@auth0/auth0-spa-js" :as auth0]
...
(auth0/createAuth0Client auth0-config)
but I just see amain.js:2226 failed to load uix.control_auth.js TypeError: module$node_modules$$auth0$auth0_spa_js$dist$auth0_spa_js_production.createAuth0Client is not a function
at eval (control_auth.cljs:23)
at eval (alpha.cljc:162)
at eval (alpha.cljc:140)
and when I look in the repl I see that the namespace is a function
(require '["@auth0/auth0-spa-js" :as nsauth])
=> nil
(type nsauth)
=> #object[Function]
the resources/public/js/cljs-runtime/module$node_modules$$auth0$auth0_spa_js$dist$auth0_spa_js_production.js.map
looks like
"names":[...,
"createAuth0Client",
...]
the original function is declared as
export default async function createAuth0Client(options: Auth0ClientOptions) {
so it IS default, (which I can call),
but why cannot I call the real function?
is it the ES8-only async
causing linking problems?I set my :compiler-options
to
:compiler-options
{:infer-externs :auto
:closure-warnings {:global-this :off}
:closure-defines {"goog.DEBUG" true#}
:output-feature-set :es8}
but it doesn't seem to have helped...@ben.hammond nothing to do with your config
I'd like to understand why the actual named function call doesn't work though if I can
ah okay; that is the gap in my understanding
well not really. generally default
exports don't have a name. it is just the default
so import Foo from "@auth0/auth0-spa-js"
is just as valid as import createAuth0Client from "@auth0/auth0-spa-js"
currently teaching two people cljs using shadow-cljs, so far so good 🙂 thanks for making it such an enjoyable experience
I did a few recently, e.g. https://github.com/hindol/genesis
Let shadow write files to docs/
instead of the default public/
and in Github's repo settings, enable pages from docs
folder.
Everytime you want to update the site, remember to 1) first clean existing built files, 2) npx shadow-cljs release app
(assuming app is your build target) and 3) git push!
Thank you @UJRDALZA5
something i have found useful is to configure two separate targets, one for dev and one for prod, and have the prod target build to a different place from the dev target. This way you don't have to do the cleaning step.
great idea ! @UUSQUGUF3
That's a great tip! @UUSQUGUF3 Is it possible to share the same index.html
between two builds? By copying as part of the build step, perhaps?
https://shadow-cljs.github.io/docs/UsersGuide.html#_release_specific_vs_development_configuration
if you just want a different output dir for release then do :release {:output-dir "foo"}
in your build config
oh awesome, thanks for that :release
:output-dir
option 👍
my apologies for the fake news
@UJRDALZA5 in terms of build I use a Makefile to do the final build which invokes the production build and also copies files from public
to build
.
👍 will see if i can find a public one
though here i am using the technique which @thheller said not to use, with the two different targets. so i should update that.
you could also do it in Java if that is easier: https://shadow-cljs.github.io/docs/UsersGuide.html#clj-run