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

feat(vercel): allow defining ISR exclusions with regular expressions #13211

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

slawekkolodziej
Copy link
Contributor

@slawekkolodziej slawekkolodziej commented Feb 10, 2025

Changes

There are 2 main changes in this PR:

  1. It is now possible to define ISR exclusions as regular expressions.
  2. Routes excluded from ISR do not get _isr route entry in .vercel/output/config.json.

Longer answer with my reasoning:

I am using Astro at www.superside.com and our website has many different API routes. I found it quite inconvenient to add every single one of them to the isr.exclude list manually. I prefer to have this in my astro.config.mjs instead:

isr: {
  exclude: [/^\/api/]
}

We've been using this change via patched node module on production for quite some time without any issue. However, this complicates the process of upgrading Astro for us. Ideally I would love to see this change merged into the source code.

As for the second change: as I was working on a way to make isr.exclude accept regular expressions, I noticed that generated vercel/output/config.json file has a lot of unnecessary entries in it (our website has a many excluded api routes). This change helped me investigate Vercel build outputs.

Testing

I adjusted existing tests to handle new use cases.

Docs

/cc @withastro/maintainers-docs for feedback!

If you accept this PR it would be necessary to mention support for regular expressions support in this section of the docs:
https://docs.astro.build/en/guides/integrations-guide/vercel/#excluding-paths-from-caching

Copy link

changeset-bot bot commented Feb 10, 2025

🦋 Changeset detected

Latest commit: 770ec13

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

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: integration Related to any renderer integration (scope) label Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: integration Related to any renderer integration (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant