Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatibility with Next.js Edge API runtime using edge-light condition #238

Closed
pajecawav opened this issue May 7, 2023 · 1 comment · Fixed by #246
Closed

Incompatibility with Next.js Edge API runtime using edge-light condition #238

pajecawav opened this issue May 7, 2023 · 1 comment · Fixed by #246

Comments

@pajecawav
Copy link

Environment

ofetch: v1.0.1
next: from v13.1.7-canary.17 to v13.4.1
node: v18.15.0

Reproduction

https://github.com/pajecawav/next-ofetch-edge-api-route

To reproduce:

git clone https://github.com/pajecawav/next-ofetch-edge-api-route
cd next-ofetch-edge-api-route
pnpm install
pnpm build

Describe the bug

Starting from [email protected] I can't use ofetch inside an Edge API route because build fails with an error "Module build failed: UnhandledSchemeError: Reading from "node:buffer" is not handled by plugins (Unhandled scheme).".

After some digging I figured out that most likely changes in this PR caused the issue.

I managed to get it working by removing "node" section from "exports" field in the package.json of ofetch:

diff --git a/package.json b/package.json
index f182539..a921c1b 100644
--- a/package.json
+++ b/package.json
@@ -8,11 +8,6 @@
   "type": "module",
   "exports": {
     ".": {
-      "node": {
-        "types": "./dist/node.d.ts",
-        "import": "./dist/node.mjs",
-        "require": "./dist/node.cjs"
-      },
       "default": {
         "types": "./dist/index.d.ts",
         "import": "./dist/index.mjs",

Adding "edge-light" also seems to fix the issue:

diff --git a/package.json b/package.json
index f182539..cbafb2c 100644
--- a/package.json
+++ b/package.json
@@ -8,6 +8,11 @@
   "type": "module",
   "exports": {
     ".": {
+      "edge-light": {
+        "types": "./dist/index.d.ts",
+        "import": "./dist/index.mjs",
+        "require": "./dist/index.cjs"
+      },
       "node": {
         "types": "./dist/node.d.ts",
         "import": "./dist/node.mjs",

Additional context

No response

Logs

No response

@pajecawav pajecawav changed the title Incompability with Next.js Edge API runtime Iincompatibility with Next.js Edge API runtime May 7, 2023
@pajecawav pajecawav changed the title Iincompatibility with Next.js Edge API runtime Incompatibility with Next.js Edge API runtime May 7, 2023
@pi0
Copy link
Member

pi0 commented May 8, 2023

Thanks for reporting this. Let me do some more research how reliable is this new condition. FYI we had been thinking to introduce similar condition for Nitro/Nuxt (unjs/nitro#1123)

@pi0 pi0 changed the title Incompatibility with Next.js Edge API runtime Incompatibility with Next.js Edge API runtime using edge-light condition May 8, 2023
pajecawav added a commit to pajecawav/ghloc-web that referenced this issue May 20, 2023
@pi0 pi0 closed this as completed in #246 Jun 6, 2023
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 a pull request may close this issue.

2 participants