Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getBundle only works once in .11ty.js templates, then fails to replace #26

Open
kfranqueiro opened this issue May 22, 2024 · 1 comment

Comments

@kfranqueiro
Copy link

I seem to have stumbled into some confusing behavior that I'm seeing when using getBundle and/or getBundleFileUrl specifically within a .11ty.js layout used by multiple templates.

I've created a repo to reproduce the issue: https://github.com/kfranqueiro/11ty-js-getbundle-bug

To better illustrate the issue, the repo begins in a working state. It has 3 templates (one HTML/Liquid, one JS, one Markdown) and 2 layouts (one HTML/Liquid, one JS).

In its initial state, all 3 templates are using the HTML layout, and npm run build produces the expected results: all 3 resulting pages have CSS both inlined and referenced via separate files properly.

Where things get interesting, is when you start switching those templates to use the JS layout...

  1. When you switch 1 over, everything is still fine
  2. When you switch 2 over (seemingly regardless of which 2 exactly), 1 out of 2 will be broken, with incorrect output still containing __EleventyBundle comments that should have been replaced
  3. When you switch all 3 over, 2 out of 3 will be broken as above

Somehow getBundle and getBundleFileUrl within the .11ty.js layout only ever work for one page?

(For what it's worth, this also happens if only using getBundle; I added getBundleFileUrl to the example later to see if it behaved the same)

  • Eleventy: 3.0.0-alpha.10 + eleventy-plugin-bundle 2.0.2
  • Node: 20.13.1
  • OS: Linux (Debian 12)
@troyvassalotti
Copy link

I think I'm having the same issue as this and created my own repo for reproduction before stumbling here: https://github.com/troyvassalotti/mvp-eleventy-bundle-debug.

In my case, my site's homepage has a bundle that doesn't get output at all, while other pages have mixed results.

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

No branches or pull requests

2 participants