Skip to content

fix: Move title TOC computation to frontmatter to fix esbuild build failure#106

Merged
williamzujkowski merged 1 commit intomainfrom
fix/build-chapterhint
Mar 30, 2026
Merged

fix: Move title TOC computation to frontmatter to fix esbuild build failure#106
williamzujkowski merged 1 commit intomainfrom
fix/build-chapterhint

Conversation

@williamzujkowski
Copy link
Copy Markdown
Collaborator

Problem

Build fails with Expected identifier but found "const" — esbuild can't handle const declarations inside .map() callbacks in Astro templates. This was introduced in PR #103 (chapter hints) and broke all CI/deploy builds.

Fix

Move ALL template-level computation to the Astro frontmatter section:

  • Define ChapterView and SectionView typed interfaces
  • Pre-compute chapter hints, section status, change indicators, display titles
  • Template uses only simple property access (no const, no .map() with logic)

Verified

  • Local build: 58,032 pages in 294s — success
  • svelte-check: 0 errors
  • pnpm test: all pass

Root cause

Astro compiles template expressions to JS that esbuild processes. Complex callback logic with const in arrow functions generates invalid JS in esbuild's parser context. Moving computation to frontmatter avoids this entirely.

🤖 Generated with Claude Code

esbuild fails with "Expected identifier but found const" when Astro
templates contain const declarations inside .map() callbacks. Fix by
pre-computing all chapter and section view data in the frontmatter
section using typed interfaces (ChapterView, SectionView).

This also removes the onclick="event.stopPropagation()" which was
flagged as another esbuild issue.

Build verified: 58,032 pages in 294s locally.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@williamzujkowski williamzujkowski merged commit 828df70 into main Mar 30, 2026
@williamzujkowski williamzujkowski deleted the fix/build-chapterhint branch March 30, 2026 03:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant