This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-01-15
Channels
- # babashka (13)
- # beginners (37)
- # calva (19)
- # cider (15)
- # clj-kondo (2)
- # clojure (152)
- # clojure-norway (1)
- # clojure-sweden (10)
- # clr (5)
- # emacs (19)
- # honeysql (1)
- # introduce-yourself (19)
- # joyride (1)
- # lsp (4)
- # malli (5)
- # membrane (6)
- # off-topic (11)
- # pathom (18)
- # polylith (13)
- # practicalli (3)
- # releases (4)
- # shadow-cljs (38)
Perhaps an obvious question - I’m using the mapbox npm package, however on saving the page doesn’t render my component only when I evaluate it on the REPL, what’s the issue here?
https://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html is the only thing I can link you to in general
otherwise need more specific code examples. don't know what you are doing, so can't give specific answers
Sorry for being non informative enough 😉 Basically I render a map. When saving, hot reloading shows blank page, but evaluate the code on the REPL automatically renders the map on the page. My intializers are:
(defn home-page []
[:<>
[items-list]
[map-container]])
;; -------------------------
;; Initialize app
(defn mount-root []
(d/render [home-page] (.getElementById js/document "app")))
(defn ^:export init! []
(mount-root))
the map components look like this:
(ns coffee-tlv.components.map-container
(:require ["mapbox-gl" :as mapbox]))
(defn map-container []
[:div#map])
(set!
(.-accessToken mapbox)
"pk.eyJ1IjoiaXRheWRyZSIsImEiOiJja2RlczU5bmIwcDlzMnducmVuMDQ4cWlyIn0.BSyB9nVoIsnazX2PeUyPyg")
(def tlv-map
(new
(.-Map mapbox)
#js
{:container "map",
:style "",
:center #js [34.79 32.07],
:zoom 15}))
I created this example for pdfjs a while ago https://github.com/thheller/reagent-pdfjs
this being the important parts https://github.com/thheller/reagent-pdfjs/blob/master/src/main/demo/app.cljs#L19-L22
Taking a look, thanks a lot!
Trying to use the latest https://github.com/openlayers/openlayers from npm and getting many this kind of warnings with realease builds:
> Resource: node_modules/ol/layer/Layer.js:111:20
> Parse error. name not recognized due to syntax error.
.. and the release builds are thus broken. In dev-mode all is working well. I guess the error is coming from Closure and it has hard time processing OpenLayers javascript..?
My shadow-cljs.edn
looks like this:
{:lein true
:dev-http {3449 "resources/public"}
:builds
{:app
{:target :browser
:asset-path "js/compiled"
:output-dir "resources/public/js/compiled"
:compiler-options
{:infer-externs :auto}
:dev
{:closure-defines
{re-frame.trace.trace-enabled? true}}
:modules
{:app
{:init-fn lipas.ui.core/init}}
:devtools
{:after-load lipas.ui.core/mount-root
:preloads [devtools.preload
day8.re-frame-10x.preload]}}}}
Just tried :output-feature-set :es8
and that seems to get rid of the warnings. :thinking_face:
Argh. After manually deleting all cached files and previously generated output I still get these warnings with output-feature-set :es8
. Does someone have advice what to try next?
Ha! Among the aforementioned warnings there was also a single extern problem that caused the release build to blow up. I guess those errors from Closure don’t matter 🤷
Ok, I did more methodological tests and following seems to be the case
• “Parse error. name not recognized due to syntax error.” happens when outputting < :es8
• With :es8
I don’t see the errors and my build & app works
◦ I had an unrelated extern problem which I was able to fix
Last question is that are there any known problems with es8
as output feature set? I mean other than “doesn’t work with IE11". 😉
I checked from analytics and during past 3 months we’ve had one (1) IE11 visitor. Maybe the World is ready for es8..?
Also, thanks for shadow Thomas! I just migrated my main project from good old lein-figwheel + webpack and it’s been a joy to work with shadow. 🙏
not sure what would cause this error but in the past the closure compiler had issues processing some @
directives in comment blocks. the files from OL seem to be full of them. I'm guessing it has some issues with this
/***
* @type {LayerOnSignature<import("../events").EventsKey>}
*/
Oh, interesting. Could be that my testing wasn’t methodological enough. 😅 I’ll try one more time with default :output-feature-set
In the docs there’s > By default the generated JS output will be compatible with ES6 and all “newer” features will be transpiled to compatible code using polyfills. probably outdated?
I also upgraded shadow from 2.20.15
=> 2.20.20
in the process. Dunno if this could explain some of the wierdness