next.js
15bb8ce5 - fix: force module format for virtual client-proxy file (#74162)

Commit
1 year ago
fix: force module format for virtual client-proxy file (#74162) Fixes #74062 (`jotai` ran into this error [when they added `"type": "commonjs"` to their package.json](https://github.com/pmndrs/jotai/discussions/2579#discussioncomment-9812492)) > this is a bug in the transform we do when a `'use client'` directive is encountered. I think what's happening is that we're creating a virtual file that uses ESM import/export syntax, but it's called proxy.js (not proxy.mjs), so the `"type": "commonjs" `makes turbopack "correctly" upset at the ESM syntax. https://github.com/vercel/next.js/issues/74062#issuecomment-2555922867 The (slightly kludgy) solution is to use `proxy.mjs` or `proxy.cjs` to force the module format, bypassing the issue where `proxy.js` changes meaning depending on `package.json#type`.
Author
Parents
Loading