Skip to content

Commit e9b31f8

Browse files
committed
refactor(preact): switch from vendored globals to bundled node_modules approach
- Add preact dependency to all 6 starter package.json files for proper js.Build resolution - Use automatic JSX runtime (JSX: "automatic", JSXImportSource: "preact") in libraries.html - Restore proper ES module imports in hero/client.jsx and Icon.jsx components - Remove vendored preact script loading since preact is now bundled via js.Build - Fixes CI build failures with "Could not resolve preact/jsx-runtime" errors - Provides cleaner, more standard JS tooling for users extending with custom components BREAKING CHANGE: Starters now require `preact` in `package.json`to resolve preact dependency before hugo build
1 parent c843d01 commit e9b31f8

File tree

9 files changed

+12
-19
lines changed

9 files changed

+12
-19
lines changed

modules/blox-tailwind/blox/hero/client.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Uses the shared component for consistency
44
*/
55

6-
// Use global preact (loaded via script tag) with classic JSX transform
6+
import {render} from "preact";
77
import {HeroBlock} from "./component.jsx";
88

99
// Render function - immediately renders Hero components
@@ -18,7 +18,7 @@ function renderHeroBlocks() {
1818
const props = JSON.parse(propsData);
1919

2020
// Render the Preact component into the container
21-
preact.render(<HeroBlock {...props} />, block);
21+
render(<HeroBlock {...props} />, block);
2222
console.debug(`✓ Hero block "${block.id}" rendered with Preact`);
2323
} catch (error) {
2424
console.error(`Failed to render Hero block "${block.id}":`, error);

modules/blox-tailwind/blox/shared/js/components/Icon.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Use classic JSX transform with global preact; no direct import
1+
import {h} from "preact";
22

33
/**
44
* Icon component

modules/blox-tailwind/layouts/_partials/libraries.html

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,7 @@
33
{{ if .Page.Store.Get "needs_preact" }}
44
{{ $preact_blocks := .Page.Store.Get "preact_blocks" | default slice }}
55

6-
{{/* Load Preact core library */}}
7-
{{ $preact_core := resources.Get "dist/lib/preact/preact.min.js" }}
8-
{{ if $preact_core }}
9-
{{ $preact_core = $preact_core | resources.Fingerprint "sha256" }}
10-
<script src="{{ $preact_core.RelPermalink }}" integrity="{{ $preact_core.Data.Integrity }}"></script>
11-
12-
{{/* Publish the source map so the browser can load it at the expected path */}}
13-
{{ $preact_map := resources.Get "dist/lib/preact/preact.min.js.map" }}
14-
{{ if $preact_map }}
15-
{{ $preact_map.Publish }}
16-
{{ end }}
17-
18-
{{ end }}
6+
{{/* Preact is now bundled with each template via js.Build and node_modules */}}
197

208
{{/* Build and load each Preact block's client script */}}
219
{{ range $block_type := $preact_blocks }}
@@ -26,9 +14,8 @@
2614
{{/* Build the client-side JSX using Hugo's official integration */}}
2715
{{ $jsx_opts := dict
2816
"targetPath" (printf "assets/js/preact-built/%s.js" $block_type)
29-
"JSX" "transform"
30-
"JSXFactory" "preact.h"
31-
"JSXFragment" "preact.Fragment"
17+
"JSX" "automatic"
18+
"JSXImportSource" "preact"
3219
"format" "iife"
3320
"minify" hugo.IsProduction
3421
"sourceMap" (cond hugo.IsDevelopment "external" "")

starters/academic-cv/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"dependencies": {
1212
"@tailwindcss/cli": "^4.1.12",
1313
"@tailwindcss/typography": "^0.5.10",
14+
"preact": "^10.27.2",
1415
"tailwindcss": "^4.1.12"
1516
}
1617
}

starters/blog/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"dependencies": {
1212
"@tailwindcss/cli": "^4.1.12",
1313
"@tailwindcss/typography": "^0.5.10",
14+
"preact": "^10.27.2",
1415
"tailwindcss": "^4.1.12"
1516
}
1617
}

starters/documentation/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"dependencies": {
1212
"@tailwindcss/cli": "^4.1.12",
1313
"@tailwindcss/typography": "^0.5.10",
14+
"preact": "^10.27.2",
1415
"tailwindcss": "^4.1.12"
1516
}
1617
}

starters/landing-page/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"dependencies": {
1212
"@tailwindcss/cli": "^4.1.12",
1313
"@tailwindcss/typography": "^0.5.10",
14+
"preact": "^10.27.2",
1415
"tailwindcss": "^4.1.12"
1516
}
1617
}

starters/link-in-bio/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"dependencies": {
1212
"@tailwindcss/cli": "^4.1.12",
1313
"@tailwindcss/typography": "^0.5.10",
14+
"preact": "^10.27.2",
1415
"tailwindcss": "^4.1.12"
1516
}
1617
}

starters/resume/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"dependencies": {
1212
"@tailwindcss/cli": "^4.1.12",
1313
"@tailwindcss/typography": "^0.5.10",
14+
"preact": "^10.27.2",
1415
"tailwindcss": "^4.1.12"
1516
}
1617
}

0 commit comments

Comments
 (0)