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

refactor(next): send IntegrationRouteData to integrations #11864

Merged
merged 16 commits into from
Sep 13, 2024

Conversation

ematipico
Copy link
Member

@ematipico ematipico commented Aug 28, 2024

Changes

Closes PLT-2338

This PR changes the type passed to integrations regarding the routes. RouteData was never meant for external usage, in fact it lacks JSDocs.

This wasn't intentional, and with v5 we plan to fix this. In fact, with the new type IntegrationRouteData, we removed isIndex and fallbackRoutes from being passed to the integrations, because they were never meant to be used by downstream integrations.

With this PR, I took the chance to add some proper documentation, so downstream developers (and us), know what each field is about.

Also, this PR fixes a critical bug. RouteData.distURL needs to be an array, because a route can generate multiple files, and until now we were saving only the last file generated.

This PR changes to be an array, which is marked as a breaking change.

Testing

The existing CI should pass

Docs

Added changesets

withastro/docs#9273

Copy link

changeset-bot bot commented Aug 28, 2024

🦋 Changeset detected

Latest commit: eea2150

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

@ematipico ematipico changed the base branch from main to next August 28, 2024 16:26
@github-actions github-actions bot added pkg: astro Related to the core `astro` package (scope) semver: major Change triggers a `major` release labels Aug 28, 2024
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

This PR is blocked because it contains a major changeset. A reviewer will merge this at the next release if approved.

@github-actions github-actions bot added the pkg: integration Related to any renderer integration (scope) label Aug 29, 2024
@ematipico ematipico marked this pull request as ready for review August 29, 2024 07:42
@ematipico ematipico changed the title Feat/different route data refactor(next): send IntegrationRouteData to integrations Aug 29, 2024
Copy link
Member

@alexanderniebuhr alexanderniebuhr left a comment

Choose a reason for hiding this comment

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

We have moved the adapter to https://github.com/withastro/adapters, so this PR can't be merged here anymore.
I would offer to port over the changes to the new repo for you, just let me know if you want me to do that.

route: string;
/**
* Source component URL
Copy link
Member

Choose a reason for hiding this comment

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

It might be worth documenting what value will be here in case of redirect and fallback routes since this is not optional and yet those types don't necessarily have a component.

Copy link
Member

Choose a reason for hiding this comment

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

@Fryuni what would you propose then?

Copy link
Member

Choose a reason for hiding this comment

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

Since this is for next major I think it would be better to change the name of this field to something like subject and then document what it means for different route types.

  • For page routes, it is the Astro component to be rendered.
  • For endpoint routes, it is the file declaring the method handlers.
  • For redirect routes, it is the target mask of the redirect.
  • For fallback routes, it is the subject of the route used as fallback.

packages/astro/src/types/public/internal.ts Outdated Show resolved Hide resolved
@alexanderniebuhr
Copy link
Member

I ported over the adapter related changes here withastro/adapters#377

@github-actions github-actions bot removed the pkg: integration Related to any renderer integration (scope) label Sep 4, 2024
@florian-lefebvre florian-lefebvre dismissed alexanderniebuhr’s stale review September 11, 2024 12:47

Changes ported to the adapters repo

Copy link
Member

@florian-lefebvre florian-lefebvre left a comment

Choose a reason for hiding this comment

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

We discussed with the rest of team platform and sounds like we want a bigger refactor of this interface, not just a proxy of the internal type

@matthewp
Copy link
Contributor

@florian-lefebvre I don't think we said we shouldn't merge this though. Unless we have a solid idea for such a refactor this is a small improvement.

@florian-lefebvre
Copy link
Member

ah that's not what i understood! Feel free to merge as is then

@bluwy
Copy link
Member

bluwy commented Sep 12, 2024

To clarify a bit, in the last standup I brought up that I hoped the API would shrink down by a lot more (like 3-5 properties only). Designing it as if from scratch, exposing the crucial ones, rather than exposing as much as possible to keep backwards compat for integrations who use them. Because I think routes in its entirety wasn't meant to support those usecases in that way in the first place.

But anyways I don't mind this merging and we can re-iterate again in the beta if we want.

@Fryuni
Copy link
Member

Fryuni commented Sep 12, 2024

IIRC Ema did this on a TBD and most of the fields were being used by official UI framework integrations and adapters. So this just separates the types so they can evolve independently and we can then see whether the features relying on those fields should be implemented differently.

@ematipico
Copy link
Member Author

Yeah, I can confirm that all fields exposed by the new interface are used by integrations and adapters maintained by us.

I believe that's one of those cases where we would like to refactor it, but it's too late now

@florian-lefebvre florian-lefebvre merged commit ee38b3a into next Sep 13, 2024
14 checks passed
@florian-lefebvre florian-lefebvre deleted the feat/different-route-data branch September 13, 2024 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs pr pkg: astro Related to the core `astro` package (scope) semver: major Change triggers a `major` release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants