This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-06-04
Channels
- # announcements (4)
- # beginners (110)
- # boot (6)
- # calva (23)
- # cider (14)
- # cljdoc (5)
- # cljs-dev (50)
- # cljsrn (3)
- # clojure (105)
- # clojure-europe (3)
- # clojure-italy (46)
- # clojure-nl (6)
- # clojure-spec (19)
- # clojure-sweden (1)
- # clojure-uk (78)
- # clojurescript (66)
- # core-async (5)
- # cursive (19)
- # data-science (16)
- # datomic (3)
- # events (2)
- # fulcro (11)
- # hoplon (53)
- # jobs (4)
- # jobs-discuss (6)
- # keechma (51)
- # leiningen (3)
- # nrepl (25)
- # off-topic (95)
- # parinfer (8)
- # precept (1)
- # reitit (61)
- # remote-jobs (1)
- # rewrite-clj (75)
- # ring-swagger (2)
- # robots (3)
- # shadow-cljs (43)
- # tools-deps (28)
- # vim (2)
Does anyone know how to exclude https://github.com/bhb/expound when compiling with advanced optimizations?
Simply requiring it and wrapping usage sites with (when ^boolean goog.DEBUG ...)
doesn’t help
Perhaps should hack around it with :preloads
We've had reasonable success removing things with macros for the code + :strip-type-prefixes
for ns entries. (shadow-cljs only, https://shadow-cljs.github.io/docs/UsersGuide.html#_code_stripping)
Wonder what are the general workarounds for non-DCEable code in cljs
Would a require wrapped in a macro do it? (a macro that toggles content based on some compile time flag)
@olical There’s no require
in cljs as in JVM Clojure AFAIK, it works only in REPL
it would mean dynamic require in adv compilation mode, which is a different thing (cljs.loader)
Ah yeah, that's only REPL. But could you condition an ns form that would be picked up by the compiler?
yeah probably, but honestly :preloads
looks better for this IMO
(core/defmacro require
[& args]
`(~'ns* ~(cons :require args)))
require is just that anywayafaik ns
form in cljs is a special form, it’s translated directly into Closure’s module definition syntax, so not an option
Yeah, you can't really make ns
forms be dynamic in any way... they are consumed during compilation.
That was my point though really, that you want to toggle at compile time, so you could macro out a ns form based on compilation level. Maybe...?
Question about modules. If I compile a project using the modules
options like;
{:output-dir "out"
:optimizations :simple
:modules {:a {:entries #{app.feature.a}
:output-to "out/a.js"}
:b {:entries #{app.feature.b}
:output-to "out/b.js"}}}
I seem to get an error when importing any Closure lib inside that module.
goog is not defined at file-name.js:17
If I use main
and output-to
this is not the case;
{:main app.feature.a
:output-dir "out"
:output-to "out/a.js"
:optimizations :simple}
Is there a simple way to include the goog
namespace in each module?This is in a new project so it should be easy to experiment with. I’ll try and older version of cljs as well
I'm assuming you've read this https://clojurescript.org/guides/code-splitting
<html>
<body>
<button id="button">Load Bar!</button>
<script src="out/cljs_base.js" type="text/javascript"></script>
<script src="out/foo.js" type="text/javascript"></script>
</body>
</html>
I can do that - so fwiw, I’m trying to create a number of js bundles that can be dropped into a page I do not control. I can do this by compiling each one separately without using modules, but I was thinking that would be an easier approach.
Would like to keep the overall bundle size down since only one component could ever be loaded at time.
ok just remember if the component is very simple code splitting isn't going to help as much as you would like
code splitting really only makes a significant impact on fairly complex SPAs where there's a fairly complex set of components in different logical views
yeah, I think that’s what I was missing. Thanks again for the help and all your work with CLJS
hey folks, I have a ns form like (ns some-ns (:require [ns1.ns2]))
and i'm not using ns1.ns2
at all. Does cljs compiler include ns1.ns2
in the final optimized build ?
yes, but depending on the code written there it may be fully deleted if nothing is used
shadow-cljs can generate detailed build reports so you can easily check if something is included that shouldn't be https://shadow-cljs.github.io/docs/UsersGuide.html#_build_report