Commit edf22de
fix(build): patch payload loadEnv for OpenNext's @next/env shim
OpenNext worker bundling (esbuild) failed with:
No matching export in shims/env.js for import "default" (payload/dist/bin/loadEnv.js)
loadEnv does `import x from '@next/env'` (a default import — correct for the real
CJS package), but OpenNext replaces @next/env with an ESM shim exposing only a
named `loadEnvConfig` (no default). loadEnv is pulled into the worker bundle via
payload/node yet never runs at worker runtime. pnpm-patch it to a namespace import
with a default fallback (`nextEnvImport.loadEnvConfig ?? nextEnvImport.default?.
loadEnvConfig`), which resolves against both the ESM shim and the real CJS package.
With this, the full `opennextjs-cloudflare build` completes locally against the real
D1/R2 (remote bindings) — .open-next/worker.js saved. Remove this patch once the
Payload/OpenNext @next/env interop is fixed upstream.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 0aa4cc6 commit edf22de
3 files changed
Lines changed: 103 additions & 82 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
172 | 175 | | |
173 | 176 | | |
174 | 177 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
0 commit comments