Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip printing async if await is not used #1004

Merged
merged 1 commit into from
May 1, 2024
Merged

Skip printing async if await is not used #1004

merged 1 commit into from
May 1, 2024

Conversation

bluwy
Copy link
Member

@bluwy bluwy commented Apr 30, 2024

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.

Copy link

changeset-bot bot commented Apr 30, 2024

🦋 Changeset detected

Latest commit: ff02944

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

Copy link
Member

@natemoo-re natemoo-re left a comment

Choose a reason for hiding this comment

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

LGTM! Glad to see that this idea does have some small gains.

@bluwy bluwy merged commit ecd7e90 into main May 1, 2024
5 checks passed
@bluwy bluwy deleted the skip-async-no-await branch May 1, 2024 08:16
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.

None yet

2 participants