You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
buildEnv: "auto" reads the wrangler config from the working directory, not the Vite root #1037
rango({ preset: "cloudflare", buildEnv: "auto" }) builds its build-time environment from the wrangler config found from the directory vite build is run in, not from the Vite root. Building an app from another working directory gives build-time handlers an env without the app's bindings.
Where
resolveBuildEnv in packages/rangojs-router/src/vite/router-discovery.ts (line 351 on main, eed288b1):
constuserRequire=createRequire(resolve(factoryCtx.root,"package.json"));constwranglerPath=userRequire.resolve("wrangler");const{ getPlatformProxy }=awaitimport(pathToFileURL(wranglerPath).href);constproxy=awaitgetPlatformProxy();// no configPath
Wrangler itself is resolved from the project root. The config is not: getPlatformProxy() without configPath searches from process.cwd().
Observed
vite build tests/cloudflare-basic from the repository root fails in the build-time prerender of /build-env (src/pages/build-env-handler.tsx, await ctx.env.KV.put(...)):
Cannot read properties of undefined (reading 'put')
vite build inside tests/cloudflare-basic passes. Seen while taking the two-working-directory sample for #1034, on that branch and on its base commit (main plus one docs commit). The cause above is read from the code; the failing build was not bisected further.
Expected
The same build from any working directory. Pass configPath resolved against the Vite root (factoryCtx.root); if the Cloudflare Vite plugin is configured with its own configPath, that one is the better source.
Test
A build from a second working directory. #1034 adds one for the node fixture (cache-versions-build.test.ts, vite build app from the parent directory); tests/cloudflare-basic is left out of that PR's two-directory sample because of this bug.
Activity