Resolve content collection images without cloning entry data - #17631
Resolve content collection images without cloning entry data#17631matthewp wants to merge 2 commits into
Conversation
Record image field locations when an entry is stored, so read-time resolution rewrites only those fields instead of deep-cloning the whole entry. Values elsewhere are passed through by reference, so a schema transform returning a Temporal.PlainDate or other class instance no longer throws DataCloneError.
🦋 Changeset detectedLatest commit: 01230cd The changes in this PR will be included in the next version bump. This PR includes changesets to release 417 packages
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 |
|
This is a much cleaner direction than making the clone smarter like #17596 did — recording the image field paths at write time (where the data is already being traversed anyway) and doing a copy-on-write only along those paths means Astro never has to take a position on what types user data may contain. Happy for this to supersede my PR. Two things I noticed while reading the diff, mostly as questions:
Thanks for picking this up so quickly! |
Changes
Temporal.PlainDateor other class instance no longer throwsDataCloneErrorfromgetCollection()/getEntry().structuredCloneusage, so any types supported bydevalue()should work.Testing
image-references.test.ts: reworked, removed old testsmutable-data-store.test.ts: asserts image prefixes are stripped to plain srcs and their paths recorded asimageImports, and that entries without images record nothing.Docs
Alternative to #17596.
Closes #17589