What is vendorClosest doing?

I am meditating about the function of the configuration value `vendorClosest``.

    When enabled, we will pick the vendored module closest to the module using it. 
   The default behavior is to pick the first. 
   Note that there can still be only one dependency of a given module path, 
   so once it is in use it cannot be redefined.

I guess that it means: What shall Hugo do, if the exact module cannot be found. But I must confess that I am only guessing and I have no idea what I can do here. Can anyone shed some light on it?

I can try.

If this is your “module graph”:

└── module1
    ├── module1_1
    └── module1_2

If you run hugo mod vendor in both project and module1 both of them get a _vendor folder with all of their dependencies.

  • When you run hugo from project, Hugo will, by default, pick the first vendored version it finds, starting from the root.
  • If you set vendorClosest=true it will pick the version closest to where it’s included (or, the last not the first).

It’s a little bit of a speciality tool, but it allows vendoring on both project and module level, if needed.

1 Like

Wow. Sound special indeed. Is vendorClosest applied to modules with the same name but different versions as I thought before or – as the last sentence in the docs suggests – to the mounted path? So that if module1 mounts a different font-module than project the resulting website gets the font defined in module1?

Yes, thats’s right.