Skip to content

[vite-plugin] Complete v1 framework builds and imported assets - #16817

Merged
edmundhung merged 2 commits into
codex/vite-v1-header-browser-20261109from
codex/vite-v1-backport-16761
Nov 11, 2026
Merged

edmundhung merged 2 commits into
codex/vite-v1-header-browser-20261109from
codex/vite-v1-backport-16761

Conversation

@petebacondarwin

@petebacondarwin petebacondarwin commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Backport the compatible build fixes from #16761. Framework plugins can build Workers before the Cloudflare post hook and remove Vite manifests, leaving assets missing or causing repeated builds. Complete only the remaining environments, collect imported assets from emitted bundles, move entry/child assets into the client output, and copy prerender assets while preserving their originals.

V1 keeps its builder callback because Vite 6 has no buildApp hook. Vite 7/8 also complete the same work in the post hook, including custom builder callbacks. Wrangler output configuration and removal of the assets field for Workers without client output are preserved. The v2 Build Output Specification implementation is not introduced.

The remaining diff is plugin build/config code, three integration regression cases and a plugin patch changeset. Dependency upgrades remain in #16801 beneath this PR. This PR is part of native GitHub stack #16738; merge the stack in order.

Validation: build, all 58 checks, all 8 package test tasks (265 plugin tests), and all 6 retained fixture tasks pass (30 registry, 5 harness and 2 browser tests). Affected Vite 8 build playgrounds pass: 11 tests, 3 expected skips. Vite 6.4.6 build and applicable playground coverage pass: 3 tests, 2 expected skips for unsupported features. Vite 7.1.12 build and affected playgrounds also pass: 11 tests, 3 expected skips. No credentialed E2E or full OS matrix was run.


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: existing build APIs are preserved and output fixes are described in the plugin changeset.

Note

This is a contribution from an AI agent: Codex.

@changeset-bot

changeset-bot Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1609502

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@cloudflare/vite-plugin Patch

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

@petebacondarwin

Copy link
Copy Markdown
Contributor Author

