You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Should document cue.mod/module.cue and module vs package #2186
It's also probably not clear to new users when they need to create a module name and how it relates to package name when building a dagger package destined to be shared (often via github, etc).
CUE Package: directory with cue files, each including a package definition on top, making it importable (e.g, universe.dagger.io/docker is a package, universe.dagger.io/docker/cli is another package);
CUE Module: directory with a cue.mod directory which makes for the prefix/root of importable packages (e.g, universe.dagger.io is a module;
Anonymous module (default)
The default module name is an empty string, which means it's anonymous. That's when you don't need to import other packages inside your module. It represents most cases where someone has a dagger plan and imports everything from third-party packages like universe.
When to use a module
You can add a different module name, if you want to import other packages from inside your module. This is required so you have a prefix/root before your imports. This is when you want to split your code into multiple files.
The module path becomes the import path prefix for packages in the module. This might be the name of a domain you own or another name you control (such as your company name), even your email, followed optionally by a descriptive path (e.g., project name).
You import packages by prefixing the module name they're a part of, plus the path to them, relative to the cue.mod directory.
Example:
root // <- this is a module because it includes a cue.mod dir
|-- cue.mod
| |-- module.cue // module: "example.com/pkg"
|-- schemas
| |-- compose // <- this is a package because it includes files with a package directive
| | |-- spec.cue // package compose
...
|-- plan.cue // import "example.com/pkg/schemas/compose"
Activity
morlay commentedon Apr 21, 2022
it is old issue of cue
once official mod manager support, it goes better.
cue-lang/cue#851
I created a simple one for now.
https://github.com/octohelm/cuemod
helderco commentedon May 6, 2022
TLDR: The use of a module is optional, but required if one wants to import files from it.
Documentation for this is being worked on:
I can help give a bit o clarity in the meantime.
In summary:
packagedefinition on top, making it importable (e.g,universe.dagger.io/dockeris a package,universe.dagger.io/docker/cliis another package);cue.moddirectory which makes for the prefix/root of importable packages (e.g,universe.dagger.iois a module;Anonymous module (default)
The default module name is an empty string, which means it's anonymous. That's when you don't need to import other packages inside your module. It represents most cases where someone has a dagger plan and imports everything from third-party packages like universe.
When to use a module
You can add a different module name, if you want to import other packages from inside your module. This is required so you have a prefix/root before your imports. This is when you want to split your code into multiple files.
The module path becomes the import path prefix for packages in the module. This might be the name of a domain you own or another name you control (such as your company name), even your email, followed optionally by a descriptive path (e.g., project name).
You import packages by prefixing the module name they're a part of, plus the path to them, relative to the
cue.moddirectory.Example:
/cc @grouville