This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-08-26
Channels
- # adventofcode (2)
- # announcements (7)
- # babashka (20)
- # beginners (77)
- # brompton (6)
- # calva (4)
- # clj-kondo (28)
- # clj-together (1)
- # cljdoc (2)
- # cljfx (10)
- # cljsrn (1)
- # clojure (77)
- # clojure-europe (33)
- # clojure-gamedev (12)
- # clojure-uk (11)
- # clojurescript (95)
- # clojureverse-ops (4)
- # core-async (4)
- # core-logic (1)
- # cryogen (2)
- # cursive (14)
- # data-science (3)
- # datomic (47)
- # duct (1)
- # emacs (7)
- # fulcro (51)
- # gratitude (8)
- # helix (14)
- # hoplon (4)
- # improve-getting-started (60)
- # jobs (1)
- # jobs-discuss (4)
- # joker (11)
- # lsp (99)
- # meander (62)
- # membrane (5)
- # news-and-articles (3)
- # off-topic (64)
- # pathom (3)
- # polylith (11)
- # practicalli (7)
- # react (1)
- # reagent (8)
- # reveal (15)
- # shadow-cljs (78)
- # specter (7)
- # sql (16)
- # tools-build (1)
- # tools-deps (29)
- # workspaces (1)
- # xtdb (17)
Hi I want to make a chrome extension and it would basically take a paragraph of text and add bounded boxen to different words. Anyone have any experience working on chrome/firefox extensions leveraging CLJS? Part of what stumps me is the fact that I could potentially use regex to figure out what's what, but the box-drawing has got to be pretty flexible... so imagine you have a sentence like "the elephant goes to school" .. I want to draw a box around "the elephant" and "to school." But I also want it to work on partial inputs / not crash because sentences are incomplete... so "the elephant goe" would get a box around "the elephant" and it could somehow wait for more useful input.
Hey @U3ES97LAC! I came across this that uses clojurescript https://github.com/jiacai2050/gooreplacer not sure if this could help for reference
Oh awesome, really appreciate the link!
I don't read Chinese [yet]...
in ClojureScript we simply allow that in the cases where the import includes chars that cannot be in a symbol
$
is valid in symbols and the convention was taken from Clojure usage of inner classes
@dnolen yeah cool, I kind of knew that but in clj-kondo it's used as a way to differentiate between JS libs and clojure namespaces. I should probably rethink that.
Now that I've actually got more experience with this myself, I know where the problems are.
yes, understood. it's not invalid to use strings only for JS libs though, and that's what people have been doing to satisfy the static analysis. I will see if there's a better solution though.
Hey, I’m looking for example how to use directly firebase (recent, ver. 9) from ClojureScript (shadow-cljs). I have problem with requiring of right functions directly (without using fancy wrapper). Do you have maybe working examples with using v9?
following the documentation https://firebase.google.com/docs/database/web/read-and-write?hl=en&authuser=0#web-version-9_1
import { getDatabase, ref, set } from "firebase/database";
const db = getDatabase();
set(ref(db, 'users/' + userId), {
username: name,
email: email,
profile_picture : imageUrl
})
.then(() => {
// Data saved successfully!
})
.catch((error) => {
// The write failed...
});
I should be able to “require” the getDatabase functions directly right?(ns some.fb.db
(:require ["firebase/database" :refer [getDatabase]])
?I’m able to initialize firebase via:
(ns giggin.fb.init
(:require ["firebase/app" :as firebase]))
(defn firebase-init
[]
(firebase/initializeApp {...})
but “importing” of database is failingHave you seen this section? https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages Not just the table but also what follows.
Ok, time to try and use some Specter in this clojurescript project.. How do I properly add it to the project? So far I've only added node modules (using shadow-cljs)
also is there a convention for naming the import since using s as the documentation suggests seems to collide with accepted practice for spec.
Just as you would add a regular Clojure dependency. Shadow-cljs has examples in its documentation. Haven't seen any convention, just use whatever you prefer. Do note that using Specter will significantly increase the bundle size.
@rdonahue there is no convention, and using s
for spec is not a convention - you can do whatever you like
it's the whole point of ns aliases - you're free to pick names best suited to your project
@rdonahue as to adding stuff to Clojure projects it depends largely on the tool - I think shadow has it's own way of doing it
Continuing on the cljs vs js lib "namespace", are there any heuristics that can be applied whether to detect a cljs namespace vs js lib, beyond just trying to load the js lib, catch and then try the cljs lib? can also first check the classpath for the cljs lib and then try the js lib This is more a question about how CLJS itself implements it. I can also just go read the source.
@borkdude note that there are significant differences here between what ClojureScript does and what shadow-cljs does
we indexed Closure Library - you can requires a Closure Library just like a normal CLJ namespace
right. in nbb I have the luxury that I can use resolve (on a require created with createRequire) to lookup the JS source first. I just wonder if that would be correct: JS and if that fails, then try CLJS, in that order.
again the whole point of the ClojureScript design is "who cares where this stuff comes from?"
yes, it makes sense, I just have never used it myself, but I can imagine that there's a use case for it (like you've mentioned). this is helpful, thanks
does the async ESM stuff complicate stuff for CLJS or is it just a matter of setting the right JS language target and it generates import
stuff?
yeah. right now CLJS uses google closure's way of bundling and loading modules, which is distinct from async import.
you can use async import to get external JS to load, but that isn't something that involves the compiler in any way. you would just call (js/import ,,,)
or whatever
but my experience w/ interop heavy stuff in Clojure & ClojureScript is it's a losing game
in that some things are better written in Java and JavaScript (rather than adding features to achieve parity which is always a moving target)
my primary complaint - though it's somewhat of our creation is that Closure doesn't follow a Hickey-esque approach to development
I think in the old days Closure development was slower because they were a lot of consumers of the APIs
it's also hard to go back in time to 8 (?) years ago and think to pick any other solution
it really was the best at the time, and any solution built on top of other existing tech back would have seen at least as much churn and discrepancies with current bleeding edge tech
yeah ESM essentially cemented the status quo a lot of other bundlers set w/ using closures as modules rather than object namespaces
not saying that Racket is bad - but that where ESM comes from, people that worked on Racket
One of the very best ideas that Rich Hickey had (among all the others) is form-at-time compile
I guess module-at-time compilation makes some mechanical sense, since pragmas set at the beginning of a module can radically change the way compilation is done. is that how most schemes work?
StrongTalk / Self laid the foundation for proving you could optimize all kinds of wild thing at runtime
whereas previously people believed you had to do this whole program optimization up front
Clojure whole idea was that you have runtime optimizing compiler and fast GC - so just focus on the stuff that matters
ClojureScript was created right at the time that was becoming true for JavaScript - and the design is based on the same principles
Is there a canonical way to tell at runtime whether you're in the browser or in node?