#Correctly exposing modules.
1 messages · Page 1 of 1 (latest)
You should be able to just import with a relative path (../../utility.zig)
Unless you are making AnimationPlayer the root of a different module, and arent able to import further up, which would feel like a weird design decision with the limited context shared
I know that relative paths work but they feel like a workaround. Is there not a way to make game.zig and util.zig top level and directly importable from anywhere?
AnimationPlayer is not a root of something.
It is not a workaround, its effectively the same as importing from a folder further down the tree
You could make your "top level" files a module and add them, to import like @import("utils"), but that would feel like a workaround for me, not the relative imports
It would also be extra work in the build script for no real benefit. In fact, it will likely cause the LSP (if you use one) to work worse, since extra steps would be required to "find" the modules' source
My intention was to have it similar like the stdlib.
All the other modules that need some other modules go through the std module to import them.
There are also no relative paths
I just want to have clean and readable imports
The simplicity of a relative import is not to be underestimated.
I do prefer to have my imports
const module = @import("util").<whatever path mighe be here later>.<final module>
(or utils.zig instead of utils)
instead of
const module = @import("../../../../util/<whatever path>/<final module>.zig")
(I made it a bit extreme in this example, but you get the idea)
Anybody know how to do this?
You might have too much organisation xD
I just don't like flat hierarchies where the whole project is in one single folder and relative paths that walk the whole path up and down from one folder branch to another.
I give up