Don't require cljs-ajax' API wholesale #29
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
About this PR
This PR changes the
day8.re-frame.http-fx
ns definition to only require the namespaces within cljs-ajax that are essential to the fx, rather than the whole API. It doesn't impact functionality in any way.Why?
Short answer: to avoid pulling in
cognitect.transit
.Longer answer: cljs-ajax's formats include
transit-request-format
andtransit-response-format
, to facilitate efficient sending of Clojure/Script data structures over the wire. That's all well and good, but consumers of re-frame-http-fx may not need it.Now, Closure Compiler is normally quite efficient in optimizing it away if it's not needed. However, a complication might arise when some other part of the code does need it, and ClojureScript's code splitting facility is in use.
Consider this scenario:
re-frame-http-fx
, but never uses thetransit-*-format
sWithout this PR,
transit
will be compiled into A even though it's never used when B is not loaded. With it, the compiler is able to lifttransit
out of A and into B.This is exactly what we do at WorksHub. In our case, enabling this change causes our main JS code (advanced optimizations, uncompressed) to weigh 25 KiB less.