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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[node] Add isomorphic functions #9947

Merged
merged 16 commits into from Jun 6, 2023
Merged

[node] Add isomorphic functions #9947

merged 16 commits into from Jun 6, 2023

Conversation

Kikobeats
Copy link
Member

@Kikobeats Kikobeats commented May 12, 2023

This PR allow using Web APIs in Serverless functions

// api/serverless.js
export const GET = () => {
  return new Response(`new Response('馃憢 Hello from Serverless Web!)`)
}

More about that https://nextjs.org/docs/app/building-your-application/routing/router-handlers

@changeset-bot
Copy link

changeset-bot bot commented May 12, 2023

馃 Changeset detected

Latest commit: 9ad8318

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

This PR includes changesets to release 4 packages
Name Type
vercel Minor
@vercel/node Minor
@vercel/gatsby-plugin-vercel-builder Patch
@vercel/static-build 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
Contributor

@EndangeredMassa EndangeredMassa left a comment

Choose a reason for hiding this comment

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

I didn't manually test this yet, but it's looking awesome

if (!message.startsWith('Error:')) {
message = `Error: ${message}`;
}
console.error(message);
Copy link
Contributor

Choose a reason for hiding this comment

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

This is an improvement, but I realized we show errors differently between startup/runtime and serverless-node/edge. We should standardize those differences, but not in this PR.

Copy link
Contributor

@cb1kenobi cb1kenobi left a comment

Choose a reason for hiding this comment

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

Code looks good. I tested a handful of scenarios and didn't find any issues.

// @ts-expect-error - `node-fetch` Headers is missing `getAll()`
Headers,
});
const toHeaders = buildToHeaders({ Headers });
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand how this TS error was fixed :thinkies:

Copy link
Contributor

Choose a reason for hiding this comment

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

Upgrading @edge-runtime/node-utils fixed the issue I think because of this PR: vercel/edge-runtime#309

@Kikobeats Kikobeats merged commit 0039c8b into main Jun 6, 2023
103 checks passed
@Kikobeats Kikobeats deleted the isomorphic branch June 6, 2023 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: node semver: minor PR contains new features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants