Module with Main.BakedPackage in its dependencies

I have been working on a package for a while, that uses another package that is baked into Main by necessity (which I will called Main.BakedPackage for now). Its format is the following:

module MyPackage
    using Main.BakedPackage

I want to be able to call Pkg.add("MyPackage"), so I can call using MyPackage from any Julia terminal. But since I cannot add Main or Main.BakedPackage to the Project.toml of MyPackage, I always get the following error:
ERROR: LoadError: ArgumentError: Package MyPackage does not have Main in its dependencies:
Is there a way to get around this, or do I always have to call include("MyPackage.jl"); using .MyPackage every time I want to use it? This is really cumbersome, so your help is appreciated. Thanks in advance!

How can you be sure that BackedPackage is always in Main? It looks like a conditional dependency rather than a dependency? Tho it’s not actually a solution but more a workaround, but maybe you want to check Requires.jl?

Why is it necessary? And how exactly do you “bake it in”?

It’s necessary since it is a closed source package, and requires a pre-built system image of Julia with BakedPackage and its dependencies (by changing [Linux] or sys.dll [Windows] directly). See here: System Image Building · The Julia Language

You can only be sure if the user has gone through the same install process for BakedPackage. And I don’t know what you mean by a conditional dependency; it’s not conditional because BakedPackage has to be in Main for my package to work. I will check out Requires.jl.

If it has to be Main then that’s a dependency you should just depend on this package

A closed source package can be done without a custom sysimage (eg via a private registry). So I am guessing you have some other reasons for a custom sysimage?

Main.BakedPackage is not mine, so I don’t get to choose how it’s implemented unfortunately. And @Roger-luo, I wish, but since the package is baked into Main, you can’t actually add it as a dependency in the usual way.

Frankly you’re in a suuuuper weird scenario. Despite the name, Main.BakedPackage is not a package, it’s just a Module.

The author of the code should really have made an actual package and baked that in to the sysimage then you could do using BakedPackage. This is how the standard packages like Pkg work.