Dynamic require of "node:querystring" is not supported

Hello, I’m using SvelteKit, SSR mode with Mixpanel as server side analytics. I’ve enabled Edge functions, but now I’m getting an error Error: Dynamic require of "node:querystring" is not supported from the render Edge function. The problem is also mentioned in the SvelteKit’s GitHub: Dynamic import not supported with netlify edge function · Issue #12057 · sveltejs/kit · GitHub. I need to implement analytics for my client and it’s a pretty difficult issue that I don’t know how to workaround at this moment. I’m thinking to ditch the mixpanel package and use fetch API instead for the tracking. I’m using latest v20 Node runtime on Netlify. Assistance welcomed :pray:

Does this work if you remove edge: true?

Yes, it does work with edge disabled.

@hrishikesh Do you have some ideas? I think it’s quite important issue, makes SvelteKit unusable with Edge functions at this moment.

Based on the stacktrace you’ve added in the issue, the problem seems to be mailchimp: mailchimp-marketing-node/src/ApiClient.js at master · mailchimp/mailchimp-marketing-node (github.com)

It’s a library not updated for over 2 years. You should find an alternative for it.

How is this relevant? Dynamic requires of node protocols break edge functions. Plus, I’m not using Mailchimp. This problem probably touches big majority of SvelteKit projects. I think this is related to Netlify Serverless Typescript functions fail with dynamic requires - #13 by fool