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: allow dynamic route segments in isr.exclude array #10513

Merged
merged 5 commits into from
Mar 28, 2024

Conversation

tk04
Copy link
Contributor

@tk04 tk04 commented Mar 21, 2024

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

Copy link

changeset-bot bot commented Mar 21, 2024

🦋 Changeset detected

Latest 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

@github-actions github-actions bot added the pkg: integration Related to any renderer integration (scope) label Mar 21, 2024
Copy link
Contributor

@lilnasy lilnasy left a 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.

packages/integrations/vercel/test/isr.test.js Outdated Show resolved Hide resolved
Copy link
Contributor

@lilnasy lilnasy left a 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) {
Copy link
Member

@ematipico ematipico Mar 28, 2024

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)

Copy link
Contributor Author

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.

@matthewp
Copy link
Contributor

If we're adding a new feature that we're going to have to support going forward I want it to be tested.

Copy link
Member

@ematipico ematipico left a 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 :)

@lilnasy lilnasy merged commit a573cc1 into withastro:main Mar 28, 2024
4 checks passed
@astrobot-houston astrobot-houston mentioned this pull request Mar 28, 2024
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.

4 participants