One possibility would be to use a system image. In the following code I use PackageCompiler.jl to create a system image that includes Infiltrator.jl, that way Main, the top-level module, will always include Infiltrator as a submodule:
julia> using PackageCompiler
julia> create_sysimage(["Infiltrator"]; sysimage_path="debug_image.so")
I save the new system image to debug_image.so and then start julia with this image instead of the default one, the NoInfil project does not have Infiltrator in its deps:
$ julia --project=NoInfil -Jdebug_image.so [21:52:23]
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.7.1 (2021-12-22)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
julia> using NoInfil
julia> NoInfil.greet()
Infiltrating greet() at NoInfil.jl:3:
infil>
This is what NoInfil/src/NoInfil.jl looks like:
module NoInfil
greet() = (Main.Infiltrator.@infiltrate; print("Hello World!"))
end # module