Julia introduced package extensions in v1.9. This package makes these extensions backwards-compatible to earlier Julia versions, with zero overhead on new versions.
Internally, this uses Requires.jl on earlier versions, automating this strategy in the Pkg.jl docs.
Supports all versions of Julia from 1.0 upwards.
Supposing you have a package called Foo
:
-
Set up package extensions for
Foo
as usual. This means adding[weakdeps]
and[extensions]
toProject.toml
and adding extension code toext/
. -
Add
PackageExtensionCompat
as a dependency toFoo
. -
Add the following code to
src/Foo.jl
:using PackageExtensionCompat function __init__() @require_extensions end
That's it! Your package extensions will now be loaded as expected on any Julia version!
See the example folder for an example package using this functionality.