# Is it possible to precompile (with PrecompileTools) code from a package extension?

**URL:** <https://discourse.julialang.org/t/is-it-possible-to-precompile-with-precompiletools-code-from-a-package-extension/102647>\
**Category:** General Usage\
**Tags:** precompilation, package-extensions\
**Created:** [August 9, 2023, 5:08pm UTC](https://discourse.julialang.org/t/is-it-possible-to-precompile-with-precompiletools-code-from-a-package-extension/102647 "2023-08-09T17:08:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![BenjaminDoran](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/benjamindoran/32/34587_2.png) [@BenjaminDoran](https://discourse.julialang.org/u/BenjaminDoran)\
**Post date:** [August 9, 2023, 5:08pm UTC](https://discourse.julialang.org/t/is-it-possible-to-precompile-with-precompiletools-code-from-a-package-extension/102647/1 "2023-08-09T17:08:46Z")

</div>

I was trying to use PrecompileTools to make a pre-compilation workflow for a package extension but ran into issues where because the weak-dependency is not part of the module its name is not defined.

Is it possible to precompile (with PrecompileTools) code from a package extension?  
where would the `@compile_workload` go in the codebase?  
Is there a precompile target to list in the project.toml to list extra packages that are needed for precompilation?

---

<div class="post-metadata">

**Author:** ![BenjaminDoran](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/benjamindoran/32/34587_2.png) [@BenjaminDoran](https://discourse.julialang.org/u/BenjaminDoran)\
**Post date:** [August 9, 2023, 6:27pm UTC](https://discourse.julialang.org/t/is-it-possible-to-precompile-with-precompiletools-code-from-a-package-extension/102647/2 "2023-08-09T18:27:43Z")

</div>

Figured it out,

I can add the `@compile_workload` block direction into the extension module.

i.e.

```julia
module MyPackageExt
using MyPackage, MyOtherPackage
# ....
using PrecompileTools
@compile_workload begin
# ....
end
end

```
