This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-04-18
Channels
- # announcements (1)
- # aws (13)
- # beginners (55)
- # calva (8)
- # cider (73)
- # cljs-dev (96)
- # clojure (119)
- # clojure-europe (4)
- # clojure-italy (41)
- # clojure-nl (14)
- # clojure-uk (6)
- # clojurescript (90)
- # cursive (14)
- # data-science (1)
- # datomic (20)
- # dirac (1)
- # emacs (32)
- # figwheel-main (11)
- # fulcro (81)
- # hoplon (2)
- # jobs (1)
- # lein-figwheel (2)
- # luminus (1)
- # lumo (19)
- # nyc (3)
- # off-topic (60)
- # other-languages (1)
- # pedestal (5)
- # quil (1)
- # re-frame (3)
- # reagent (3)
- # reitit (5)
- # remote-jobs (1)
- # ring-swagger (2)
- # shadow-cljs (43)
- # sql (15)
- # tools-deps (20)
- # vim (21)
- # yada (6)
what kind of use cases do people have for including something like datascript in their app?
All, struggling with the Clojurescript idiom that deals with child classes of Javascript libraries e.g.
class Foo extends Bar
. Am I missing something obvious?so there’s not a super easy way of doing that in CLJS, since Clojure doesn’t really have first-class support for inheritance
the important thing to know is that class Foo extends Bar
is JS syntax sugar on top of prototypical inheritance. so we can use the underlying prototype to do this.
another way of writing class Foo extends Bar
would be:
Foo.prototype = Object.create(Bar.prototype);
Foo.prototype.constructor = Foo;
there are some helper functions in the goog.object
namespace we might find useful:
(ns my-app.thing
(:require [goog.object :as gobj]))
(defn Bar [])
(defn Foo [])
(gobj/extend (.-prototype Foo) (.-prototype Bar))
(set! (.. Foo -prototype -constructor) Foo)
Because Bar is a class I seem to have to use (defrecord Foo …)
its an object with methods on it. to expose the methods I had to use defrecord
yes fair.. but the idiom you gave me does work
what does the ^not-native
type hint actually do? I’m trying to optimize some paths that use a lot of a particular protocol, which is extended to native JS types (string, number, nil) as well as CLJS/user types like Keyword, PersistentVector, and Object
Hey there, I'm trying to optimize my bundle with shadow-cljs, in particular by trimming down cljs.core as much as I can. I've got a reproduction of just a small proof-of-concept here: https://github.com/staab/shadow-tiny
The problem I'm running into is that if I use anything in core, my bundle blows up in size; currently I'm just invoking a couple core functions, and the size of cljs.core.js
alone is 97k. Is there any way to improve this? I was thinking of maybe using refer-clojure
in all my namespaces, but the docs say "The only options for :refer-clojure are :exclude and :rename". I'm also not sure if this would work, because it does appear that google closure compiler is properly tree-shaking things (`cljs.core.js` is only 1.1k if I remove the body of my main function, and my other project's cljs.core.js
is 136k).
I haven't on this project; I tried it on my main one yesterday and it crashed so I moved on
This is my source code though:
(ns shadow-tiny.core)
(defn ^:export main []
(print (map inc [1 2])))
I think what you’re going to run into is that the CLJS data structures weigh about 60-80kb un-gzipped
Preact/redux are a total of 5k (gzipped), and I'd like to get cljs to compete with that somehow
do you have an example project showing this? I'd bet that the closure compiler can make this even smaller.
without CLJS of course but it would be nice to show how irrelevant all the micro optimizations preact does are
Is there any prior art on this you know of? I haven't been able to find any articles about tiny bundles online
It's true, but as far as delivering something to users, I'm more willing to suffer with js than bloat my bundles
88K is honestly not enough that I would start to balk. that’s not going to strain my users
@jstaab CLJS isn't really suited for "tiny" bundles since you are always going to end up with cljs.core
and the datastructures
do you have any strategies for alleviating the burden? I'd love to use it everywhere, and with cljs.core aggressively cached on a CDN that seems feasible
I’m setting up SPA routing without /#
. I’ve configured webserver to always return index.html
. Basic stuff works but I’m having trouble with nested routes like
. My build tries to find /foo/js/compiled/out/goog/base.js
when it actually exists in /js/compiled/out/goog/base.js
. Same for deps.js
and deps_cljs.js
. What knobs I need to turn to make those paths absolute?
Under :advanced
it just works as long as I’m pointing to the bundle with absolute pith in index.html
.
code splitting is the answer if you want to limit the initial payload - but fundamentally we start around 22K-25K gzipped and go up from there
CDN caching is not possible meaning not supported/worth supporting, or is there something more fundamental going on with how it's linked?
Ha @dnolen I've been reading some Henrik Joreteg lately and it's inspiring me to change that
but I don't really sympathize that much with such efforts - Closure fundamentally does the only interesting thing that can be done
Svelte is also interesting - but I can't find any data on that on really large projects
but my hunch is once you factor in all the dependencies you actually need, internationalization etc.
so suffice to say, I think ClojureScript and Closure are still state of the art, the real answer is make sure deps can be dead code eliminated
If there were fewer macros, would bundle sizes shrink? I suppose run times would grow commensurately though
Really? I thought they were evaluated during build time, so if I had (defmacro x [] "blah blah blah")
and used it a bunch, wouldn't the output be bigger? Or do you mean it's just negligible?
so yeah if you generate a bunch of code they can affect the bundle size if emit the same stuff over and over again
I see what you mean, the output would be the same whether you used a macro or manually wrote everything out longform, unless your macro is bloating the output unnecessarily