Comments about this depemdemcy declaration style and new post about my zig studies

I decided to try mix database and user interfaces using zig:

but i did something on my build.zig
that i don’t fully understand the downsides, and i with very much to catch your opinions:

    // deps config
    const deps = [_][]const u8{ "zigzag", "pg" };
    for (deps) |dep| {
        exe.root_module.addImport(dep, b.dependency(dep, .{
            .target = target,
            .optimize = optimize,
        }).module(dep));
    }

so far, someone told me that it fails if the dependency has more than one module.

what else it could break?

all comments are very welcome.

It depends on the dependency’s main module having the same name as you have it in build.zig.zon. It also prevents you from passing in stuff other than target and optimize into dependency. Also if the dependency has multiple modules you can’t access them.

This is how I usually do dependencies.

const zigzag = b.dependency("zigzag",  .{}).module("zigzag");
const pg = b.dependency("pg",  .{}).module("pg");
// ...
const exe = b.addExecutable(.{
// ...
        .imports = &.{
            .{.name = "zigzag", .module = zigzag},
            .{.name = "pg", .module = pg},
        },
    }),
});

the target and optimize aren’t necessary unless you want different targets or optimization modes in the same module otherwise it’ll be inherited (I’m probably wrong about my exact wording of this, but it’s the gist of my understanding)