This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-01-25
Channels
- # aleph (12)
- # announcements (2)
- # beginners (40)
- # calva (8)
- # cider (26)
- # cljs-dev (71)
- # cljsrn (2)
- # clojure (122)
- # clojure-dev (9)
- # clojure-europe (2)
- # clojure-nl (2)
- # clojure-spec (42)
- # clojure-uk (20)
- # clojurescript (86)
- # cursive (15)
- # data-science (1)
- # datomic (42)
- # duct (4)
- # emacs (33)
- # events (1)
- # figwheel-main (2)
- # fulcro (33)
- # jobs (2)
- # jobs-discuss (46)
- # kaocha (13)
- # leiningen (9)
- # off-topic (62)
- # pathom (75)
- # quil (2)
- # re-frame (6)
- # reagent (13)
- # reitit (3)
- # shadow-cljs (52)
- # spacemacs (3)
- # specter (17)
- # sql (6)
- # tools-deps (2)
- # vim (3)
- # yada (28)
Question about artifact size: there's always been a strong sentiment in the js world that minimizing artifact size is super important... Does it still matter that much in 2019? If lower level libs are cached with a long ttl, isn't it not that big a deal, for most apps?
if only because the requirements of our apps will continue to rise, which will encourage us to package up more to the browser
for example, wait until people are packaging up whole runtimes / etc. in wasm and shipping them over grandpa’s AOL connection 😬
But once it's cached... The first time I open photoshop in my browser, I may have a few second delay, sure
that’s fine for photoshop, which is a power user application. but what about a marketing / promo site? or a health insurance app for viewing my claims?
it’s also a fact that we don’t care because we’re in a place with good connection, on our laptops. many people interact with the internet in very different conditions
think of developing countries, or even many places in USA who don’t have good fiber and have to rely on 3G / Satellite / etc.
obviously this is going to depend on your use case. I work in health care so I have to make sure that grandpa can see their medicare stuff without fuss. If you’re building a blockchain yogurt app for millennials or a photoshop-in-the-cloud for professionals, you might not need to worry quite as much
So, let's say a meg or two. Is it exorbitant for a user on a 3G connection to have to download a meg the first time they visit my promo site?
yes, I have already left and am on instagram if a site takes more than a couple seconds to load 🙂
Yeah, that's the main objective evidence I've heard.. some study proved that every extra second your site takes to load, some surprising number of users drop off.
But, something tells me, that study is mostly talking about the kind of clickbait that goes in AMP pages
clickbait AMP pages need to be very lightweight, cause that crowd barely conscious when doing their browsing.
they really don't care about what they're looking at... But for most use-cases, I'm not sure if people are so careless
if I’m on my laptop, a slow loading tab is nbd. if I’m on my phone, I get pretty frustrated after waiting 3 seconds. if I don’t really want to see this site, I’ll move on in my browsing
Not if you've gotta check claims in a health insurance app, right? It's only the most useless of click-baity things that our attention is so easily drawn away from
true, we were talking about promo sites. also things like marketing sites, news articles, etc.
for things like claims in a health insurance app, it’s more of an ethical concern that you are only servicing a certain section of the population: people with fast computers on good networks
We could say there's an ethical problem with a downloadable health app too.. 10 megs instead of 20. But that's just not a thing.
it is a thing! if my app takes up 300mb, or only works on latest iOS, etc. same problem
obviously there are diminishing returns on download size. the NYT pays way more attention and spends way more resources on reducing page load than we do on our health care site
Maybe a little... Not a huge thing. But you've persuaded me slightly back into the fold 😉
luckily the tooling is good enough today that just by using CLJS with optimizations and gzipping, you get a long way
is there a cljs equivalent of https://momentjs.com/docs/#/displaying/calendar-time/ (like iso8601 date string to Yesterday at 2:30
) or should i just use moment? cljs-time doesn’t appear to have this out-of-the-box. thanks very much for any help.
@hoopes There is some support for that kind of stuff directly in Closure Library. For example,
cljs.user=> (require 'goog.date.relative)
nil
cljs.user=> (goog.date.relative/formatDay (- (js/Date.) 1e8))
"Yesterday"
what do you fine scholars use instead of environ
to read things off of env, when you’re in nodejs land? Seriously, I can’t find anything nice to work with js/process.env
.
upd. Okay I did something “plain stupid but works ™”
(require '[cljs.nodejs :as node])
(defn env->clj
"Converts `js/process.env` into clj map"
[]
(-> node/process
.-env
js/JSON.stringify
js/JSON.parse
(js->clj :keywordize-keys true)))
But I still need something to “inject” default values. I can of course use npm’s dotenv
, but I’d rather prefer “clojuresque” approach. Maybe reading off dev.cljs.edn since I already have oneI use dotenv
because I could not find any Clojuresque way
we use dotenv and have made wrappers
I want to thank you very much theheller for the shadow-cljs. ❤️ Dashboard and the npm integration is just perfect!! Man you did a miracle!
Also documentation is looking so professional! I can see how much heart you put into this project!
it's not that uncommon in JS land to encode to json and back, to clone an object
really? never seen someone doing it in JS
@roman01la https://dev.to/ptasker/best-way-to-copy-an-object-in-javascript-827/comments see some of the answers here
not exactly a best practice but not that rare to see
> Good to see I'm not crazy! JSON.parse( JSON.stringify( obj ) ); seems to be a common 'shortcut'.
> why is everyone doing this JSON.stringify hack?
Yeah, I agree. That's stupid. if someone shows me an improved version of js->clj
that actually works that'd be awesome
when does it not work? I always use #(js->clj % :keywordize-keys true)
If you want to normalize the keys (reduce-kv (fn [i k v] (assoc i (goog.string/replace k "_" "-") v)) {} (js->clj process.env :keywordize-keys true))
can someone summarize what’s the hack and why you should not do it, and what to do instead?
Interesting food for thought, wrt js interop https://medium.com/@zandaqo/structurae-data-structures-for-high-performance-javascript-9b7da4c73f8
Hey guys, i`m trying to use cljs.analyzer.api/ns-resolve but i’m getting a “No protocol method IDeref.-deref defined for type null”
(defn ns-resolve
([ns sym]
(ns-resolve env/*compiler* ns sym))
([state ns sym]
{:pre [(symbol? ns) (symbol? sym)]}
(get-in @state [::ana/namespaces ns :defs sym])))
I assume state
is nil
. How is it being called?is there some good guidance for how to share a macro between clj and cljs from a cljc file? I tried #?(:clj (defmacro ... ))
within the cljc (which contains a bunch of other functions), and then (ns my.ns (:require-macros [my.ns]))
in a cljs file per … I think the namespaces guide… and the result was that cljs couldn’t see any of the functions in the cljc file.
This is my go-to link for these matters: https://clojureverse.org/t/how-to-define-and-use-a-macro-in-both-clj-and-cljs/2896
@U1UQEM078 @thheller thanks so much … I seem to have gotten it working. Plot twist, though: if I follow this method, I can do a simple (ns my.other-ns (:require [my-ns :refer [the-macro]])
if the file is CLJ or CLJS.
if it’s CLJC, then the declaration needs to be (ns my.other-ns (:require #?(:clj [my-ns :refer [the-macro]] :cljs [my-ns :refer-macros [the-macro]]))
I’ve added this using-a-cljc-macro-from-cljc wrinkle to the original post over at https://clojureverse.org/t/how-to-define-and-use-a-macro-in-both-clj-and-cljs/2896/7?u=rgm … does anyone know if I just hit an uncovered edge case on the namespacing/macro sugar, or is this how it’s supposed to work?
@rgm in the cljc file #?(:cljs (:require-macros [my.ns :refer (a-macro-you-want-to-use)]))
(not in an extra cljs file)
hi, I'm having troubles with :foreign-libs
and :module-type :commonjs
:
I'm including basic file with no deps that has
module.exports.typeDefs='some string'
when compiled using deps.cljs and figwheel-main with this config
:foreign-libs [{:file "generated/prisma-client/prisma-schema.js"
:provides ["typeDefsXXX"]
:module-type :commonjs}
the compiled file exposes the namespace with var
so it's contents end up in some local scope somehowif I remove the var
infront of the contents of the namespace in the compiled file everything works
this is the compiled code excerpt
var module$Users$gdanov$work$playground$trading_cockpit$generated$prisma_client$prisma_schema={"default":{}};
module$Users$gdanov$work$playground$trading_cockpit$generated$prisma_client$prisma_schema["default"].typeDefs=`type Account......
ok, got it. the var
shadows the variable created by goog.provide(...)
so I end up with empty namespace
I’ve added this using-a-cljc-macro-from-cljc wrinkle to the original post over at https://clojureverse.org/t/how-to-define-and-use-a-macro-in-both-clj-and-cljs/2896/7?u=rgm … does anyone know if I just hit an uncovered edge case on the namespacing/macro sugar, or is this how it’s supposed to work?