withastro / compiler

The Astro compiler. Written in Go. Distributed as WASM.
Other
503 stars 59 forks source link

Adds lint rules for `data-astro-reload` and `data-astro-rerun` on script tags #965

Closed martrapp closed 8 months ago

martrapp commented 9 months ago

Changes

Depends on https://github.com/withastro/astro/pull/9977

Supports transition:reload as a nice Astro way to set data-astro-reload. Warns if data-astro-*attributes are used the wrong way during view transitions.

For some time now, you can set data-astro-reload to a tag to skip view transitions in favor of full page loads. https://github.com/withastro/astro/pull/9977 will also use data-astro-reload data-astro-rerun to mark <scripts> for re-execution during view transitions.

Update:

Since we have now separated data-astro-reload and data-astro-rerun (for scripts), I would stay with the data attributes and prefer not to introduce any additional directives.

The original warnings about transition:reload were unnecessary as they are better covered by packages/astro/astro-jsx.d.ts are carried over.

Testing

added test case

Docs

I will open a PR if this one gets accepted, see https://github.com/withastro/docs/pull/6856

changeset-bot[bot] commented 9 months ago

🦋 Changeset detected

Latest commit: adf00d0e156a02f80197b6af086762120af22bd2

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 | Patch |

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

martrapp commented 9 months ago

!preview transition-reload

github-actions[bot] commented 9 months ago
 > root@0.0.0 release /home/runner/work/compiler/compiler > changeset publish "--tag" "next--transition-reload" 🦋 warn ===============================IMPORTANT!=============================== 🦋 warn Packages will be released under the next--transition-reload tag 🦋 warn ---------------------------------------------------------------------- 🦋 info npm info @astrojs/compiler 🦋 info @astrojs/compiler is being published because our local version (0.0.0-transition-reload-20240211162919) has not been published on npm 🦋 info Publishing "@astrojs/compiler" at "0.0.0-transition-reload-20240211162919" 🦋 success packages published successfully: 🦋 @astrojs/compiler@0.0.0-transition-reload-20240211162919 🦋 Creating git tag... 🦋 New tag: @astrojs/compiler@0.0.0-transition-reload-20240211162919
martrapp commented 9 months ago

/cc @withastro/maintainers-docs for help with the warning messages and changeset.

martrapp commented 9 months ago

This one depends on https://github.com/withastro/astro/pull/9977 So i will merge with/after v4.5

martrapp commented 9 months ago

Haha, thank you for pointing that out! Yes, the "ECMAScript Module" is a bit bulky. I would typically use ESM in that context, but I do not like to use abbreviations when I can't properly introduce them. I guess we go for "module scripts" as it becomes clear from the context.