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

enhancement: Added warm feature to all SsrSite constructs #2996

Closed
wants to merge 7 commits into from
Closed

enhancement: Added warm feature to all SsrSite constructs #2996

wants to merge 7 commits into from

Conversation

SpencerDuball
Copy link
Contributor

@SpencerDuball SpencerDuball commented Jun 20, 2023

Bug Fix

There is a TypeScript issue when running pnpm build where the value returned on packages/sst/src/stacks/build.ts:66 from babel.parse can be either const ast: ParseResult<babel.types.File> | null. This is an issue as the next command babel.traverse can only accept the type Node - and null does not fit this interface.

After having a look into @babel/core it would appear that this value would only be null in the instance that there is not a config defined for babel:

  • Issue is in the parse function.
  • This returns beginHiddenCallStack which returns fn. If we go back to parse we can see this fn is equal to either parseRunner.sync or parseRunner.errback.
  • Inside parseRunner if config is null we return null.

In practice this should never happen as loadConfig should throw an error if there is a file with no configuration, but for our purposes this will basically just fix the type error by checking for null.

Enhancement: SsrSite warm Feature

  • Added a new function warmer-function which is compiled by SST and warms regionally deployed lambdas for SsrSite
  • Updated the build.mjs to build the warmer-function when SST is built, that way there is no dependence upon the consumers of the SsrSite via RemixSite, NextjsSite, (and all others) to implement the function themselves.
  • Removed the warm and createWarmer pieces of the NextjsSite as this now happens more generally for all SsrSite
  • Updated SsrSite to implement the warm and createWarmer

@changeset-bot
Copy link

changeset-bot bot commented Jun 20, 2023

⚠️ No Changeset found

Latest commit: c36bc48

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@SpencerDuball SpencerDuball changed the title bug: Add type narrow to prevent TypeScript build issues for sst enhancement: Added feature to SsrSite, removed features from NextjsSite to share code Jun 20, 2023
@SpencerDuball
Copy link
Contributor Author

SpencerDuball commented Jun 20, 2023

fixes #2988

@SpencerDuball SpencerDuball changed the title enhancement: Added feature to SsrSite, removed features from NextjsSite to share code enhancement: Added warm feature to all SsrSite constructs Jun 20, 2023
@fwang
Copy link
Contributor

fwang commented Sep 13, 2023

Thanks @SpencerDuball!

There were some conflicts.. I copied over the changes in #3301

@fwang fwang closed this Sep 13, 2023
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