Skip to content

Pre-compiled Declarative Modules#6978

Open
lihaoyi wants to merge 21 commits intocom-lihaoyi:mainfrom
lihaoyi:pre-compile-modules
Open

Pre-compiled Declarative Modules#6978
lihaoyi wants to merge 21 commits intocom-lihaoyi:mainfrom
lihaoyi:pre-compile-modules

Conversation

@lihaoyi
Copy link
Copy Markdown
Member

@lihaoyi lihaoyi commented Mar 31, 2026

This PR allows users to define module traits that can be instantiated in build.mill.yaml and package.mill.yaml files without needing to be codegened and compiled. This can speed up Mill initialization substantially in scenarios where the build is mostly declarative .mill.yaml modules.

The user opts in by defining a class PreCompiled() extends mill.api.PreCompiledModule in their trait's companion object, and any .mill.yaml file that extends a single label that matches that class will use the pre-compiled class instantiated reflectively rather than the original trait instantiated via codegen.

Notes:

  • We are only able to skip codegen in yaml modules who do not have programmable descendents. For programmable modules with yaml descendents, we would need to codegen the yaml module reference in the nearest enclosing programmable ancestor, so build.foo.bar.qux programmable references works.

  • So if everything is declarative then no codegen needs to happen, but if the root is programmable and the children are declarative the root needs to generate a object tree, and if the root is declarative and some descendent is programmable we also need to codegen something for the root to handle build.* references

@lihaoyi lihaoyi marked this pull request as ready for review April 1, 2026 02:18
@lihaoyi lihaoyi force-pushed the pre-compile-modules branch from 8063176 to 88129bd Compare April 1, 2026 09:13
@lihaoyi lihaoyi force-pushed the pre-compile-modules branch from cd16dc7 to c524e89 Compare April 1, 2026 10:57
@lihaoyi lihaoyi force-pushed the pre-compile-modules branch from 2c59aea to bde3322 Compare April 1, 2026 12:18
@lihaoyi lihaoyi force-pushed the pre-compile-modules branch from 8b97729 to d20a236 Compare April 1, 2026 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant