Bjørn Erik Pedersen
ae7bf74b3e
common/hexec: Make NODE_PATH a fallback for ESM bare imports
...
Node's ESM resolver does not consult NODE_PATH (unlike CJS require), so
an ESM postcss.config.js shipped by a Hugo theme fails when loaded from
the module cache: bare imports like `import x from "postcss-import"`
have no node_modules to walk up to.
Install a synchronous resolver hook (module.registerHooks) via
--import=data:... on every Node invocation. On ERR_MODULE_NOT_FOUND for
a bare specifier it resolves the package from each NODE_PATH entry via
createRequire().resolve(). No-op for relative, absolute, URL-scheme and
non-MODULE_NOT_FOUND failures. Synchronous hooks run on the main thread,
so no --allow-worker is needed under the Node permission model.
Fixes #13987
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com >
2026-05-13 22:00:04 +02:00
Bjørn Erik Pedersen
e51e761d9c
css: Make css.Build's file-loader URLs absolute to web context root
...
When CSS imports assets via the file loader (fonts, images), the emitted
URLs were relative to the CSS output directory. That broke when the CSS
was inlined into HTML, since browsers then resolved the URLs against the
page rather than the CSS file.
Set esbuild's PublicPath to the CSS output directory joined with the
site base path so URLs work whether the CSS is published as a file or
inlined.
Fixes #14849
2026-05-10 19:08:08 +02:00
Bjørn Erik Pedersen
7622dd86ce
css: Support nested hugo:vars/<name> imports
...
Allow CSS variables to be grouped under sub-paths and imported via
@import "hugo:vars/mobile" (or @use for Dart Sass), so callers can pass
nested dicts like:
{{ dict "primary-color" "blue" "mobile" (dict "primary-color" "red") }}
Top-level "hugo:vars" now skips nested map entries instead of emitting
garbage for them.
Fixes #14705
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com >
2026-04-27 19:42:50 +02:00
Bjørn Erik Pedersen
a54c398b93
Harden Node tool execution with --permission flag
...
Add security.node.permissions config to run Node tools (PostCSS, Babel,
TailwindCSS) under Node's permission model, restricting file system access
to the working directory by default.
The binary resolution is simplified to node_modules/.bin → PATH (npx removed).
For both locations, the actual JS entry point is resolved via symlinks (macOS/Linux)
or by parsing npm wrapper scripts (Windows .cmd), then executed as
"node --permission --allow-fs-read=<path> --allow-fs-write=<path> <script>".
Users can opt out by removing "node" from security.exec.allow.
Closes #7287
2026-04-22 15:47:34 +02:00
Bjørn Erik Pedersen
481baa0896
all: Replace NewIntegrationTestBuilder with Test/TestE/TestRunning
2026-04-03 21:17:45 +02:00
Bjørn Erik Pedersen
e431f90bc6
tpl/css: Fix external source maps
...
Fixes #14620
2026-03-14 12:08:18 +01:00
Bjørn Erik Pedersen
3e3b849cc7
Add css.Build
...
Fixes #14609
Fixes #14613
2026-03-12 13:32:40 +01:00
Bjørn Erik Pedersen
5f5b2f378f
testing: Skip some slow tests when not running in CI
...
Fixes #14438
2026-01-27 15:38:49 +01:00
Bjørn Erik Pedersen
b441472b69
Add modulequeries file cache for module version queries
...
This adds a new file cache named 'modulequeries' with a 24h maxAge
that caches JSON responses from 'go mod download -json' when querying
module versions with constraints (e.g., version = "<v3.0.0").
On subsequent builds, if the cached JSON exists and the module
directory it references is non-empty, the cached result is used
directly, skipping the costly VCS interaction entirely.
Fixes #14417
2026-01-24 14:25:34 +01:00
Bjørn Erik Pedersen
da5b1fcf8f
tailwindcss: Add referece to skipInlineImportsNotFound when import not found in assets
...
See #14273
2025-12-18 10:57:01 +01:00
Bjørn Erik Pedersen
0637adb239
Improve error messages for template failures
2025-12-17 21:12:15 +01:00
Bjørn Erik Pedersen
0bf61353f6
Improve error handling/messages in Hugo Pipes
...
Fixes #14257
Closes #14270
2025-12-17 21:12:15 +01:00
Bjørn Erik Pedersen
9937a5dcaa
tpl/css: Deprecate libsass in favor of dartsass (note)
...
The upstream library is now EOL and the repo is archived. Also, it's time for us to move away from the extended CGO build and for Hugo users not already done that, move to https://gohugo.io/functions/css/sass/#dart-sass
https://github.com/sass/libsass
Closes #14261
2025-12-16 22:31:13 +01:00
Joe Mooring
5e649eb4d0
resources: Skip integration test if Dart Sass is not installed
2025-11-27 19:32:23 +01:00
Bjørn Erik Pedersen
3073fd5ccf
testing: Replace legacy config.toml with hugo.toml in most tests
2025-11-27 12:08:08 +01:00
Bjørn Erik Pedersen
b9b304a126
testing: Port integration tests to new templates structure
...
As introduced in v0.146.0. Keep some legecy test to preserve backwards compatibility.
2025-11-27 12:00:15 +01:00
Bjørn Erik Pedersen
04650ce778
all: Run modernize -fix ./...
...
Closes #14107
2025-11-05 21:05:42 +01:00
Bjørn Erik Pedersen
a03a245f0c
Fix it so css.TailwindCSS inlineImports options isn't always enabled
...
To avoid breaking existing setup and to make a better default option, the option is now `disableInlineImports` (default false).
Fixes #13719
2025-05-19 19:36:48 +02:00
Bjørn Erik Pedersen
83cfdd78ca
Reimplement and simplify Hugo's template system
...
See #13541 for details.
Fixes #13545
Fixes #13515
Closes #7964
Closes #13365
Closes #12988
Closes #4891
2025-04-06 20:59:41 +02:00
Joe Mooring
c15ebce2fd
resources: Add option to silence dependency deprecation warnings
...
Closes #13530
2025-03-29 19:04:53 +01:00
Bjørn Erik Pedersen
521911a576
all: Run modernize -fix ./...
2025-02-26 11:44:25 +01:00
Oleksandr Redko
4245a4514d
all: Remove deprecated build tags
2025-02-08 10:29:42 +01:00
Joe Mooring
33b46d8a41
resources: Remove debug statement
...
Closes #13320
2025-01-30 11:32:57 +01:00
Bjørn Erik Pedersen
020253904f
js/esbuild: Don't try to resolve packages in /assets marked as external
...
Fixes #13183
2024-12-22 21:29:18 +01:00
Bjørn Erik Pedersen
e293e7ca6d
Add js.Batch
...
Fixes #12626
Closes #7499
Closes #9978
Closes #12879
Closes #13113
Fixes #13116
2024-12-12 21:43:17 +01:00
Bjørn Erik Pedersen
5ab38de363
Fix Sass imports on the form index.{scss,sass}
...
Fixes #13123
2024-12-10 13:33:27 +01:00
Bjørn Erik Pedersen
8d017a60fb
dartsass: Fix nilpointer on Close when Dart Sass isn't installed
...
Fixes #13076
2024-11-21 20:00:36 +01:00
Bjørn Erik Pedersen
8d92042ab9
dartsass: Fix error message
...
Closes #13065
2024-11-18 17:14:56 +01:00
Bjørn Erik Pedersen
3b6eaf9b1f
dartsass: Add silenceDeprecations option
...
Fixes #13045
2024-11-18 13:41:12 +01:00
Bjørn Erik Pedersen
1fd845eee4
dartsass: Remove support for v1 of the protocol/binary (note)
...
People who stil use a very old binary named `dart-sass-embedded` need to upgrade.
See https://gohugo.io/functions/css/sass/#dart-sass
2024-11-18 12:32:39 +01:00
Joe Mooring
889308dd85
resources: Address Dart Sass deprecation of global built-in functions
...
See https://github.com/sass/dart-sass/releases/tag/1.80.0
Fixes #12961
2024-11-01 14:05:27 +01:00
Joe Mooring
5b0b663ec3
tailwind: Pin Tailwind 4 test to alpha 26 or later
2024-10-06 22:15:17 +02:00
Joe Mooring
d1ba52f3c3
tests: Address deprecation warnings and errors
2024-09-29 10:49:26 +02:00
Bjørn Erik Pedersen
da72ac2db9
tailwind: Pin Tailwind 4 test to alpha 24
...
See #12880
2024-09-27 10:36:25 +02:00
Joe Mooring
5b442b3cce
libsass: Resolve directory paths to directory index files
...
Closes #12851
2024-09-16 09:34:14 +02:00
Joe Mooring
2bc27657d8
dartsass: Resolve directory paths to directory index files
...
Closes #12849
2024-09-15 20:32:11 +02:00
Bjørn Erik Pedersen
2babd6404e
identity: Use xxHash in hashstructure (note)
...
```
name old time/op new time/op delta
HashString/n28-10 133ns ± 9% 107ns ±10% -19.58% (p=0.029 n=4+4)
HashString/n112-10 243ns ± 5% 121ns ± 4% -50.08% (p=0.029 n=4+4)
HashString/n448-10 698ns ± 3% 174ns ± 5% -75.02% (p=0.029 n=4+4)
HashString/n1792-10 2.58µs ± 4% 0.38µs ± 4% -85.11% (p=0.029 n=4+4)
HashString/n7168-10 10.0µs ± 3% 1.3µs ± 4% -86.91% (p=0.029 n=4+4)
name old alloc/op new alloc/op delta
HashString/n28-10 80.0B ± 0% 72.0B ± 0% -10.00% (p=0.029 n=4+4)
HashString/n112-10 160B ± 0% 152B ± 0% -5.00% (p=0.029 n=4+4)
HashString/n448-10 496B ± 0% 488B ± 0% -1.61% (p=0.029 n=4+4)
HashString/n1792-10 1.84kB ± 0% 1.83kB ± 0% -0.43% (p=0.029 n=4+4)
HashString/n7168-10 8.24kB ± 0% 8.23kB ± 0% -0.06% (p=0.029 n=4+4)
name old allocs/op new allocs/op delta
HashString/n28-10 4.00 ± 0% 3.00 ± 0% -25.00% (p=0.029 n=4+4)
HashString/n112-10 4.00 ± 0% 3.00 ± 0% -25.00% (p=0.029 n=4+4)
HashString/n448-10 4.00 ± 0% 3.00 ± 0% -25.00% (p=0.029 n=4+4)
HashString/n1792-10 4.00 ± 0% 3.00 ± 0% -25.00% (p=0.029 n=4+4)
HashString/n7168-10 4.00 ± 0% 3.00 ± 0% -25.00% (p=0.029 n=4+4)
```
2024-07-31 16:44:06 +02:00
Bjørn Erik Pedersen
78db8aebca
identity: Upgrade to github.com/mitchellh/hashstructure/v2 v2.0.2
...
```
name old time/op new time/op delta
HashString/n28-10 131ns ± 7% 133ns ±19% ~ (p=0.343 n=4+4)
HashString/n112-10 237ns ± 5% 241ns ± 3% ~ (p=0.229 n=4+4)
HashString/n448-10 688ns ± 3% 687ns ± 1% ~ (p=0.886 n=4+4)
HashString/n1792-10 2.51µs ± 3% 2.56µs ± 3% ~ (p=0.200 n=4+4)
HashString/n7168-10 10.1µs ± 2% 10.0µs ± 4% ~ (p=0.686 n=4+4)
name old alloc/op new alloc/op delta
HashString/n28-10 80.0B ± 0% 80.0B ± 0% ~ (all equal)
HashString/n112-10 160B ± 0% 160B ± 0% ~ (all equal)
HashString/n448-10 496B ± 0% 496B ± 0% ~ (all equal)
HashString/n1792-10 1.84kB ± 0% 1.84kB ± 0% ~ (all equal)
HashString/n7168-10 8.24kB ± 0% 8.24kB ± 0% ~ (all equal)
name old allocs/op new allocs/op delta
HashString/n28-10 4.00 ± 0% 4.00 ± 0% ~ (all equal)
HashString/n112-10 4.00 ± 0% 4.00 ± 0% ~ (all equal)
HashString/n448-10 4.00 ± 0% 4.00 ± 0% ~ (all equal)
HashString/n1792-10 4.00 ± 0% 4.00 ± 0% ~ (all equal)
HashString/n7168-10 4.00 ± 0% 4.00 ± 0% ~ (all equal)
```
Closes #11644
2024-07-31 16:44:06 +02:00
Bjørn Erik Pedersen
72ff937e11
Switch EXIF library
...
Closes #10855
Closes #8586
Closes #8996
2024-07-20 15:56:10 +02:00
Bjørn Erik Pedersen
e1317dd322
Add css.TailwindCSS
...
Closes #12618
Closes #12620
2024-06-25 15:48:02 +02:00
Joe Mooring
57165d44ed
resources: Update Dart Sass error message
2024-06-13 16:25:50 +02:00
Bjørn Erik Pedersen
1cdd3d0a9e
js: Support more recent targets with js.Build / esbuild
...
Closes #12575
2024-06-08 11:40:19 +02:00
Bjørn Erik Pedersen
bb59a7ed97
Fix one more resource change eviction logic issue
...
This is how we should have fixed #1239 .
Fixes #12456
2024-05-05 12:41:51 +02:00
Bjørn Erik Pedersen
004b694390
Fix partial rebuilds for SCSS fetched with GetMatch and similar
...
Fixes #12395
2024-04-20 15:09:12 +02:00
Bjørn Erik Pedersen
92de8625c7
babel: Run go fmt
2024-04-08 18:28:04 +02:00
guangwu
7907935a42
babel: Close file before removing
2024-04-08 15:23:08 +02:00
Christian Oliff
78178d0c2a
all: Typo fixes
2024-03-15 17:25:52 +01:00
Bjørn Erik Pedersen
0d6e593ffb
Fix and add integration test for the Bootstrap SCSS module for both Dart Sass and Libsass
...
This fixes the reverse filesystem lookup (absolute filename to path relative to the composite filesystem).
The old logic had some assumptions about the locality of the actual files that didn't work in more complex scenarios.
This commit now also adds the popular Bootstrap SCSS Hugo module to the CI build (both for libsass and dartsass transpiler), so we can hopefully avoid similar future breakage.
Fixes #12178
2024-03-01 14:18:52 +01:00
Bjørn Erik Pedersen
189b72331e
tocss: Fix the import resolving from absolute to relative assets paths
...
Fixes #12137
2024-02-24 16:41:18 +01:00
Benjamin Altpeter
554aa58db6
js: Support JSX and JSXImportSourceOptions
...
Fixes #12118
2024-02-23 10:25:27 +01:00