@jamesopstad (verified author of #16761) and @petebacondarwin (latest qualifying pre-merge human ant-core approver, November 9 13:24:33Z): please check this v1 backport and approve it if it looks good.

V1 retains the builder callback needed by Vite 6 and its Wrangler output configuration. The remaining change completes environments once, collects imported assets from bundles rather than removable manifests, and transfers entry/child/prerender assets into client output while preserving prerender originals. Three plugin integration regression cases pass; build, all 58 checks and all 8 package test tasks pass, including 265 plugin tests. Affected playground and Vite 6 compatibility validation are being finalized. #16801 already supplies the November 10 dependency graph beneath this PR, so no dependency upgrades or upstream dependency tests are repeated here. Added to native GitHub stack #16738; merge the stack in order.

@pkg-pr-new

pkg-pr-new Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
npm i https://pkg.pr.new/@cloudflare/vite-plugin@16817

commit: 1609502

@petebacondarwin
petebacondarwin marked this pull request as ready for review November 10, 2026 14:05
@workers-devprod
workers-devprod requested review from a team and edmundhung and removed request for a team November 10, 2026 14:05
@workers-devprod

workers-devprod commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler

@devin-ai-integration devin-ai-integration 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.

Devin Review found 2 potential issues.

Devin Review

Comment thread .changeset/v1-build-imported-assets.md Resolved

@clanky-the-clanker clanky-the-clanker 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.

Superseded by the review of 1609502d.

This review, of e09da0d2

💬 Approved with comments — The build and asset-transfer logic looks correct and is covered by regression tests. The only findings are two INFO cleanup notes: a leftover unused option and duplicated post-hook logic.

Findings: 2 info (2 are inline comments on the diff)

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


📋 Code Quality: 💬 2 info

Logic looks correct. Two small cleanup items.

Recommendation: 💬 Optional Nits

  • [INFO] isEntryWorker is no longer read but stays in the options type and its callers (packages/vite-plugin-cloudflare/src/cloudflare-environment.ts)
  • [INFO] The post buildApp hook repeats the Worker builds and removeAssetsField that buildApp in build.ts already does (packages/vite-plugin-cloudflare/src/plugins/config.ts:181)
View full review
  • createCloudflareEnvironmentOptions still declares and receives isEntryWorker, but nothing reads it any more.
  • The post buildApp hook calls buildApp(...) first. buildApp already builds the remaining Worker environments and removes the assets field. The hook then repeats both steps. This is harmless because the build calls check isBuilt and removing the field twice changes nothing, but the logic now lives in two places.

✅ All other checks passed

🚀 Release: ✅ LGTM

Risk: low. The plugin patch changeset is present.


🔒 Security: ✅ LGTM

No security concerns in the build and config changes.


📖 AGENTS.md: ✅ LGTM

No AGENTS.md concerns.


⚡ Performance: ✅ LGTM

No performance concerns.


📝 Documentation: ✅ LGTM

The changeset describes the user-facing fixes.


Reviewed commit: e09da0d2

Vite 6 does not set `environment.isBuilt`, so the build still treated the
client as unbuilt right after building it. It then removed the `assets`
field from the entry Worker's output config and skipped moving imported
assets into the client output. Also track the client build done here.

@clanky-the-clanker clanky-the-clanker 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.

💬 Approved with comments — The Vite 6 fix for client build tracking is correct. Only INFO notes remain: the Vite 6 child-environment asset gap, the changeset's no-rebuild wording, and duplicated post-hook logic.

Findings: 3 info (2 are inline comments on the diff)

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


📋 Code Quality: 💬 2 info

Build logic is sound. Two INFO notes: Vite 6 skips child-environment assets, and the post-hook logic is still duplicated.

Recommendation: 💬 Optional Nits

  • [INFO] On Vite 6, child-environment imported assets are never moved, because the filter relies on isBuilt (packages/vite-plugin-cloudflare/src/build.ts:68)
  • [INFO] The post buildApp hook repeats the Worker builds and removeAssetsField logic that buildApp in build.ts already does (packages/vite-plugin-cloudflare/src/plugins/config.ts:181)
View full review
  • Vite 6 child environments (INFO): build.ts:68 keeps a child environment only when childEnvironment.isBuilt is true. Vite 6 never sets that flag, as the comment at build.ts:79 says. Imported assets from child environments are therefore never moved to the client output on Vite 6. The client already gets local tracking (isClientBuilt). One option for children is to treat an environment that has an entry in environmentNameToImportedAssetPaths as built, since writeBundle only runs after a build.
  • Duplicated post-hook logic (INFO): the post buildApp hook in plugins/config.ts calls buildApp(...), then repeats the Worker-build loop and the removeAssetsField branch. This is harmless because builds check isBuilt and removing the field twice changes nothing, but the same logic now lives in two places.

📝 Documentation: 💬 1 info

The changeset's no-rebuild claim doesn't hold on Vite 6.

Recommendation: 💬 Optional Nits

  • [INFO] The changeset's "without rebuilding environments" claim doesn't hold on Vite 6 (.changeset/v1-build-imported-assets.md:5)
View full review
  • The changeset says builds complete "without rebuilding environments". build.ts:45 skips a Worker build only when isBuilt is set, and Vite 6 never sets it, so on Vite 6 a Worker that a framework already built can be built again.

✅ All other checks passed

🚀 Release: ✅ LGTM

Risk: Low. The plugin patch changeset is present.


🔒 Security: ✅ LGTM

The source and destination paths for moved or copied assets come from the build's own bundle metadata (viteMetadata.importedAssets), not from untrusted input. The change adds no secrets, authentication changes or network exposure.


📖 AGENTS.md: ✅ LGTM

No concerns.


⚡ Performance: ✅ LGTM

No performance concerns.


Reviewed commit: 1609502d

Comment thread .changeset/v1-build-imported-assets.md Resolved

@workers-devprod workers-devprod 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.

Codeowners reviews satisfied

@edmundhung
edmundhung merged commit cdde2c8 into vite-plugin-v1 Nov 11, 2026
28 checks passed
@edmundhung
edmundhung deleted the codex/vite-v1-backport-16761 branch November 11, 2026 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants