Allow live collections in the content config, behind an experimental flag by ematipico · Pull Request #18359 · withastro/astro · GitHub
Skip to content

Allow live collections in the content config, behind an experimental flag - #18359

Draft
ematipico wants to merge 1 commit into
mainfrom
feat/joined-apis
Draft

ematipico wants to merge 1 commit into
mainfrom
feat/joined-apis

Conversation

@ematipico

@ematipico ematipico commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Changes

  • Adds experimental.liveContentEntrypoints. With it, live collections can be declared in src/content.config.ts next to build-time collections, as defineCollection({ type: 'live', entrypoint: './src/live/products.ts' }). The entrypoint default-exports defineLiveCollection({ loader, schema }), one live collection per module, so src/live.config.ts isn't needed. It keeps working alongside entrypoints.
  • The content config stays sync-only and is never bundled. The astro:content runtime gets a map of lazy import()s of the entrypoints, so the server bundle contains only the live modules and their imports, not build-time loaders. Entrypoints load on first use, which lets them import astro:content without the live.config.ts redirect.
  • Sync throws LiveContentConfigError when the flag is off or an entrypoint doesn't exist. Types are generated from each entrypoint's default export into LiveContentConfig, merged with live.config.ts, and live collections are left out of DataEntryMap.
  • Without the flag, the generated astro:content module and the types are unchanged.

Testing

  • live-loaders.test.ts runs its existing dev and SSR assertions against a new live-loaders-entrypoints fixture, unchanged. It also checks that the server chunks include the entrypoint but not the glob loader or the content config, and that the build fails without the flag.
  • New unit tests (units/content-layer/live-entrypoints.test.ts) cover defineCollection() validation, defineLiveCollection() in entrypoints, and lazy loading in getLiveCollection()/getLiveEntry(), including an entrypoint that doesn't export a live collection.
  • New type tests (types/define-collection-entrypoint.ts) cover the defineCollection() overload.

Docs

  • The flag is documented in its @docs entry in types/public/config.ts, which generates the configuration reference. Content collection guides can be updated when the flag is stable.

/cc @withastro/maintainers-docs for feedback!

@changeset-bot

changeset-bot Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

@github-actions github-actions Bot added the pkg: astro Related to the core `astro` package (scope) label Oct 13, 2026
@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

e18e dependency analysis

No dependency warnings found.

@codspeed

codspeed Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

@ematipico ematipico reopened this Oct 23, 2026
@ematipico ematipico changed the title refactor: join types Allow live collections in the content config, behind an experimental flag Oct 23, 2026
@github-actions github-actions Bot added docs pr semver: minor Change triggers a `minor` release and removed semver: minor Change triggers a `minor` release labels Oct 23, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

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 minor changeset. A reviewer will merge this at the next release if approved.

This branch has not been deployed

No deployments
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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant