-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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: allow dynamic route segments in isr.exclude array #10513
feat: allow dynamic route segments in isr.exclude array #10513
Conversation
🦋 Changeset detectedLatest commit: 4ad07a0 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great. Incredible work putting this together!
I was hoping the code for creating segments in core would be more modular, but oh well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me! Thanks for the clean implementation (especially all things considered 😅) .
// eslint-disable-next-line regexp/no-super-linear-backtracking | ||
const ROUTE_DYNAMIC_SPLIT = /\[(.+?\(.+?\)|.+?)\]/; | ||
const ROUTE_SPREAD = /^\.{3}.+$/; | ||
function getParts(part: string, file: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've seen this very function used in the Cloudflare adapter too. Maybe we should consider exposing it (not in this PR)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right, it would make sense to expose it in the core package. Maybe also the code for parsing the segments:
const segments = removeLeadingForwardSlash(content)
.split(nodePath.posix.sep)
.filter(Boolean)
.map((s: string) => {
return getParts(s, content);
});
I've seen it used many times in the core package and the Cloudflare adapter.
If we're adding a new feature that we're going to have to support going forward I want it to be tested. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blocking the PR because it requires to update the documentation: https://docs.astro.build/en/guides/integrations-guide/vercel/#isr
@tk04 you'll have to raise a PR in the docs repository too :)
Changes
Adds support for dynamic route segments in the isr.exclude array. See #10492
Testing
Manually tested: the implementation transforms the route segments similar to how redirects are transformed.
Docs
N/A