Skip to content

Cannot mix live content collections and build-time collections #14088

@iwanker-rockruff

Description

@iwanker-rockruff

Astro Info

Astro                    v5.12.0
Node                     v22.13.1
System                   Windows (x64)
Package Manager          pnpm
Output                   server
Adapter                  @astrojs/node
Integrations             none

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

When an Astro project has both live.config.ts and content.config.ts files, astro sync will fail to sync the types with the following error:
Cannot read properties of undefined (reading 'object'), causing both content configs to never load.

Moving the build-time collections to live.config.ts causes Astro to not recognize the build-time collections and tries to handle them in the legacy way. Naturally, moving the runtime ones to content.config.ts results in a different error: (0 , __vite_ssr_import_0__.defineLiveCollection) is not a function, although this is expected.

What's the expected result?

Both files should be processed correctly, and Astro should be able to distinguish and support both collection types.

A possible use case for this is to have a live collection for constantly updating content (products, customer lists) and a regular build-time one for content that doesn't update as often (blog posts), or to have a collection loaded at build-time for development, and another at runtime for production; they needn't even need to be the same name (e.g. "posts", "livePosts"):

---
import { getLiveEntry, getEntry } from "astro:collections";

export const prerender = false;

const { slug } = Astro.params;
const post = import.meta.env.PROD
    ? (await getLiveEntry("livePosts", slug)).entry
    : await getEntry("posts", slug);

if(!post) {
    Astro.redirect("/404");
}

const { Content } = await post.render();
---
<Content />

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-h5vvhwwu?file=src%2Flive.config.ts

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

Labels

- P2: has workaroundAn edge case that only affects very specific usage, but has a trivial workaround (priority)feat: content collectionsRelated to the Content Collections feature (scope)needs triageIssue needs to be triaged

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions