Skip to content

AOT compile duct modules and components / explicit :require on all dependencies? #99

Description

@danielcompton

I'm trying to build an AOT'd uberjar using the Duct Leiningen template. I can use the template to build an uberjar, but it doesn't look like Duct modules and components are AOT compiled.

$ lein new duct foobar +api +cljs +postgres +site
$ lein uberjar
$ tar xzf target/foobar-0.1.0-SNAPSHOT-standalone.jar -C target/
$ ls target/duct/database/*
target/duct/database/sql.clj

target/duct/database/sql:
hikaricp.clj

If I add an explicit :require for duct.database.sql.hikaricp in the foobar.main ns form, then the duct.database.sql and duct.database.sql.hikaricp namespaces are AOT compiled in the uberjar.

I'm guessing that this is happening because the Clojure compiler isn't able to tell at AOT compile time that those modules are needed.

This also causes issues when compiling with native-image, as the SubstrateVM compiler can't tell (without extra config) that some namespaces are going to be required at runtime based on info in the config.edn file.

A workaround is to add explicit requires on all namespaces which are dynamically required by Duct or add them manually in the project.clj, but this loses some of the benefits of Duct. Is there another way to get all of a Duct application automatically AOT compiled?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions