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

Add top-level await support for SSR #2987

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

FredKSchott
Copy link
Owner

@FredKSchott FredKSchott commented Mar 25, 2021

Changes

  • Top level await support exists in Node.js (14+) and browsers (Chrome)
  • This changes new Function to new AsyncFunction. I played around with a smart picker between the two different Function constructors based on whether top-level await existed in the file or not. But ultimately, the performance cost to walk the ast to detect that didn't outweigh the performance cost of an unnecessary Promise wrapper in non-top-level-await files.
  • This fixes an issue where our SSR parser would error on top-level await due to a parser bug: Error trying to use top-level await? meriyah/meriyah#186 Acorn is slower than meriyah, but feature completeness and stability should be our first priority here. I'd love to add meriyah back as soon as that issue is resolved. And, lets hold off on merging a bit in case they're able to fix the issue. Fixed in meriyah! No longer needed, removed from this PR.

Testing

  • TODO: Test needed

Docs

  • N/A

@vercel
Copy link

vercel bot commented Mar 25, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/pikapkg/snowpack/Hp2TjvFHJscYPCYuoyPHvt1WNFQi
✅ Preview: https://snowpack-git-support-top-level-await-pikapkg.vercel.app

@FredKSchott FredKSchott self-assigned this Mar 31, 2021
@changeset-bot
Copy link

changeset-bot bot commented Jul 21, 2021

🦋 Changeset detected

Latest commit: ec20cf8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
snowpack 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants