What happened?
While upgrading a theme from Astro 5 to 7, scripts combining is:inline data-astro-rerun define:vars={{ … }} silently lost data-astro-rerun in the built HTML. The scripts then no longer re-execute after ClientRouter navigations, so features relying on that pattern (a giscus embed, a page toggle) die after the first SPA navigation. No build error or warning — we only caught it by diffing v5 vs v7 dist/ output.
Minimal reproduction (compiler-level, no project needed)
const c = require("@astrojs/compiler-rs");
const src = `---
const g = { a: 1 };
---
<script is:inline data-astro-rerun define:vars={{ g }}>
console.log(g);
</script>
<script is:inline data-astro-rerun>
console.log(1);
</script>
`;
c.transform(src, { filename: "Probe.astro" }).then((o) => console.log(o.code));
Output with @astrojs/compiler-rs 0.3.1 (template part, abbreviated):
<script>(function(){${$$defineScriptVars({ g })} … })();<\/script> ← attribute dropped
<script data-astro-rerun> … <\/script> ← attribute kept
The Astro 5 compiler preserved the remaining attributes on define:vars scripts (<script data-astro-rerun>(function(){…})()).
Root cause
In crates/astro_codegen/src/printer/mod.rs, the define:vars branch prints hardcoded opening tags instead of the element's remaining attributes:
Everything except define:vars / is:inline (and the type="module" it re-emits) is discarded — including data-astro-rerun, id, nonce, and any data-*.
Expected behavior
Attributes other than the compiler directives should be preserved on the emitted <script> tag, matching the v5 compiler's behavior.
Happy to send a PR if that helps.
Versions
astro 7.1.1, @astrojs/compiler-rs 0.3.1, Node 25.3.0, Linux
What happened?
While upgrading a theme from Astro 5 to 7, scripts combining
is:inline data-astro-rerun define:vars={{ … }}silently lostdata-astro-rerunin the built HTML. The scripts then no longer re-execute after ClientRouter navigations, so features relying on that pattern (a giscus embed, a page toggle) die after the first SPA navigation. No build error or warning — we only caught it by diffing v5 vs v7dist/output.Minimal reproduction (compiler-level, no project needed)
Output with
@astrojs/compiler-rs0.3.1 (template part, abbreviated):The Astro 5 compiler preserved the remaining attributes on
define:varsscripts (<script data-astro-rerun>(function(){…})()).Root cause
In
crates/astro_codegen/src/printer/mod.rs, thedefine:varsbranch prints hardcoded opening tags instead of the element's remaining attributes:<script type="module">)<script>)Everything except
define:vars/is:inline(and thetype="module"it re-emits) is discarded — includingdata-astro-rerun,id,nonce, and anydata-*.Expected behavior
Attributes other than the compiler directives should be preserved on the emitted
<script>tag, matching the v5 compiler's behavior.Happy to send a PR if that helps.
Versions
astro 7.1.1, @astrojs/compiler-rs 0.3.1, Node 25.3.0, Linux