Dependencies united under one public API.
Republic.jl re-publicizes names from upstream modules, making them part of your module's public API without exporting them into the caller's namespace. Like Reexport.jl, but for Julia's public keyword (introduced in Julia 1.11).
module MyPackage
using Republic
# All of Foo's public and exported names become `public` in MyPackage
@republic using Foo
# Specific names
@republic using Foo: bar, baz
# Aliases: F becomes public in MyPackage
@republic using Foo: Foo as F
# Blocks
@republic begin
using Foo
using Bar
end
endNames marked public are accessible via qualified access (MyPackage.bar) without being brought into scope by using MyPackage. This is useful for packages that want to expose a broad API surface without polluting the caller's namespace.
By default, @republic makes everything public. To also re-export names that were exported upstream, use reexport=true:
@republic reexport=true using FooWith reexport=true, exported names are re-exported (like Reexport.jl), and public-only names are marked public. Republic never promotes a public-only name to exported — that is a deliberate choice left to the user (see below).
Julia does not allow a name to be marked with both public and export. This only matters if a name is public upstream but you want to export it in your module — names that are already exported upstream can be handled with reexport=true. To export a public-only name, declare the export before @republic:
module MyPackage
using Republic
export bar # bar will be exported, not just public
@republic using Foo # skips `public` for bar since it's already exported
endAlternatively, use qualified imports to keep @republic and export separate:
module MyPackage
using Republic
using Foo: bar
export bar
@republic using Foo: baz, qux # only these become public
endRepublic.jl is derived from Reexport.jl by Simon Kornblith (MIT License).