unjs / nitro

Next Generation Server Toolkit. Create web servers with everything you need and deploy them wherever you prefer.
https://nitro.unjs.io
MIT License
5.89k stars 496 forks source link

fix: fix types for `cloudflare:queue` args #2626

Open dalbodeule opened 2 months ago

dalbodeule commented 2 months ago

๐Ÿ”— Linked issue

โ“ Type of change

๐Ÿ“š Description

The queue event(MessageBatch) is wrong types. What was originally supposed to be MessageBatch, I looked it up today and found that it was written as CloudflareEmailContext. I just fixed it.

๐Ÿ“ Checklist

https://github.com/unjs/nitro/issues/2587#issuecomment-2240766921

dalbodeule commented 2 months ago

additional fix: types for cloudflare:queue args

CloudflareEmailContext.raw to ReadableStream\<Uint8Array> from ReadableStream

dalbodeule commented 2 months ago

I have something additional to ask.

Testing with Nuxt nightly. The error occurs during the build process.

 ERROR  Cannot resolve "cloudflare:email" from "/Users/jioo0224/Desktop/nodejs/sh0rt-kr-email-worker/node_modules/cloudflare-email-kit/dist/index.js" and externals are not allowed!                                                 10:49:18 AM

  at Object.resolveId (node_modules/nitro/dist/rollup/index.mjs:1570:17)
  at async PluginDriver.hookFirstAndGetPlugin (node_modules/rollup/dist/es/shared/node-entry.js:19708:28)
  at async resolveId (node_modules/rollup/dist/es/shared/node-entry.js:18389:26)
  at async ModuleLoader.resolveId (node_modules/rollup/dist/es/shared/node-entry.js:18792:15)
  at async Object.resolveId (node_modules/@rollup/plugin-commonjs/dist/es/index.js:590:10)
  at async PluginDriver.hookFirstAndGetPlugin (node_modules/rollup/dist/es/shared/node-entry.js:19708:28)
  at async resolveId (node_modules/rollup/dist/es/shared/node-entry.js:18389:26)
  at async ModuleLoader.resolveId (node_modules/rollup/dist/es/shared/node-entry.js:18792:15)
  at async ModuleLoader.resolveDynamicImport (node_modules/rollup/dist/es/shared/node-entry.js:19196:82)
  at async node_modules/rollup/dist/es/shared/node-entry.js:19083:32

I would like to ask whether this is also a problem with Nitro and, if so, where I should fix it.

dalbodeule commented 2 months ago

I don't know think so.

Maybe this rule or "cloudflare-email-kit" plugin is fault.

Before, "cloudflare-email-kit" module's dependency is all of "browser" dependencies. So, I think that rules is problem...

ADD:

I added this rule. So, It works. (??)

        if (
          id.startsWith("cloudflare:")
        ) {
          return { id, external: true };
        }