Skip to content

feat: emit template depth tracking instructions#1156

Open
seroperson wants to merge 1 commit intowithastro:mainfrom
seroperson:i15389-template-script-dedup
Open

feat: emit template depth tracking instructions#1156
seroperson wants to merge 1 commit intowithastro:mainfrom
seroperson:i15389-template-script-dedup

Conversation

@seroperson
Copy link

@seroperson seroperson commented Mar 19, 2026

This PR adds a special handling for <template> tags, so they call special templateEnter and templateExit functions. It's necessary for withastro/astro#15980 PR.

Changes

  • print-to-js.go now detects template nodes and adds templateEnter / templateExit calls inside.
  • transform/transform.go now fills ContainsTemplateElement flag to be able to dynamically include imports later.

Testing

  • Added two snap tests to confirm the behavior: simple <template> case and nested case

Docs

I'm unsure whether it should be documented. I can add the documentation somewhere if needed.

@changeset-bot
Copy link

changeset-bot bot commented Mar 19, 2026

🦋 Changeset detected

Latest commit: 75ca0b5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@astrojs/compiler Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@seroperson seroperson force-pushed the i15389-template-script-dedup branch from 616b1f0 to 0b513fd Compare March 19, 2026 18:26
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