Fork me on GitHub
#shadow-cljs
<
2021-12-18
>
nbdam06:12:59

Hi. Is there a way to pause/resume hot reloading during REPL use?

thheller06:12:56

@nbdam from a clojure REPL you can call (shadow.cljs.devtools.api/watch-set-autobuild! :the-build-id false) to disable and true to enable again

nbdam07:12:27

excelent, thanks!

haywood16:12:04

am i correct in thinking I can’t use (cljs.analyzer/analyze in a non-bootstrapped build target? I’m “just” looking to get the AST structure for some code at runtime

thheller17:12:35

depends. you can use analyzer without but you won't get very far without at least the analyzer data for cljs.core. which in turn means self-hosted

Schmoho17:12:02

Hi! I am trying to get a minimal thing with OpenLayers to work, referring to this: https://stackoverflow.com/questions/10349168/clojurescript-openlayers and this: https://code.thheller.com/blog/shadow-cljs/2017/11/10/js-dependencies-in-practice.html Problem is, if I use the (js/OpenLayers.Map. "map") syntax, shadow-cljs complanis OpenLayers is not defined, if I use (:require ["ol" :as ol]) I can define a map like (def mapp (ol/Map. "map")) but I don't know how to use constructors like (js/OpenLayers.Layer.OSM. "Simple OSM Map"). Also, using this require, I cannot send the namespace expression via the nREPL connection in Clojure-Kit from IntelliJ, because the ns macro is considered invalid (shadow-cljs compiles fine however ...). So, what is the correct way to do stuff like this in CLJS with shadow? Is requiring a library like this something very shadow-specific? I guess it might be possible to require the library via the html (then the js/OpenLayers.Map. thing should work, right?) but I kind of feel like this should not be the way

thheller17:12:09

@d.eltzner don't use anything from that SO question

thheller17:12:10

> Asked 9 years, 7 months ago

thheller17:12:21

none of that is relevant today I guess

thheller17:12:43

ol is basically OpenLayers so use that as a regular alias

thheller17:12:54

js/OpenLayers.Map. would become ol/Map.

Schmoho17:12:19

yeah so much I got alright, but I'm wondering about the Layer.OSM. part ...

thheller17:12:22

(js/OpenLayers.Layer.OSM. "Simple OSM Map") would become (ol/Layer.OSM. "Simple OSM Map")

thheller17:12:40

swap any js/OpenLayers with ol/

Schmoho17:12:44

then it's really just that OpenLayers API probably has changed

thheller17:12:00

yeah that too maybe

Schmoho17:12:57

the other thing, any idea why I'd get an error trying to send a ns declaration using this require via Clojure-Kit? it's the usual invalid macro syntax thingie when there's invalid stuff in a namespace delcaration

Schmoho17:12:17

Syntax error macroexpanding clojure.core/ns at (src/myproject/core.cljs:1:1). ((:require [reagent.core :as r] [reagent.dom :as d] ["ol" :as ol])) - failed: Extra input spec: :clojure.core.specs.alpha/ns-form

thheller17:12:26

I don't know what Clojure-Kit is but I guess it doesn't understand the string require syntax. or you are eval'ing in a clojure repl. clojure doesn't support it

Schmoho17:12:44

it's a free-to-use intellij plugin ... doesn't seem like a good idea using that actually, I just realized there are actually free licenses for cursive

Schmoho17:12:12

I'll see if the problem remains then. Thanks very much for claring the require thingie up for me!