Skip to content

fix(preview): isolate JS as optional module, add IIFE scope#109

Merged
markdumay merged 2 commits into
mainfrom
develop
Apr 17, 2026
Merged

fix(preview): isolate JS as optional module, add IIFE scope#109
markdumay merged 2 commits into
mainfrom
develop

Conversation

@markdumay

Copy link
Copy Markdown
Contributor

Move preview.js from the bookshop module into a dedicated optional preview module to prevent a TDZ runtime error in the production core bundle. Hugo's concatenate-then-minify pipeline caused closure variables in the nested forEach callbacks to collide after minification.

  • Add [params.modules.preview] with integration = "optional"
  • Move assets/js/modules/bookshop/preview.js → assets/js/modules/preview/preview.js
  • Wrap preview.js in an IIFE to isolate module-level consts from the concatenated bundle scope
  • Warn at build time when a page uses the preview block without declaring modules: ["preview"] in its front matter; guard with page.IsPage to avoid false positives on section index pages

markdumay and others added 2 commits April 17, 2026 08:34
Move preview.js from the bookshop module into a dedicated optional
preview module to prevent a TDZ runtime error in the production core
bundle. Hugo's concatenate-then-minify pipeline caused closure
variables in the nested forEach callbacks to collide after minification.

- Add [params.modules.preview] with integration = "optional"
- Move assets/js/modules/bookshop/preview.js →
  assets/js/modules/preview/preview.js
- Wrap preview.js in an IIFE to isolate module-level consts from the
  concatenated bundle scope
- Warn at build time when a page uses the preview block without
  declaring modules: ["preview"] in its front matter; guard with
  page.IsPage to avoid false positives on section index pages

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@markdumay markdumay enabled auto-merge April 17, 2026 06:35
@markdumay markdumay merged commit 7314b92 into main Apr 17, 2026
8 checks passed
@markdumay

Copy link
Copy Markdown
Contributor Author

🎉 This PR is included in version 1.22.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant