Skip to content

Conversation

@GauBen
Copy link
Contributor

@GauBen GauBen commented Sep 25, 2024

The default is not node18 as advertised but guessed at build time with the get_default_runtime function


Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

Edits

  • Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.

@changeset-bot
Copy link

changeset-bot bot commented Sep 25, 2024

🦋 Changeset detected

Latest commit: c797e19

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

This PR includes changesets to release 1 package
Name Type
@sveltejs/adapter-vercel 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

@GauBen
Copy link
Contributor Author

GauBen commented Sep 25, 2024

node${number}.x does not show auto-complete, which is not so great. I suggest explicit strings instead

@GauBen
Copy link
Contributor Author

GauBen commented Sep 25, 2024

image

Better!

@teemingc teemingc changed the title style(adapter-vercel): updated @default annotation for runtime fix: updated @default annotation for runtime Sep 27, 2024
@teemingc teemingc added the pkg:adapter-vercel Pertaining to the Vercel adapter label Sep 27, 2024
@teemingc
Copy link
Member

teemingc commented Sep 27, 2024

The Vercel documentation mentions v20 as the default.

guessed at build time with the get_default_runtime function

Can you explain further what this means and how you came to this conclusion?

@GauBen
Copy link
Contributor Author

GauBen commented Sep 27, 2024

The runtime is picked here

const runtime = route.config?.runtime ?? defaults?.runtime ?? get_default_runtime();

It may default to node 20 if unspecified, but svelte-kit will always write a value to .vc-config.json

runtime: config.runtime,

@teemingc
Copy link
Member

teemingc commented Sep 28, 2024

Thanks! It's interesting because this means the node version can differ if building on Vercel versus building on the dev's machine then deploying using the CLI. Meanwhile, Vercel seems to use the same version for build and deployment if you link it to your repository.
vercel node version determines build and serverless function runtime
Do you think it's enough that we clarify the default Vercel version is 20 but also add a note about the difference if it's built on a local machine and deployed?

@GauBen
Copy link
Contributor Author

GauBen commented Sep 29, 2024

Do you think it's enough that we clarify the default Vercel version is 20 but also add a note about the difference if it's built on a local machine and deployed?

I guess that would work:

@default Same as the build environment.

- When building your project on Vercel, if this parameter is unset, it will [default to Node 20.x](https://vercel.com/docs/functions/runtimes/node-js/node-js-versions#default-and-available-versions).
- Otherwise, if you intend to build your application yourself with a Node version that is not [supported by Vercel](https://vercel.com/docs/functions/runtimes/node-js/node-js-versions#default-and-available-versions), you must set this parameter.

@teemingc
Copy link
Member

teemingc commented Oct 6, 2024

cc: @dummdidumm any thoughts on this or preferences from Vercel?

* @default Same as the build environment
*/
runtime?: `nodejs${number}.x`;
runtime?: 'nodejs18.x' | 'nodejs20.x';
Copy link
Member

Choose a reason for hiding this comment

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

I'd like to keep this as the type because Vercel may deprecate old versions after some time and/or introduce new ones, and we don't want people to upgrade to newer versions of the adapter just for silencing type errors / don't want to make a major version bump just because we gotta remove a type

Suggested change
runtime?: 'nodejs18.x' | 'nodejs20.x';
runtime?: `nodejs${number}.x`;

@dummdidumm dummdidumm merged commit 7fb1f5c into sveltejs:main Oct 7, 2024
@github-actions github-actions bot mentioned this pull request Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg:adapter-vercel Pertaining to the Vercel adapter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants