-
-
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
fix(page-data): add key to allPages #10625
Conversation
🦋 Changeset detectedLatest commit: 27395f4 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 |
Okay @Fryuni @Princesseuh , the good news is: I fixed the key problem in The bad news is: it didn't solve my problem. So I guess the problem runs deeper... 🕵🏻♂️ |
Current suspect : |
On an unrelated (but kind of related) note: |
There is still a |
Still a lot of work to get rid of the "getting all pages by their component" logic everywhere. But I'm still thinking : should this use a key (like the PR mentioned above), or should this use path ? (Could be more useful + two routes can't have the same path). |
Struggling to understand |
It is used for the rendering pipeline once it knows which routes should be rendered during the build, it needs to know from which file to import the renderer that needs to run.
|
The value from A "Route", conceptually in Astro, can be either:
When it comes from the filesystem or from an integration, the "component" is the entrypoint defining the route. It may be called When it is a redirect, the "component" really is a path. It is the target of the redirect. That being confusing is great feedback, thank you! We have been talking recently exactly about where things could be confusing for new contributors. |
Great example of some of the more complicated internals and how they sort of just grew and never got a proper refactor / rethinking. We're unlikely to do that, but renaming properties to make them make more sense, and adding inline documentation to explain what they are for, is something that could be done more easily. |
@Fryuni Thanks a lot for the first review. This week I have a lot of work, that's why I didn't continue this PR, but I'll come back to it soon. For the key I'm wondering : I've choose this key pattern because it's the same one as @ematipico in #10248 . But if we want to do something different, maybe we could just use the path ( Or maybe we shouldn't use a Record here ? And I should change that to a Set or an Array ? But I'm afraid this will break even more things. |
@matthewp I won't do any refactor/ rethinking since I'm not in the Astro team and I would like this to be a minor fix. But I'll simplify some over-engineered parts (I already deleted some generators), add documentation, and change some naming. Here is my course of action:
|
It is. Two integrations can define the same dynamic route, like |
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.
Looking GREAT to me!
I left just a naming suggestion that I think would improve clarity; I got a bit confused about what it really meant for a file to be in that set.
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.
Awesome work! The logic all looks good to me.
426c795
to
846dd6f
Compare
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.
Just reviewing for docs, and have some tiny language edits for the changeset!
Co-authored-by: Sarah Rainsberger <[email protected]>
Thanks @sarah11918 ! BTW, I just remembered that @ematipico suggested adding a usage example in the docs (See in the issue -> #10622 (comment) ). Is this still relevant? Should I take care of this, and what should I have in my doc PR? |
Hi @goulvenclech ! I checked out the docs in question, and I think we only need a docs PR if something in that section/instruction now works differently. As you wrote in your issue, this may simply have been an unexpected limitation, and people just assumed it would have already worked this way. I will also tag in @Fryuni since he understands the underlying feature better than I do! 😄 Is anything on the Integrations API reference page now incorrect or misleading as a result of your feature? |
Not incorrect nor misleading, the doc didn't talk about since it wasn't decided (different behavior between dev and prod). I think there are two options:
Your call 🙂 both suit me, and I can quickly do the PR doc. |
Co-authored-by: Sarah Rainsberger <[email protected]>
@sarah11918 Just commited your changeset. Noted for "when building an Astro integration" as an use case, makes sense. And noted for "marginal use case so no doc for now", I think this is the expected behavior anyway. Thanks for your time 🙂 |
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.
Approving on behalf of docs! Thank you @goulvenclech ! 🙌
Current changes
As now :
Fixes #10622 , by changing the logic of "getting all pages by their component" by "getting all pages by a key" in the build part. Inspired by how the PR #10248 implemented the same solution in the route caching part. Also, remove a bunch of generators (verbose and inneficients).
Since this doesn't change anything in the public API, I guess it's a
patch
? But because I did deep changes in the build process, I'll understand if you prefer this to be aminor
. I leave that to reviewers 🙂For Astro 5 :
internals
has a new functiongetPageDatasWithPublicKey()
. It only exist to avoid breaking change in the integration API, but maybe we should remove it at the next major update?Testing
@Fryuni provided me with an integration test, see
packages/astro/test/reuse-injected-entrypoint.test.js
. I don't plan to change the tests apart from that one.Docs
Should this be documented? I feel like this is just the expected behaviour.