fix(deploy): resolve worker bundle path from @cloudflare/vite-plugin dist layout#381
Open
AshishKumar4 wants to merge 1 commit into
Open
fix(deploy): resolve worker bundle path from @cloudflare/vite-plugin dist layout#381AshishKumar4 wants to merge 1 commit into
AshishKumar4 wants to merge 1 commit into
Conversation
…dist layout Deploy to Cloudflare fails with `FileNotFoundError: /workspace/<id>/dist/index.js` because the deploy reads a hardcoded `dist/index.js` while @cloudflare/vite-plugin (pinned ^1.9.4 in templates) emits to `dist/<sanitized-name>/index.js` plus a rewritten wrangler.json. The same file already uses modern `dist/client/` for assets, making the worker path the only inconsistent piece. Resolve both paths from the plugin's own dist/<env>/wrangler.json (canonical source of truth), falling back to the legacy layout for older templates. Adds regression tests covering both layouts and the missing-build error.
|
ProviderModelNotFoundError |
|
@AshishKumar4 Bonk workflow failed. Check the logs for details. View workflow run · To retry, trigger Bonk again. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Deploy to Cloudflare button on generated apps fails with:
Root cause
worker/services/sandbox/sandboxSdkClient.tsreads a hardcoded/workspace/<id>/dist/index.js, but@cloudflare/vite-pluginemits the worker todist/<sanitized-name>/index.jsand writes a rewrittenwrangler.jsonalongside it. The same file already reads static assets from the moderndist/client/layout, so the worker-read path was the inconsistent piece.The hardcoded
dist/index.jshas been present since the initial OSS release. The user-facing regression surfaced when the R2-hosted templates switched to use@cloudflare/vite-plugin, shifting builds from the flatdist/index.jslayout to the plugin's nesteddist/<env>/index.jslayout.Verified against a real generated app (
lumina-the-beautiful-hello-world):dist/lumina_hello_world_zqneqpyztwbhid_y98ifi/index.jsexistsdist/lumina_hello_world_zqneqpyztwbhid_y98ifi/wrangler.jsonexists withmain: "index.js",assets.directory: "../client"dist/client/existsdist/index.js, the path the code tries to read, does not existFix
Resolve both paths from the plugin's own
dist/<env>/wrangler.jsonas the canonical source of truth, falling back to the legacydist/index.js+dist/clientlayout for older templates byte-for-byte.The fix is strictly local to
deployToCloudflareWorkersinworker/services/sandbox/sandboxSdkClient.ts.parseWranglerConfig,buildDeploymentConfig,WranglerConfigtype,deployer.ts,deploy.ts,cloudflare-api.ts,templates.ts, and thebunx wrangler buildstep are untouched.Tests
New unit tests in
worker/services/sandbox/resolveBuildArtifacts.test.tscover:@cloudflare/vite-pluginlayout with../clientassets resolving to siblingdist/client.apiandweb, picking the one matchingconfig.name.wrangler.json, preserving byte-identical legacy strings.Verification
npm run typecheckpassednpm run lintpassednpm run test -- worker/services/sandbox/resolveBuildArtifacts.test.tspassednpm run testpassed: 216 passed / 1 skipped across 10 test files