-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reducing bundle size effects by disabling data printers #13
Comments
Okay, I have tested two strategies to help reduce bundle size impact:
I then tested bundle sizes on the following very simple code. (ns demo.core
(:require [lambdaisland.deja-fu :as fu]))
(defn ^:export init []) Here are some statistics I have recorded.
[1] https://groups.google.com/g/clojurescript/c/3QmukS-q9kw/m/8Tyo0nd8-X4J |
@rome-user I think that's a reasonable thing to explore. It's a small library, so it makes sense to avoid automatically pulling in relatively heavy dependencies (even In your table above "Do not require library," means without deja-fu, correct? So with patches, deja-fu adds about 26 KB uncompressed and 6 KB compressed? I'm a little loathe to remove top-level data structures, since the largest one appears to be |
@rome-user Anyway, thank you for all this investigation! It looks like we can shave off quite a bit. |
That is correct. It means compiling the CLJS code without
In short, I wrap the large map inside a delay and deref it where it is used. This allows Google Closure to remove The tricky part about disabling data printers (i.e. avoiding having to bundle (ns lambdaisland.deja-fu.pretty
(:import (goog.date Date DateTime))
(:require [lambdaisland.data-printers :as data-printers]
[lambdaisland.deja-fu :refer [format LocalTime]]))
(data-printers/register-print LocalTime 'time/time (comp str format))
(data-printers/register-pprint LocalTime 'time/time (comp str format))
(data-printers/register-print goog.date.Date 'time/date (comp str format))
(data-printers/register-pprint goog.date.Date 'time/date (comp str format))
(data-printers/register-print goog.date.DateTime 'time/date-time (comp str format))
(data-printers/register-pprint goog.date.DateTime 'time/date-time (comp str format)) Then in code one can |
Would it be possible to disables the custom data printer with e.g. a compiler constant? For instance, the
re-frame-10x
library lets you opt in to the library by setting a compiler constant. Maybe this library can do the same. That is to say, expose a constant for disabling the data printers. This should allow Google Closure to remove cljs.pprint from bundles.I am requesting this because I noticed that
data_printers
requirescljs.pprint
, which is nearly 100 kb in my bundle.The text was updated successfully, but these errors were encountered: