Hugo 0.168.0: js.Build fails with browser:false and extensionless require

I encountered a js.Build regression after upgrading Hugo from 0.166.0 to 0.168.0 (Homebrew, Linux amd64).

A dependency uses require(‘./util.inspect’) and maps “./util.inspect.js” to false in its package.json browser field. Although util.inspect.js exists, Hugo fails with:

 lstat .../node_modules/object-inspect/util.inspect: no such file or directory

I reproduced this without a theme or external npm dependencies:

  • Hugo 0.166.0: succeeds.
  • Hugo 0.168.0: fails.
  • Hugo 0.168.0 with an explicit .js extension in the require: succeeds.

The minimal reproduction and results are in this GitHub issue:

Could anyone confirm whether they encounter the same behavior? Is there a recommended workaround that preserves the read-path security checks and does not require modifying third-party packages?

In general I don’t think it adds any value for anyone to double post bugs on both GitHub and here:

Thank you for pointing that out !
I see that, from the maintainers’ perspective, this post doesn’t make sense. I’m sorry I didn’t take that into consideration.

As a Hugo user myself, whenever I encountered a problem I couldn’t solve, I would always start by looking for a workaround on this forum, so I assumed it would be helpful to other developers facing or someone who will face the same issue.
However, I’ll try to avoid doing that in the future.

Finally, I really like Hugo and this community. I’m not against them.