Skip to content

fix(build): Introduce build pass to accomodate plugins with build-time code generation#846

Merged
justinvdm merged 11 commits intomainfrom
content-collections-delete-bug
Oct 28, 2025
Merged

fix(build): Introduce build pass to accomodate plugins with build-time code generation#846
justinvdm merged 11 commits intomainfrom
content-collections-delete-bug

Conversation

@justinvdm
Copy link
Copy Markdown
Collaborator

Problem

Vite plugins that generate code at build time, such as Content Collections, typically use the buildStart hook to perform their work. The framework's directive scan, which is necessary to configure the main build, was running before this hook. This created a lifecycle mismatch: the directive scan attempts to resolve modules that are generated by these plugins. Because the scan ran before the plugins' buildStart hooks, the generated files had not been created yet. This causes the build to fail with a module resolution error, such as ERROR: Cannot read file ".content-collections/generated": is a directory.

Solution

This change introduces a "plugin setup pass" - a minimal, no-op Vite build that runs before the directive scan.

This pass is configured to be inert: it uses a temporary, empty file as an entry point and is set not to write any output. Its sole purpose is to trigger the buildStart hook for all configured plugins, ensuring that any necessary code generation is complete before the directive scan begins.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying redwood-sdk-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: a907e1a
Status: ✅  Deploy successful!
Preview URL: https://9caa2163.redwood-sdk-docs.pages.dev
Branch Preview URL: https://content-collections-delete-b.redwood-sdk-docs.pages.dev

View logs

@justinvdm justinvdm closed this Oct 28, 2025
@justinvdm justinvdm reopened this Oct 28, 2025
@justinvdm justinvdm merged commit e942d02 into main Oct 28, 2025
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant