]> git.maquefel.me Git - brevno-suite/hugo/commit
npm: Use workspaces to simplify `hugo mod npm pack`
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Mon, 23 Mar 2026 15:00:50 +0000 (16:00 +0100)
committerGitHub <noreply@github.com>
Mon, 23 Mar 2026 15:00:50 +0000 (16:00 +0100)
commitd88a29e002ebc31bf9b4e1e024f141cc0b39a657
tree95414ca70334c3eacfba6be2a6d8c899c0bc3b8a
parent3ff9b7f89ffd3672e0c02cd43f61ff05128f3d83
npm: Use workspaces to simplify `hugo mod npm pack`

Rewrite `hugo mod npm pack` to use npm workspaces. Module deps are now
written to packages/hugoautogen/package.json and the root package.json
gets a "workspaces" reference. A hugo_packagemeta.json sidecar stores a
hash of all input package files so regular commands can warn when npm
deps are out of sync.

Other changes:
- Workspace glob patterns (*, **, {a,b}) are resolved via gobwas/glob.
- Workspaces defined in package.hugo.json are supported.
- package.hugo.json is only recognised at module roots, not in workspaces.
- When package.hugo.json exists, package.json is not mounted or vendored.
- packages/hugoautogen is not mounted or vendored from dependencies.
- Add usePackageJSON import option (auto/always/never) to control whether
  a module's npm deps are included. "auto" checks for Hugo config files
  or package.hugo.json.
- The staleness check is skipped when running `hugo mod npm pack` itself.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
16 files changed:
commands/commandeer.go
commands/mod.go
common/loggers/logger.go
config/allconfig/load.go
hugofs/files/classifier.go
modules/client.go
modules/collect.go
modules/collect_test.go
modules/config.go
modules/module.go
modules/npm/package_builder.go
modules/npm/package_builder_integration_test.go [new file with mode: 0644]
modules/npm/package_builder_test.go
testscripts/commands/mod_npm.txt
testscripts/commands/mod_npm__moduleorder.txt [new file with mode: 0644]
testscripts/commands/mod_npm_withexisting.txt