Cannot using cloudflare worker socket or any other cloudflare package likes cloudflare:xxx in cloudflare_module preset.
I wonder if this is a bug or just an unimplement feature?
Additional context
I try to add this to nuxt.config.ts, but it doesn't work:
run nuxt dev:
WARN "cloudflare:sockets" is imported by "server/api/email/send.post.ts", but could not be resolved – treating it as an external dependency. 7:42:32 PM
✔ Nuxt Nitro server built in 646 ms nitro 7:42:32 PM
ℹ Vite client warmed up in 1ms 7:42:32 PM
ℹ Vite server warmed up in 20ms 7:42:32 PM
[7:42:33 PM] ERROR [worker reload] [worker init] Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. Received protocol 'cloudflare:'
at throwIfUnsupportedURLScheme (node:internal/modules/esm/load:239:11)
at defaultLoad (node:internal/modules/esm/load:130:3)
at ModuleLoader.load (node:internal/modules/esm/loader:396:13)
at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:278:56)
at new ModuleJob (node:internal/modules/esm/module_job:67:26)
at #createModuleJob (node:internal/modules/esm/loader:290:17)
at ModuleLoader.getJobFromResolveResult (node:internal/modules/esm/loader:247:34)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:228:17)
at async ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:87:21)
run nuxt build:
[nitro 7:43:50 PM] ERROR Error: Cannot resolve "cloudflare:sockets" from "/Users/zougengyu/Projects/supa-email/supa-email/server/api/email/send.post.ts" and externals are not allowed!
undefined
[7:43:50 PM] ERROR Cannot resolve "cloudflare:sockets" from "/Users/xxx/Projects/supa-email/supa-email/server/api/email/send.post.ts" and externals are not allowed!
at Object.resolveId (node_modules/.pnpm/nitro-nightly@3.0.0-beta-28665895.e727afda_typescript@5.5.3/node_modules/nitro-nightly/dist/rollup/index.mjs:1570:17)
at async PluginDriver.hookFirstAndGetPlugin (node_modules/.pnpm/rollup@4.18.1/node_modules/rollup/dist/es/shared/node-entry.js:19643:28)
at async resolveId (node_modules/.pnpm/rollup@4.18.1/node_modules/rollup/dist/es/shared/node-entry.js:18324:26)
at async ModuleLoader.resolveId (node_modules/.pnpm/rollup@4.18.1/node_modules/rollup/dist/es/shared/node-entry.js:18727:15)
at async Object.resolveId (node_modules/.pnpm/@rollup+plugin-commonjs@26.0.1_rollup@4.18.1/node_modules/@rollup/plugin-commonjs/dist/es/index.js:590:10)
at async PluginDriver.hookFirstAndGetPlugin (node_modules/.pnpm/rollup@4.18.1/node_modules/rollup/dist/es/shared/node-entry.js:19643:28)
at async resolveId (node_modules/.pnpm/rollup@4.18.1/node_modules/rollup/dist/es/shared/node-entry.js:18324:26)
at async ModuleLoader.resolveId (node_modules/.pnpm/rollup@4.18.1/node_modules/rollup/dist/es/shared/node-entry.js:18727:15)
at async node_modules/.pnpm/rollup@4.18.1/node_modules/rollup/dist/es/shared/node-entry.js:19031:50
[7:43:50 PM] ERROR Cannot resolve "cloudflare:sockets" from "/Users/xx/Projects/supa-email/supa-email/server/api/email/send.post.ts" and externals are not allowed!
Some names seem to be recognized as URLs sometimes, but they are actually often file or hook names.
It seems like there needs to be a procedure to check if it is a real library or a file or hook name.
Some names seem to be recognized as URLs sometimes, but they are actually often file or hook names. It seems like there needs to be a procedure to check if it is a real library or a file or hook name.
Environment
nodejs: 18 nighly build nuxt & nitro (same issue with nuxt 3.12, nitro 2.9)
Reproduction
import cloudflare socket in any eventHandler files in /server/api/xxx
You are going to get a errors when you run
nuxt build
ornuxt dev
Describe the bug
Cannot using cloudflare worker socket or any other cloudflare package likes
cloudflare:xxx
in cloudflare_module preset. I wonder if this is a bug or just an unimplement feature?Additional context
I try to add this to nuxt.config.ts, but it doesn't work:
Logs
run nuxt build: