This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-04-15
Channels
- # announcements (3)
- # architecture (1)
- # babashka (52)
- # beginners (228)
- # calva (1)
- # chlorine-clover (31)
- # cider (9)
- # clj-kondo (16)
- # cljs-dev (25)
- # cljsrn (21)
- # clojure (116)
- # clojure-argentina (8)
- # clojure-europe (18)
- # clojure-france (17)
- # clojure-germany (1)
- # clojure-nl (5)
- # clojure-spec (49)
- # clojure-uk (63)
- # clojurescript (59)
- # community-development (14)
- # conjure (89)
- # core-matrix (1)
- # cursive (18)
- # data-science (1)
- # datomic (27)
- # exercism (4)
- # figwheel-main (5)
- # fulcro (38)
- # ghostwheel (8)
- # graalvm (5)
- # hoplon (2)
- # jobs-discuss (17)
- # juxt (1)
- # lambdaisland (5)
- # luminus (1)
- # lumo (9)
- # malli (7)
- # off-topic (32)
- # planck (24)
- # re-frame (14)
- # reagent (14)
- # reitit (14)
- # rum (23)
- # shadow-cljs (80)
- # spacemacs (2)
- # sql (6)
- # unrepl (1)
- # xtdb (2)
Is there any problem with the latest version? I just upgraded, and I'm not being able to watch a project, it fails with:
failed to parse websocket message {:type :repl/init, :repl-state {:shadow.cljs.repl/repl-state true, :current-ns ....
The piece of code where this is failing looks like this in the minified version:
Wh = function(a, b) {
var c = oaa[a];
if (void 0 !== c)
return c;
try {
Th.push(a);
var d = Uh[a]
, e = shadow$provide[a];
if (void 0 === d) {
if (void 0 === e)
throw "Module not provided: " + a;
d = {
exports: {}
};
Uh[a] = d
}
if (e) {
delete shadow$provide[a];
try {
e.call(d, $APP.Vh, Wh, d, d.exports)
} catch (k) {
throw console.warn("shadow-cljs - failed to load", a),
k;
}
if (b) {
var f = b.globals;
if (f)
for (c = 0; c < f.length; c++)
window[f[c]] = d.exports
}
}
} finally {
Th.pop()
}
return d.exports
}
Can you try to output to ES6? I think I had a similar issue and that resolved it.
try :compiler-options {:output-wrapper false}
too. looks like it has an issue with scoping somewhere?
Cool, switching to ES6 worked. For some reason, I was using es3 before.
I am trying to define different configs, so say :with-a :with-b :with-c or a combination thereof
You can use deps.edn to have different profiles, or google closure variables and dispatch on these
@hoertlehner require
must always be completely static so even if it was allowed outside the ns you still can't do anything that you can't do with ns
anways
If I ever disliked anything, it was the idea of conditional dependencies in javascript. Abuse of the abstraction : (
never needed it but some people at previous jobs hated me for this opinion and tried to convince me why it should happen
it is very useful to do sometimes ... just can't do it easily in an async context. thats really what makes everything difficult.
There is nothing wrong with dynamic conditional require/import if it uses different syntax/semantics as the static/sync version : )
Hi, question related with clojurescript macros: Given a list of `(def data [:foo :bar :baz])`, I want to dynamically generate:
(def foo (some-fn foo))
(def bar (some-fn bar))
(def baz (some-fn baz))
for some reason I'm not able to resolve the symbol data
in a clojurescript macro 😕in clojure, I got something like this doing the job:
(def data ["foo" "bar" "baz"])
(defmacro test-macro
[data]
`(do
~@(map (fn [e]
(let [e-name (symbol e)]
`(def ~e-name (some-fn ~e))))
(deref (resolve data)))))
(macroexpand-1 '(test-macro data))
How do you guys manage headless (end to end testing)? I would interested to have a solution where I could define a sequence of some re-frame events and that snapshot the results? Does it exists?
we do it with https://github.com/puppeteer/puppeteer
(defn ^:export ready
"Returns true the tick after no events are left to process in the re-frame queue"
[]
(let [state (.-fsm-state (:event-queue re-frame/default-frame))
dr @deferred-ready]
(cond
(and (= state :idle) (not dr))
(do
(if (exists? js/requestIdleCallback)
(js/requestIdleCallback #(reset! deferred-ready true))
(js/requestAnimationFrame #(reset! deferred-ready true)))
false)
(and (= state :idle) dr)
true
:else
(reset! deferred-ready false))))
(defn ^:export ready
"Returns true the tick after no events are left to process in the re-frame queue"
[]
(let [state (.-fsm-state re-frame.router/event-queue)
dr @deferred-ready]
(cond
(and (= state :idle) (not dr))
(do
(if (exists? js/requestIdleCallback)
(js/requestIdleCallback #(reset! deferred-ready true))
(js/requestAnimationFrame #(reset! deferred-ready true)))
false)
(and (= state :idle) dr)
true
:else
(reset! deferred-ready false))))
Thanks!!
So once you events are done you export it to png and compare the images?
@brunex it is very uncommon do write macros that depend on values of other vars. usually they should be self-contained and take all they need as an argument
Anybody here use reitit in conjunction with shadow-cljs having issues with hot reloading? I’m struggling a bit
I am a bit confused about the whole repl nrepl prepl socket repl situation... I realize it would be a bit much to ask for a complete picture, so can please someone just give me some hints on what are already fully working options for neovim/shadow-cljs? I have never done "repl driven development" but I like the sound of "auto-complete" 🙂
@peder.august whats the problem?
I’m pretty sure it’s not a shadow-cljs problem
see https://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html "Holding Code references in State"
Hmm thank you i’ll look into it 🙂
Thank you
I got it to work 🙂
Had to refactor my hooks
@ashnur I don't know neovim or which kind of REPLs it supports. most editors use nREPL.
Thanks, I am just checking out vim-iced. Sadly, cider comes with so many complications that I am way too anxious to try it 🙂
Having issues importing a js module dom-utils.js
from a js module js-main.js
which is required by a root.cljs
.
js-main.js is loaded just fine, but dom-utils.js isn’t.
;root.cljs
(ns website.main
(:require ["./js-main" :as main]))
(defn init []
(main/onDomReady))
; js-main.js
import {func1} from "./dom-utils.js"
export const onDomReady = () => func1("bar")
; dom-utils.js
export const func1 = (x) => foo(x)
All js files are laying in the same dir/package as main.cljs.
In shadow cljs target is
:dev
{:target :browser
:modules {:main {:init-fn website.main/init}}
:output-dir "resources/public/website"
:asset-path "/website"
:compiler-options {:output-feature-set :es8}}
___________
Issue
Browser says TypeError: Cannot read property 'func1' of null
---------
I see dom-utils.js file in sources tab, by the path /website/cljs-runtime/website/dom-utils.js
So perhaps I misconfigured output path or import.updated the post
dunno about all the fat arrows. not exactly sure how the closure compiler handles those
yes, this works
Thanks again! 🍺❤️
I can post this somewhere if that would be of any use
frankly I forgot the exact semantics of =>
so I don't know if it should be considered a bug or not
Hmm, I wasn’t fully honest. I also had
:compiler-options
{:output-feature-set :es8}
I disabled this :output-feature-set :es8
part. Arrows work now.
If I re-enable that it doesn’t matter arrows or not, nothing from dom-utils.js
will be visible in js-main.js
Maybe I am biased as a long term babel user, and honestly, I don't even like it or the whole situation, even so, it sounds like someone would purposefully write js instead of cljs (or maybe a colleague) and then they would use babel to make it more compliant, but then they would have to forget about what closure does and configure babel in an incorrect way. Plausible, of course, but if someone is in that specific situation, I think it's unfair to assume that they will make mistakes : )
The way I use babel is to allow specific features, not in a blanket, solve everything at once way.
the point is that closure is able to rewrite most JS features when needed and the code is guaranteed to work with the further optimizations closure does. the babel code is not.
That is your point which I didn't debate. I just added a corollary. But let me stop here since I don't intend to argue minor thing, I respect both of our times more : )
Thanks again! 🍺❤️