Skip to content

feat: emit template depth tracking instructions#1156

Merged
Princesseuh merged 2 commits into
withastro:mainfrom
seroperson:i15389-template-script-dedup
Apr 27, 2026
Merged

feat: emit template depth tracking instructions#1156
Princesseuh merged 2 commits into
withastro:mainfrom
seroperson:i15389-template-script-dedup

Conversation

@seroperson

@seroperson seroperson commented Mar 19, 2026

Copy link
Copy Markdown

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

changeset-bot Bot commented Mar 19, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b068089

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 Major

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 2 times, most recently from 0b513fd to 75ca0b5 Compare March 19, 2026 18:32
@seroperson

Copy link
Copy Markdown
Author

@matthewp @Princesseuh Hello! Sorry for ping, but would you mind reviewing this?

@seroperson
seroperson force-pushed the i15389-template-script-dedup branch from d05ca15 to a0a1082 Compare March 31, 2026 15:28
@seroperson

Copy link
Copy Markdown
Author

@matthewp @Princesseuh Sorry for pinging again =) So, after Rust PR is approved, what are next the next steps? We also have this one implementation, and the PR in Astro itself ..

@seroperson

Copy link
Copy Markdown
Author

@matthewp @Princesseuh weekly ping =)

@Princesseuh

Princesseuh commented Apr 15, 2026

Copy link
Copy Markdown
Member

Hello, yes, sorry! We'll get to it. Just needs to be careful here because Astro uses the compiler as ^3.0.1, so it would match a minor. If the compiler outputs a call that isn't implemented in Astro, it'd break everything etc. This is fine on the Rust counter-part, though, since it's experimental and what not.

Comment thread .changeset/forty-cars-lick.md Outdated

@Princesseuh Princesseuh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work, apologies for the delay!

@Princesseuh
Princesseuh merged commit 9be0456 into withastro:main Apr 27, 2026
5 checks passed
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.

2 participants