This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-12-06
Channels
- # adventofcode (112)
- # announcements (6)
- # beginners (197)
- # boot (3)
- # calva (52)
- # cider (25)
- # clara (14)
- # cljdoc (6)
- # clojure (147)
- # clojure-austin (6)
- # clojure-berlin (7)
- # clojure-brasil (2)
- # clojure-europe (3)
- # clojure-india (4)
- # clojure-italy (8)
- # clojure-new-zealand (2)
- # clojure-nl (7)
- # clojure-russia (7)
- # clojure-spec (29)
- # clojure-uk (63)
- # clojurescript (103)
- # core-async (5)
- # cursive (11)
- # datomic (16)
- # devcards (1)
- # emacs (28)
- # figwheel-main (3)
- # fulcro (97)
- # graphql (4)
- # hyperfiddle (1)
- # jobs (1)
- # kaocha (3)
- # lumo (9)
- # nrepl (4)
- # off-topic (29)
- # onyx (1)
- # pathom (4)
- # pedestal (8)
- # re-frame (24)
- # reagent (1)
- # reitit (13)
- # ring-swagger (7)
- # rum (11)
- # shadow-cljs (79)
- # sql (46)
- # tools-deps (67)
- # yada (8)
(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?
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" java.io.FileNotFoundException: Could not locate cljs/main__init.class or cljs/main.clj on classpath.
at clojure.lang.RT.load(RT.java:463)
at clojure.lang.RT.load(RT.java:426)
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(RestFn.java:408)
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(RestFn.java:142)
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(RestFn.java:137)
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(RestFn.java:137)
at clojure.lang.Var.applyTo(Var.java:702)
at clojure.main.main(main.java:37)
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
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
@rinam did you verify that you do not get that error when using :parallel-build false
+ :advanced
? :parallel-build
should not affect :advanced
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
Is there anything that I should be aware of when upgrading to this version? Any deprecated functions?
There was that map-entry change, from vectors to legit MapEntry, but unlikely you'll hit it
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 ? https://github.com/fkhadra/react-toastify
I get this error;
Invariant Violation: Unable to find node on an unmounted component.
@dustingetz @borkdude goog.global
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
@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: https://google.github.io/closure-library/api/goog.date.duration.html
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
GCL is already included in all ClojureScript projects as well, so you should be able to just require the function: https://github.com/clojure/clojurescript/wiki/Google-Closure-Library#requiring-a-function
if (ms < goog.date.duration.MINUTE_MS_) {
/**
* @desc Duration time of zero minutes.
*/
var MSG_ZERO_MINUTES = goog.getMsg('0 minutes');
return MSG_ZERO_MINUTES;
}
why do they have this 😄@bravilogy I suppose you could always check yourself whether the time is less than one minute, and if so, just display (/ ms 1000) seconds
@dnolen cool. it seems goog.global
is used in getObjectByName
, so you can do:
(goog.getObjectByName (munge "cljs.core.some?"))
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
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
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
if I want that
@thheller https://github.com/r0man/sablono for instance? thanks!
There is also https://github.com/teropa/hiccups if that doesn't work for you
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 https://github.com/metosin/komponentit/blob/master/src/cljs/komponentit/clipboard.cljs 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 https://hackernoon.com/copying-text-to-clipboard-with-javascript-df4d4988697f, 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
el.style.position = 'absolute';
el.style.left = '-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
el.select(); // 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/project-distro.zip :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?]
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!
… @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. :)
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
(sorry I think maybe you were saying that re: webpack above, didn't read closely enough)
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. https://github.com/victorb/cljs-peer-star-app
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?