This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-09-01
Channels
- # adventofcode (2)
- # announcements (3)
- # babashka-sci-dev (79)
- # beginners (76)
- # biff (2)
- # calva (32)
- # cider (2)
- # clj-kondo (42)
- # clj-on-windows (17)
- # clojure (28)
- # clojure-belgium (1)
- # clojure-berlin (1)
- # clojure-europe (95)
- # clojure-nl (4)
- # clojure-norway (4)
- # clojure-uk (5)
- # clojurescript (27)
- # conjure (5)
- # cursive (3)
- # data-science (16)
- # datomic (67)
- # graalvm (12)
- # hyperfiddle (36)
- # jobs (3)
- # jobs-discuss (1)
- # kaocha (2)
- # klipse (1)
- # leiningen (28)
- # lsp (16)
- # luminus (3)
- # malli (10)
- # nrepl (3)
- # off-topic (57)
- # other-languages (18)
- # re-frame (4)
- # reitit (8)
- # releases (1)
- # remote-jobs (1)
- # scittle (4)
- # shadow-cljs (7)
- # test-check (1)
- # tools-deps (4)
- # vim (11)
- # xtdb (25)
Is it possible to specify additional namespaces that should be included in a native-image? I have namespace that might be dynamically required. Can work around this by adding a require in gen-class ns, but I’m hoping there is a better way.
@peder.refsnes yes, you should require them at compile time
dynamic requires also tend to bloat the image. see: https://github.com/borkdude/dynaload
just want to verify I understand; top-level requires are done at compile-time, while requiring-resolve
, etc, are done at run-time, right?
top level requiring-resolve are also done at compile time :) - non-top level require is done at runtime. so top level is the key thing
Right, now I have:
(ns foo.bar
;; Don't remove, needed for native-image
(:require [foo.stuff]))
was hoping there was a flag I could pass that would do the same, ie:
native-image -jar ... --include-extra-stuff=foo.stuff
you can just make another main namespace which requires the stuff and calls your old main namespace. but I highly recommend removing the dynamic requires, see the link I posted earlier
if I understand the dynaload docs correctly it’s comparable to tree-shaking in js. is that correct?
okay, not sure that’s applicable in my case. concretely I need to include a custom publisher in mulog, so I don’t controll the code that does the dynamic require. https://github.com/BrunoBonacci/mulog/blob/master/mulog-core/src/com/brunobonacci/mulog/publisher.clj#L213
Hi @peder.refsnes, you can pass a publisher also using the :inline
type
https://cljdoc.org/d/com.brunobonacci/mulog/0.9.0/doc/special-publishers/inline-publishers
In that case, you have the burden of the initialisation of your custom publisher.
I found this to be an easier approach on GraalVM compiled apps
cool, thanks 🙏