Fork me on GitHub

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:


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:

  ;; 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.


Hi @peder.refsnes, you can pass a publisher also using the :inline type 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

👍 1

cool, thanks 🙏