moc
has a --package
flag which could be used like this:
env/lib.mo
module {
public let SECRET = "MY_SECRET";
};
main.mo
import Debug "mo:base/Debug";
import Env "mo:env";
Debug.print(Env.SECRET);
moc --package base $(dfx cache show)/base --package env env -r main.mo
Note that the -r
flag runs the file. Depending on your use case you may want to use -c
.