withastro / compiler

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

Skip printing async if await is not used #1004

Closed bluwy closed 6 months ago

bluwy commented 6 months ago

Changes

Idea by @natemoo-re. Currently we always print the component function with async even if no top-level await is used:

const $$stdin = $$createComponent(async ($$result, $$props, $$slots) => {

We can skip printing the async if no await is used so that rendering the component won't always require one tick.


Performance:

This should improve page rendering. With the Astro docs repo, it fluctuates between 35-42s a lot, so it's hard to make a concrete comparison. But compared to the old timings, the average timing dropped about 1-2s.

Testing

Updated test

Docs

n/a. internal improvement.

changeset-bot[bot] commented 6 months ago

🦋 Changeset detected

Latest commit: ff0294442a6559a9dda34eea46e001555f2cd909

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