Skip to content
This repository has been archived by the owner on Feb 10, 2025. It is now read-only.

feat(vercel): single entrypoint #424

Merged
merged 11 commits into from
Oct 25, 2024
Merged

feat(vercel): single entrypoint #424

merged 11 commits into from
Oct 25, 2024

Conversation

ematipico
Copy link
Member

@ematipico ematipico commented Oct 18, 2024

Changes

Closes PLT-2550

This PR refactors the code of the Vercel adapter, and it now exports one single entry point for both static and serverless adapter.

The new code is inside index.ts. The code that differs between the new adapters is conditionally applied using if (buidOutput === "server") all over.

Also, I took the opportunity to make the creation of the config.json a bit more readable with a classic if/else, all those big ternaries were a bit hard to handle.

Testing

The current tests should pass.

I only updated one single test, where Astro was throwing an error for an incorrect configuration.

Docs

withastro/docs#9755

Copy link

changeset-bot bot commented Oct 18, 2024

🦋 Changeset detected

Latest commit: dd0ada5

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

This PR includes changesets to release 19 packages
Name Type
@astrojs/vercel Minor
@test/astro-vercel-basic Patch
@test/astro-vercel-image Patch
@test/vercel-isr Patch
@test/vercel-max-duration Patch
@test/vercel-edge-middleware-with-edge-file Patch
@test/vercel-edge-middleware-without-edge-file Patch
@test/astro-vercel-no-output Patch
@test/astro-vercel-prerendered-error-pages Patch
@test/astro-vercel-redirects-serverless Patch
@test/astro-vercel-redirects Patch
@test/vercel-server-islands Patch
@test/astro-vercel-serverless-prerender Patch
@test/astro-vercel-serverless-with-dynamic-routes Patch
@test/astro-vercel-static-assets Patch
@test/astro-vercel-static Patch
@test/vercel-streaming Patch
@test/astro-vercel-with-web-analytics-enabled-output-as-static Patch
vercel-hosted-astro-project 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

@github-actions github-actions bot added the pkg: vercel Related to Vercel adapter (scope) label Oct 18, 2024
@ematipico ematipico changed the title feat(vercel): deprecate entrypoints feat(vercel): single entrypoint Oct 18, 2024
@florian-lefebvre
Copy link
Member

Does this require changes in astro add?

@ematipico
Copy link
Member Author

Does this require changes in astro add?

Good call. Yes, it will. I will make a PR

Copy link
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

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

Looks good! I was just wondering whether a word like "Replaces" or "combines" might be a be a more user-friendly word re: guiding them towards the changes they'll have to make (e.g. a find/replace)

.changeset/fast-singers-design.md Outdated Show resolved Hide resolved
packages/vercel/src/static/adapter.ts Outdated Show resolved Hide resolved
packages/vercel/src/image/shared.ts Outdated Show resolved Hide resolved
packages/vercel/src/serverless/adapter.ts Outdated Show resolved Hide resolved
@ematipico ematipico force-pushed the feat/vercel-single-export branch from 1ae809f to 16d6883 Compare October 22, 2024 12:05
Copy link
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

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

The change works for me 👍 We can also do type casting since that's easier if you want, but runtime checks also looks good. I noticed the code already had type casting like here:

// Cast is necessary here because Vercel's types are slightly different from ours regarding allowed protocols. Behavior should be the same, however.
remotePatterns: (astroImageConfig.remotePatterns as VercelImageConfig['remotePatterns']) ?? [],

packages/vercel/src/index.ts Outdated Show resolved Hide resolved
packages/vercel/src/index.ts Outdated Show resolved Hide resolved
packages/vercel/src/index.ts Outdated Show resolved Hide resolved
@ematipico ematipico requested a review from bluwy October 24, 2024 07:59
packages/vercel/src/index.ts Outdated Show resolved Hide resolved
@ematipico ematipico requested a review from bluwy October 25, 2024 09:04
packages/vercel/src/index.ts Outdated Show resolved Hide resolved
@ematipico ematipico requested a review from bluwy October 25, 2024 10:43
@ematipico ematipico merged commit 3351348 into next Oct 25, 2024
8 checks passed
@ematipico ematipico deleted the feat/vercel-single-export branch October 25, 2024 12:10
@github-actions github-actions bot mentioned this pull request Oct 25, 2024
@github-actions github-actions bot mentioned this pull request Dec 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pkg: vercel Related to Vercel adapter (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants