fix: prevent script dedup inside <template>#15980
Conversation
🦋 Changeset detectedLatest commit: 3dddc73 The changes in this PR will be included in the next version bump. 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 |
8a2e551 to
a11ac94
Compare
866a50e to
949a1e1
Compare
matthewp
left a comment
There was a problem hiding this comment.
This is a very expensive change, for something that is a bit of a corner case. I don't want to make this change this way. Will explain an alternative approach in a comment.
|
Basically we need to know that we are "inside of a template" in order to maybe not emit the script. I think that's really only possible through a compiler change. If you have that, you would know when you've exited all possible templates and then could emit the script. cc @Princesseuh |
949a1e1 to
6202b78
Compare
|
@matthewp Thank you for the review! Oh, I wasn't aware about such ability at all. Yea, compiler-based approach looks much better. I filled the PR to compiler and did necessary changes here to support it. Well, then waiting compiler to be merged and then I'll update the version here. P.S. I actually "moved" this render instruction to be inlined by compiler, so logic within this PR left mostly unchanged (except placing instructions of course). |
|
I've also mirrored the same functionality in |
1addff9 to
6a336b2
Compare
|
@seroperson are the failures in CI expected? |
|
@ematipico we are waiting for the compiler to be released, then here we should bump its version and ensure everything works |
…t-dedup # Conflicts: # packages/astro/package.json # pnpm-lock.yaml
ArmandPhilippot
left a comment
There was a problem hiding this comment.
A nit for consistency with how we write changesets (ie. present tense verb), otherwise LGTM!
yanthomasdev
left a comment
There was a problem hiding this comment.
Docs LGTM after Armand suggestion is applied.
Co-authored-by: Armand Philippot <[email protected]>
Co-authored-by: Erika <[email protected]>
merge
This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | |---|---|---|---| | [astro](https://astro.build) ([source](https://github.com/withastro/astro/tree/HEAD/packages/astro)) | [`6.1.10` → `6.2.1`](https://renovatebot.com/diffs/npm/astro/6.1.10/6.2.1) |  |  | --- ### Release Notes <details> <summary>withastro/astro (astro)</summary> ### [`v6.2.1`](https://github.com/withastro/astro/blob/HEAD/packages/astro/CHANGELOG.md#621) [Compare Source](https://github.com/withastro/astro/compare/[email protected]@6.2.1) ##### Patch Changes - [#​16531](withastro/astro#16531) [`76db01d`](withastro/astro@76db01d) Thanks [@​rodrigosdev](https://github.com/rodrigosdev)! - Fixes config validation for omitted `integrations` fields with newer Zod versions. - [#​16535](withastro/astro#16535) [`7df0fe4`](withastro/astro@7df0fe4) Thanks [@​rururux](https://github.com/rururux)! - Fixed an issue where a warning was displayed when the `server` property was missing during config validation, even though it is not required. - [#​16534](withastro/astro#16534) [`5cf6c51`](withastro/astro@5cf6c51) Thanks [@​matthewp](https://github.com/matthewp)! - Fixes compatibility with Zod 4.4.0 for the `server` config property and error formatting ### [`v6.2.0`](https://github.com/withastro/astro/blob/HEAD/packages/astro/CHANGELOG.md#620) [Compare Source](https://github.com/withastro/astro/compare/[email protected]@6.2.0) ##### Minor Changes - [#​16187](withastro/astro#16187) [`fe58071`](withastro/astro@fe58071) Thanks [@​gllmt](https://github.com/gllmt)! - Adds a `waitUntil` option to the `RenderOptions` so that adapters can forward runtime background-task hooks to Astro. When provided by an adapter, runtime cache providers receive `context.waitUntil` in `CacheProvider.onRequest()`, which allows background cache work such as stale-while-revalidate without blocking the response. The Cloudflare adapter now forwards `ExecutionContext.waitUntil` to this API. - [#​16290](withastro/astro#16290) [`a49637a`](withastro/astro@a49637a) Thanks [@​ViVaLaDaniel](https://github.com/ViVaLaDaniel)! - Ensures that `server.allowedHosts` (and `vite.preview.allowedHosts`) configuration is respected when using `astro preview` with the `@astrojs/cloudflare` adapter. This improves security by preventing DNS rebinding attacks when previewing Cloudflare builds locally. - [#​15725](withastro/astro#15725) [`4108ec1`](withastro/astro@4108ec1) Thanks [@​meyer](https://github.com/meyer)! - Adds support for a new `'jsx'` value for the `compressHTML` option. When set, whitespace is stripped using JSX whitespace rules instead of the default HTML compression strategy. ```js // astro.config.mjs import { defineConfig } from 'astro/config'; export default defineConfig({ compressHTML: 'jsx', }); ``` In JSX, whitespaces never matter, as such, no amount of indentation, or newlines will not affect the rendered output. For instance, the following code: ```jsx <div> <span>foo</span> <span>bar</span> </div> ``` will be rendered as `foobar`, whereas with HTML whitespace rules, a space would be present between the words due to the newline and indentation between the tags. - [#​16477](withastro/astro#16477) [`28fb3e1`](withastro/astro@28fb3e1) Thanks [@​ematipico](https://github.com/ematipico)! - Adds experimental support for configurable log handlers. This experimental feature provides better control over Astro's logging infrastructure by allowing users to replace the default console output with custom logging implementations (e.g., structured JSON). This is particularly useful for users using on-demand rendering and wishing to connect their log aggregation services, such as Kibana, Logstash, CloudWatch, Grafana, or Loki. By default, Astro provides three built-in log handlers (`json`, `node`, and `console`), but you can also create your own. ##### JSON logging JSON logging can be enabled via the CLI for the `build`, `dev`, and `sync` commands using the `experimentalJson` flag: ```js // astro.config.mjs import { defineConfig, logHandlers } from 'astro/config'; export default defineConfig({ experimental: { logger: logHandlers.json({ pretty: true, level: 'warn', }), }, }); ``` ##### Custom logger You can also create your own custom logger by implementing the correct interface: ```js // astro.config.mjs import { defineConfig } from 'astro/config'; export default defineConfig({ experimental: { logger: { entrypoint: '@​org/custom-logger', }, }, }); ``` ```ts // @​org/custom-logger.js import type { AstroLoggerDestination, AstroLoggerMessage } from 'astro'; import { matchesLevel } from 'astor/logger'; function customLogger(level = 'info'): AstroLoggerDestination { return { write(message: AstroLoggerMessage) { if (matchesLevel(message.level, level)) { // write message somewhere } }, }; } export default customLogger; ``` For more information on enabling and using this feature in your project, see the [Experimental Logger docs](https://docs.astro.build/en/reference/experimental-flags/logger/). For a complete overview and to give feedback on this experimental API, see the [Custom logger RFC](https://github.com/withastro/roadmap/blob/logger/proposals/0059-custom-logger.md). - [#​16333](withastro/astro#16333) [`0f7c3c8`](withastro/astro@0f7c3c8) Thanks [@​florian-lefebvre](https://github.com/florian-lefebvre)! - Adds an experimental flag `svgOptimizer` that enables automatic optimization of your SVG components using the provided optimizer. This supersedes the `svgo` experimental flag, which is now removed. When enabled, your imported SVG files used as components will be optimized for smaller file sizes and better performance while maintaining visual quality. This can significantly reduce the size of your SVG assets by removing unnecessary metadata, comments, and redundant code. Astro ships with a [SVGO](https://svgo.dev/) based optimizer, but any can be used. To enable this feature, add the experimental flag in your Astro config and remove `svgo` if it was enabled: ```diff // astro.config.mjs -import { defineConfig } from "astro/config"; +import { defineConfig, svgoOptimizer } from "astro/config"; export default defineConfig({ + experimental: { + svgOptimizer: svgoOptimizer() - svgo: true + } }); ``` For more information on enabling and using this feature in your project, see the [experimental SVG optimization docs](https://docs.astro.build/en/reference/experimental-flags/svg-optimization/). - [#​16302](withastro/astro#16302) [`f6f8e80`](withastro/astro@f6f8e80) Thanks [@​florian-lefebvre](https://github.com/florian-lefebvre)! - Adds a new `experimental_getFontFileURL()` method to resolve font file URLs when using the Fonts API The `fontData` object exported from `astro:assets` was introduced to provide low-level access to font family data for advanced usage. One of the goals of this API was to be able to resolve buffers using URLs. However, it turned out to be impractical, especially during prerendering. Astro now exports a new `experimental_getFontFileURL()` helper function from `astro:assets` to resolve font file URLs from `fontData`. For example, when using [satori](https://github.com/vercel/satori) to generate Open Graph images: ```diff // src/pages/og.png.ts import type { APIRoute } from "astro"; -import { fontData } from "astro:assets"; +import { fontData, experimental_getFontFileURL } from "astro:assets"; -import { outDir } from "astro:config/server"; -import { readFile } from "node:fs/promises"; import satori from "satori"; import { html } from "satori-html"; import sharp from "sharp"; export const GET: APIRoute = async (context) => { const fontPath = fontData["--font-roboto"][0]?.src[0]?.url; if (fontPath === undefined) { throw new Error("Cannot find the font path."); } - const data = import.meta.env.DEV - ? await fetch(new URL(fontPath, context.url.origin)).then(async (res) => res.arrayBuffer()) - : await readFile(new URL(`.${fontPath}`, outDir)); + const url = experimental_getFontFileURL(fontPath, context.url); + const data = await fetch(url).then((res) => res.arrayBuffer()); const svg = await satori( html`<div style="color: black;">hello, world</div>`, { width: 600, height: 400, fonts: [ { name: "Roboto", data, weight: 400, style: "normal", }, ], }, ); const pngBuffer = await sharp(Buffer.from(svg)) .resize(600, 400) .png() .toBuffer(); return new Response(new Uint8Array(pngBuffer), { headers: { "Content-Type": "image/png", }, }); }; ``` See the [Fonts API documentation](https://docs.astro.build/en/guides/fonts/#accessing-font-data-programmatically) for more information. ##### Patch Changes - [#​15980](withastro/astro#15980) [`8812382`](withastro/astro@8812382) Thanks [@​seroperson](https://github.com/seroperson)! - Prevents script deduplication inside `<template>` elements </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xNDEuNiIsInVwZGF0ZWRJblZlciI6IjQzLjE0MS42IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | |---|---|---|---| | [@astrojs/compiler-rs](https://astro.build) ([source](https://redirect.github.com/withastro/compiler-rs)) | [`^0.1.4` → `^0.2.0`](https://renovatebot.com/diffs/npm/@astrojs%2fcompiler-rs/0.1.10/0.2.3) |  |  | --- ### Release Notes <details> <summary>withastro/compiler-rs (@​astrojs/compiler-rs)</summary> ### [`v0.2.3`](https://redirect.github.com/withastro/compiler-rs/releases/tag/%40astrojs/compiler-rs%400.2.3) [Compare Source](https://redirect.github.com/withastro/compiler-rs/compare/@astrojs/[email protected]...@astrojs/[email protected]) ##### Patch Changes - [`6a56dea`](https://redirect.github.com/withastro/compiler-rs/commit/6a56dea): Fixes several cases of adjacent JSX elements inside a `{...}` expression acting weirdly, including: - HTML comments between the elements now render instead of being dropped, including when a comment is on its own line. - Whitespace between the elements is preserved. - A `<script>` that is not the first element no longer fails to parse when its body contains an HTML closing tag inside a template literal. - [`c5b8921`](https://redirect.github.com/withastro/compiler-rs/commit/c5b8921): Fixes compact mode not collapsing whitespace inside component and custom-element slot content. - [`fd756ce`](https://redirect.github.com/withastro/compiler-rs/commit/fd756ce): Fixes several cases where `await` failed to make the generated code `async`, producing invalid JavaScript. - [`7bd7e32`](https://redirect.github.com/withastro/compiler-rs/commit/7bd7e32): Fixes a parse error on `{{ ... }}` shorthand attributes containing an object expression, such as `<Debug {{ answer: sum(2, 4) }} />`. These now compile correctly instead of suggesting to use a spread attribute. - [`6a56dea`](https://redirect.github.com/withastro/compiler-rs/commit/6a56dea): Fixes a `<style>` nested in a `{...}` expression (e.g. `{cond && <style>…</style>}`) being silently dropped from the output. - [`8b6d424`](https://redirect.github.com/withastro/compiler-rs/commit/8b6d424): Fixes an "Invalid Character" error on unquoted attribute values that start with `#` followed by a digit, such as `<div color=#​18b218 />`. Unquoted hex colors now parse correctly. - Updated dependencies \[[`6a56dea`](https://redirect.github.com/withastro/compiler-rs/commit/6a56dea)] - Updated dependencies \[[`c5b8921`](https://redirect.github.com/withastro/compiler-rs/commit/c5b8921)] - Updated dependencies \[[`fd756ce`](https://redirect.github.com/withastro/compiler-rs/commit/fd756ce)] - Updated dependencies \[[`7bd7e32`](https://redirect.github.com/withastro/compiler-rs/commit/7bd7e32)] - Updated dependencies \[[`6a56dea`](https://redirect.github.com/withastro/compiler-rs/commit/6a56dea)] - Updated dependencies \[[`8b6d424`](https://redirect.github.com/withastro/compiler-rs/commit/8b6d424)] - [@​astrojs/compiler-binding](https://redirect.github.com/astrojs/compiler-binding)@​0.2.3 ### [`v0.2.2`](https://redirect.github.com/withastro/compiler-rs/releases/tag/%40astrojs/compiler-rs%400.2.2) [Compare Source](https://redirect.github.com/withastro/compiler-rs/compare/@astrojs/[email protected]...@astrojs/[email protected]) ##### Patch Changes - [`6133672`](https://redirect.github.com/withastro/compiler-rs/commit/6133672): Improved diagnostics when Astro sees a stray closing tag. Now Astro correctly shows the closing tag that doesn't match an open tag. - [`23038db`](https://redirect.github.com/withastro/compiler-rs/commit/23038db): Fixes `compact: 'jsx'` stripping significant same-line whitespace. JSX whitespace is now only trimmed where it borders a line break (matching React/Babel's rules), so a space at a text/expression, text/element, or element/element boundary is preserved. `<h1>Page {n}</h1>` now keeps its space (`Page 1`), as does `<span>hello</span> <em>world</em>`. Whitespace adjacent to newlines is still collapsed. - Updated dependencies \[[`6133672`](https://redirect.github.com/withastro/compiler-rs/commit/6133672)] - Updated dependencies \[[`23038db`](https://redirect.github.com/withastro/compiler-rs/commit/23038db)] - [@​astrojs/compiler-binding](https://redirect.github.com/astrojs/compiler-binding)@​0.2.2 ### [`v0.2.1`](https://redirect.github.com/withastro/compiler-rs/releases/tag/%40astrojs/compiler-rs%400.2.1) [Compare Source](https://redirect.github.com/withastro/compiler-rs/compare/@astrojs/[email protected]...@astrojs/[email protected]) ##### Patch Changes - [`eddd417`](https://redirect.github.com/withastro/compiler-rs/commit/eddd417): Fixes CSS scoping incorrectly adding a scope to `&::pseudo-element` selectors (e.g. `&::marker`, `&::before`) and to selectors that only reference `&` inside `:is()`/`:where()`/`:not()`/`:has()`. - [`f4adcce`](https://redirect.github.com/withastro/compiler-rs/commit/f4adcce): Fixes `Unterminated string literal` error when a quoted attribute on a component contains literal newlines (e.g. multi-line `class`). - [`ecb43d3`](https://redirect.github.com/withastro/compiler-rs/commit/ecb43d3): Fixes JSX not being transformed inside function declarations, class declarations and expressions, `throw` statements, and `for`-loop initializers. - Updated dependencies \[[`eddd417`](https://redirect.github.com/withastro/compiler-rs/commit/eddd417)] - Updated dependencies \[[`f4adcce`](https://redirect.github.com/withastro/compiler-rs/commit/f4adcce)] - Updated dependencies \[[`ecb43d3`](https://redirect.github.com/withastro/compiler-rs/commit/ecb43d3)] - [@​astrojs/compiler-binding](https://redirect.github.com/astrojs/compiler-binding)@​0.2.1 ### [`v0.2.0`](https://redirect.github.com/withastro/compiler-rs/releases/tag/%40astrojs/compiler-rs%400.2.0) [Compare Source](https://redirect.github.com/withastro/compiler-rs/compare/@astrojs/[email protected]...@astrojs/[email protected]) ##### Minor Changes - [`0726e00`](https://redirect.github.com/withastro/compiler-rs/commit/0726e00): Emit `templateEnter` / `templateExit` instructions when printing `<template>` elements for [withastro/astro#15980](https://redirect.github.com/withastro/astro/pull/15980) ##### Patch Changes - [`0bddba4`](https://redirect.github.com/withastro/compiler-rs/commit/0bddba4): Fixes `Unexpected token` error when an HTML attribute has an unquoted value such as a number (`<input maxlength=255>`) or contains characters like `-` or `#`. - Updated dependencies \[[`0bddba4`](https://redirect.github.com/withastro/compiler-rs/commit/0bddba4)] - Updated dependencies \[[`0726e00`](https://redirect.github.com/withastro/compiler-rs/commit/0726e00)] - [@​astrojs/compiler-binding](https://redirect.github.com/astrojs/compiler-binding)@​0.2.0 </details> --- ### Configuration 📅 **Schedule**: (in timezone Asia/Tokyo) - Branch creation - "before 9am on saturday" - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/HagaSpa/HagaSpa.github.io). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xNzkuMyIsInVwZGF0ZWRJblZlciI6IjQzLjI0Mi4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiXX0=--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Closes #15389,
Closed #13795
When a component with a script was first used inside a
<template>, Astro's deduplication prevented the script from rendering outside the template, breaking non-template instances. This PR makes such scripts are not deduplicated. Should be merged after withastro/compiler#1156.Changes
templateEnter/templateExitfunctions to be inlined by compiler inside of<template>tags. These functions add instructions that track<template>nesting depth during rendering.stringifyChunkskips dedup for scripts whentemplateDepth > 0. The script still renders inside the template but is also rendered outside for non-template instances.Testing
Added
astro-script-template-dedupintegration test with four cases:<template>first, then outside: verifies script appears in both places<template>elements: verifies depth tracking handles nestingDocs
Docs aren't required as it's a bugfix.