Fork me on GitHub

(set! (.-addClass dom-node) "className") ?


If a JS library uses ES6 features, would that cause any issues with Cljs? Put another way, everything else equal, would it be ok to use such a library?


I can’t think of any way that this would cause a problem for ClojureScript.

✔️ 4

Hey folks. What's the best way to get a cljs repl in a deps.edn project like advent-of-cljc? I tried the clj directions and got:

~/code/advent-of-cljc (master●)$ clj -m cljs.main
Exception in thread "main" Could not locate cljs/main__init.class or cljs/main.clj on classpath.
	at clojure.lang.RT.load(
	at clojure.lang.RT.load(
	at clojure.core$load$fn__6548.invoke(core.clj:6046)
	at clojure.core$load.invokeStatic(core.clj:6045)
	at clojure.core$load.doInvoke(core.clj:6029)
	at clojure.lang.RestFn.invoke(
	at clojure.core$load_one.invokeStatic(core.clj:5848)
	at clojure.core$load_one.invoke(core.clj:5843)
	at clojure.core$load_lib$fn__6493.invoke(core.clj:5888)
	at clojure.core$load_lib.invokeStatic(core.clj:5887)
	at clojure.core$load_lib.doInvoke(core.clj:5868)
	at clojure.lang.RestFn.applyTo(
	at clojure.core$apply.invokeStatic(core.clj:659)
	at clojure.core$load_libs.invokeStatic(core.clj:5925)
	at clojure.core$load_libs.doInvoke(core.clj:5909)
	at clojure.lang.RestFn.applyTo(
	at clojure.core$apply.invokeStatic(core.clj:659)
	at clojure.core$require.invokeStatic(core.clj:5947)
	at clojure.main$main_opt.invokeStatic(main.clj:317)
	at clojure.main$main_opt.invoke(main.clj:313)
	at clojure.main$main.invokeStatic(main.clj:424)
	at clojure.main$main.doInvoke(main.clj:387)
	at clojure.lang.RestFn.applyTo(
	at clojure.lang.Var.applyTo(
	at clojure.main.main(


If you want to go that way I think you just need to ensure that a recent clojurescript is in your deps


So, do I move it from the :test :extra-deps section to the regular :deps section? org.clojure/clojurescript {:mvn/version "1.10.439"} is in the extra-deps section of test.


⬆️ worked!


Self hosting ClojureScript drives me nuts. Make a tiny change in some unrelated place, and suddenly you can’t eval anything anymore


A few weeks ago I could eval the expression: (fn [a b] (not= a b))


But now? WARNING: Use of undeclared Var cljs.user/fn


so I changed it to eval: (cljs.core/fn [a b] (not= a b))


All that did was change it to: WARNING: Use of undeclared Var cljs.core/fn


To make it worse, the code runs just fine in node.js


It only broke in the system that includes this as a dependency


I should explain. That’s a cut down explanation. It’s really eval-ing: (fn [f1 d f2] (not= f1 f2)) And the response is:

WARNING: Use of undeclared Var cljs.user/fn
WARNING: Use of undeclared Var cljs.user/?f1
WARNING: Use of undeclared Var cljs.user/?d
WARNING: Use of undeclared Var cljs.user/?f2
WARNING: Use of undeclared Var cljs.user/?f1
WARNING: Use of undeclared Var cljs.user/?f2


This isn’t the first project that this has happened to me (though the other one was just something for fun. This time it’s for work). Everything appears to work, and then something apparently unrelated gets modified, and suddenly vars are “undeclared”. Like it runs out of space somewhere and starts losing data. Is anyone familiar with self hosting ClojureScript? Suggestions where I could track this down?


I do have a fallback position, which is to take the function I’m wrapping (in this case, the not= function), and call it directly with only the arguments it needs. Given the way the incoming data works, that will be annoying, but I can do it. Using eval was supposed to save me significant effort 🙂


I'm looking for ways to speed up the compilation I added :parallel-build true to compilation options It works fine when :optimizations :none But the're an error in the console Cannot read property 'prototype' of undefined when :optimizations :advanced


And ideas why :parallel-build true causes errors?


@rinam did you verify that you do not get that error when using :parallel-build false + :advanced? :parallel-build should not affect :advanced


Yes, I did


what are you using to compile? which cljs version?


Why isn't :parallel-build true default if it speeds up compilation?


@thheller I'm using version 1.9.660


that is rather old. try upgrading. I think there were a couple issues related to :parallel-build in the past. 1.10.439 is the latest release


Thanks, I'll try it


Is there anything that I should be aware of when upgrading to this version? Any deprecated functions?


I don't think so. may also need to bump your build tool though.


I'll try


Do you have any other idea for speeding up compilation?


There was that map-entry change, from vectors to legit MapEntry, but unlikely you'll hit it


yeah .. use shadow-cljs 😉

🔥 16

The newer cljs's cut compilation times in half, I thought


Wow! It will make a major difference to us, since we have a huge project in clojure


Yeah, david nolen and mike fikes did some crazy good optimization work the last release cycle. Def try it.


Have someone try to use react-toastify ?


I couldn’t get it done.


I get this error;

Invariant Violation: Unable to find node on an unmounted component.


But the component worked well.


Everything feels alright.


But the error disturbing me.


@dustingetz @borkdude is probably the best way


@rinam there were definitely compiler perf enhancements in the last release, but how much it will affect compilation time really depends on your project, many people report improvements but they were quite modest. Also twiddling JVM memory settings is a good idea in case you're not giving the process enough memory, a common problem


hi everyone. is it possible to convert duration that is in milliseconds, to time?


or should I defer to js methods?


time, as in like how much time was spent basically


@bravilogy what units are you trying to convert to specifically? Milliseconds to seconds? To hours?


If you're looking for a more natural language output (e.g. 6 hours, 7 minutes, 32 seconds), then you can use a function that exists within the Google Closure library:


basically it’s a little game I’m working on and players are given maximum of 3 hours to do something and whoever does it quickest, is the winner. so the most that should be shown is an hour. i.e. 1hr 2mins and 37seconds is a valid output


or just 12seconds is a valid output too


I see. Check the link above. I think that's exactly what you're after.


nice one, looking into it now 🙂 thank you!

👍 4

GCL is already included in all ClojureScript projects as well, so you should be able to just require the function:


if (ms < {
     * @desc Duration time of zero minutes.
    var MSG_ZERO_MINUTES = goog.getMsg('0 minutes');
    return MSG_ZERO_MINUTES;
why do they have this 😄


it will return 0 minutes in most cases


@bravilogy I suppose you could always check yourself whether the time is less than one minute, and if so, just display (/ ms 1000) seconds


Otherwise you can fall back to the duration function


yeah, probably that’s what I’ll do. thank you so much for your help


No problem


@dnolen cool. it seems is used in getObjectByName, so you can do:

(goog.getObjectByName (munge "cljs.core.some?"))

❤️ 4

how would i go about creating mock hiccup elements in my karma tests?

(ns ui.utils-test             
  (:require [cljs.test :refer [deftest is testing]]    
            [hiccup.core :as h]    
            [ui.utils :as utils]))
The required namespace "hiccup.core" is not available, it was required by "ui/utils_test.cljs".
"hiccup/core.clj" was found on the classpath. Should this be a .cljs file?
I'm in shadow-cljs, not sure how to do lein tree type thing to grep for hiccup (or whatever library is actually creating my elements...)


@hoopes hiccup is a clojure-only library. it does not support CLJS. you'll need some other library for that.


@thheller question, what do you thing of having something like {:install-cmd ["npm" "install" "--no-audit" "--no-save" "--no-package-lock" :packages]} the default npm command? it gets rid of a lot of noise and avoids polluting the repo


at least I want safe and package lock?


if it was my choice this feature would not exist at all


isn't this for transitive deps? do you check those changes in the parent lib?


I mean when I call yarn shadow in the client lib I want the deps pulled in but not in package.json of the client lib


unless I am missing something


not sure I understand what you mean


so I have a lib A which uses lib B containing a deps.cljs


when I do yarn shadow-cljs with defaults, it modifies the package.json of lib A


I think I do not want that


but I am curious to understand why


There is also if that doesn't work for you


:thumbsup: thanks!


Holy smokes — I’m embarrassed that I’ve spent 5+ hours on this problem, but I’ve finally narrowed it down to a surprising conclusion… Can anyone help me figure out how to solve this problem? I was using to copy text into the clipboard. It works terrific… but only when Google Closure compiler optimization is turned off. When optimization is turned on, the clipboard always remains unchanged. [insert lots of investigation] Mysteriously, the execCommand("copy") always returns false and fails to copy text to the clipboard when Closure advanced optimization is turned on. I even resorted to writing it purely in JavaScript, as per, and using js interop to call that function. And even when the execCommand in pure JavaScript, when called from a CLJS program that has been Closure optimized, it fails. Is there something I need to call that would enable execCommand("copy") to work in an CLJS/Closure optimized program? Many thanks in advance for helping me regain my sanity!!!! 🙂


// from: 
const copyToClipboard = str => {
  const el = document.createElement('textarea');  // Create a <textarea> element
  el.value = str;                                 // Set its value to the string that you want copied
  el.setAttribute('readonly', '');                // Make it readonly to be tamper-proof = 'absolute';           = '-9999px';                      // Move outside the screen to make it invisible
  document.body.appendChild(el);                  // Append the <textarea> element to the HTML document
  const selected =            
    document.getSelection().rangeCount > 0        // Check if there is any content selected previously
      ? document.getSelection().getRangeAt(0)     // Store selection if found
      : false;                                    // Mark as false to know no selection existed before;                                    // Select the <textarea> content
  const retval = document.execCommand('copy');    // Copy - only works as a result of a user action (e.g. click events)
      // ^^^ this works and returns true when CLJS is not Closure advanced optimized
      //     it returns false when Closure advanced optimization is turned on
  document.body.removeChild(el);                  // Remove the <textarea> element
  if (selected) {                                 // If a selection existed before copying
    document.getSelection().removeAllRanges();    // Unselect everything on the HTML document
    document.getSelection().addRange(selected);   // Restore the original selection
  console.log(" copyToClipboard : ", str);
  console.log(" copyToClipboard returned: ", retval);
console.log("loaded copyToClipboard widget!")


@genekim works fine for me. does your :advanced build maybe change something else that changes the semantics of the call? I think copy is only allowed as the result of a user event. so it can't be done via setTimeout or so IIRC


Howdy! I am having some trouble determining how to lein deploy/release my Serveless ClojureScript project to S3. What I have working => I have already configured my project with wagon plugin and releases/snapshots repos. When I lein deploy my distribution is pushed to the correct location in S3. The problem is that the distribution is a JAR file. Normally I would create a distribution by running sls package which would create a zip to deploy to AWS along with CloudFormation stack files. Serverless does log the lein command to the console, it looks like this:

lein update-in :cljs-lambda assoc :functions '[... function maps here...]' -- cljs-lambda build :output /output/path/.serverless/ :quiet
I would like to run this command as part of my deploy and as part of my release so I could at least push the zip file to my repositories in S3. Is this possible?


@thheller Holy smokes. Thank you for the data point! On the one hand, I’m delighted to know it works in certain conditions. On the other hand, I’m like 😱😱😱. 🙂 [Now scratching head, trying to figure out what could be different… It’s a re-frame app, but surely that can’t be it?]


not a clue. I tested with pure DOM interop (no react) and that worked fine.


Is it acceptable to cross post questions to other channels? For example the same question to Beginners and Clojure?


I’ve done it on occasion, in my desperation. :) FWIW, no one complained (or noticed. :). Good luck!


Moving to #re-frame


@thheller I’m sure you’re right! It’s an asynchronous event, and I’m sure it’s no longer an user-event. THANK YOU!!!!!


OMG. @thheller It worked! Wow! THANK YOU!!!! You’re so fantastic! (And you were fabulous in the defn and REPL podcasts. :)

😎 4
🙂 4

ugh, I've been fighting to have something basic working that uses clojurescript + figwheel + nrepl (for vim-fireplace integration) + webpack for external npm dependencies, but I can't seem to get both npm deps + nrepl to work together... Anyone knows any example with these used together?


@victorbjelkholm429 a good question to ask yourself - do you need :npm-deps


the answer is almost 90% ... no


if you're just talking about the webpack integration


what's the problem?


I don't see how nrepl has anything to do with that


(sorry I think maybe you were saying that re: webpack above, didn't read closely enough)


build stuff, and REPL integration are really quite independent


let me publish an example and pinpoint exactly where the issue is, it'll be easier


ok, I don't really need figwheel in the end, as long as rebuilding + remote repl can be setup in some other way. However, I cannot find any documentation on clojurescript on how that would be done. I made a greenfield project where the basics are setup but still missing some rebuilding + remote repl setup with clojure-tools.


so uh is jwt something i should look into instead of sessions?


question, does cljs.spec.alpha/check-asserts influence the instrument call in any way?