Clarification on extensions introduced in Julia v1.9 vs Requires.jl

The introduction in the Pkg documentation makes me think that extensions is just like a built-in implementation of @require. But, after some initial attempt, I realized that they are not substitutes.

To be concrete, suppose I have a file that used to be handled by @require and is only loaded when package A is used. The file simply export an additional object when a package is loaded. To turn it into an extension, I wrap the content into a module and the file now looks like this:

module Attempt

export AdditionalObj

struct AdditionalObj end


Now I put Attempt into the extensions segment of Project.toml. I got

julia> Attempt
ERROR: UndefVarError: `Attempt` not defined

julia> AdditionalObj
ERROR: UndefVarError: `AdditionalObj` not defined

Are extensions not supposed to be used for defining new objects that need to be exported? So, they are only used to add additional methods for functions that are already existing in the parent package?


I would say what extensions do are making more sense to me now. It’s probably not good to export something new from extensions.

@kristoffer.carlsson would be best qualified to answer, but I will try based on my interpretation of

From what I can tell, the extension mechanism is primarily focused on extending methods, not necessarily introducing or exporting new types.

Based on Are extension packages importable? it might be possible to get a reference to the extension module itself.