feat(vercel): allow defining ISR exclusions with regular expressions #13211
+51
−22
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
There are 2 main changes in this PR:
_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: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 generatedvercel/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