mailersend / mailersend-nodejs

The official MailerSend Node.js SDK
https://developers.mailersend.com
MIT License
125 stars 17 forks source link

Does not work on the Edge [Cloudflare Pages] #65

Closed marchellodev closed 1 year ago

marchellodev commented 1 year ago

Hello, after using this library in the project that is deployed to Cloudflare Pages, I get the following error during the build:

15:35:13.859 | > Using @sveltejs/adapter-cloudflare
-- | --
15:35:14.014 | ✘ [ERROR] Could not resolve "https"
15:35:14.015 |  
15:35:14.015 | node_modules/gaxios/build/src/gaxios.js:20:24:
15:35:14.015 | 20 │ const https_1 = require("https");
15:35:14.015 | ╵                         ~~~~~~~
15:35:14.015 |  
15:35:14.015 | The package "https" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
15:35:14.016 |  
15:35:14.019 | ✘ [ERROR] Could not resolve "querystring"
15:35:14.020 |  
15:35:14.020 | node_modules/gaxios/build/src/gaxios.js:22:46:
15:35:14.020 | 22 │ const querystring_1 = __importDefault(require("querystring"));
15:35:14.020 | ╵                                               ~~~~~~~~~~~~~
15:35:14.020 |  
15:35:14.021 | The package "querystring" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
15:35:14.021 |  
15:35:14.025 | ✘ [ERROR] Could not resolve "url"
15:35:14.026 |  
15:35:14.026 | node_modules/gaxios/build/src/gaxios.js:24:22:
15:35:14.026 | 24 │ const url_1 = require("url");
15:35:14.026 | ╵                       ~~~~~
15:35:14.026 |  
15:35:14.026 | The package "url" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
15:35:14.027 |  
15:35:14.031 | ✘ [ERROR] Could not resolve "net"
15:35:14.031 |  
15:35:14.031 | node_modules/https-proxy-agent/dist/agent.js:15:38:
15:35:14.031 | 15 │ const net_1 = __importDefault(require("net"));
15:35:14.031 | ╵                                       ~~~~~
15:35:14.032 |  
15:35:14.032 | The package "net" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
15:35:14.032 |  
15:35:14.033 | ✘ [ERROR] Could not resolve "tls"
15:35:14.033 |  
15:35:14.033 | node_modules/https-proxy-agent/dist/agent.js:16:38:
15:35:14.033 | 16 │ const tls_1 = __importDefault(require("tls"));
15:35:14.033 | ╵                                       ~~~~~
15:35:14.033 |  
15:35:14.034 | The package "tls" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
15:35:14.034 |  
15:35:14.034 | ✘ [ERROR] Could not resolve "url"
15:35:14.034 |  
15:35:14.034 | node_modules/https-proxy-agent/dist/agent.js:17:38:
15:35:14.034 | 17 │ const url_1 = __importDefault(require("url"));
15:35:14.034 | ╵                                       ~~~~~
15:35:14.034 |  
15:35:14.034 | The package "url" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
15:35:14.035 |  
15:35:14.035 | ✘ [ERROR] Could not resolve "assert"
15:35:14.035 |  
15:35:14.035 | node_modules/https-proxy-agent/dist/agent.js:18:41:
15:35:14.035 | 18 │ const assert_1 = __importDefault(require("assert"));
15:35:14.035 | ╵                                          ~~~~~~~~
15:35:14.035 |  
15:35:14.035 | The package "assert" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
15:35:14.036 |  
15:35:14.036 | ✘ [ERROR] Could not resolve "events"
15:35:14.036 |  
15:35:14.036 | node_modules/agent-base/dist/src/index.js:5:25:
15:35:14.036 | 5 │ const events_1 = require("events");
15:35:14.036 | ╵                          ~~~~~~~~
15:35:14.036 |  
15:35:14.037 | The package "events" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
15:35:14.037 |  
15:35:14.047 | error during build:
15:35:14.048 | Error: Build failed with 8 errors:
15:35:14.048 | node_modules/agent-base/dist/src/index.js:5:25: ERROR: Could not resolve "events"
15:35:14.048 | node_modules/gaxios/build/src/gaxios.js:20:24: ERROR: Could not resolve "https"
15:35:14.048 | node_modules/gaxios/build/src/gaxios.js:22:46: ERROR: Could not resolve "querystring"
15:35:14.048 | node_modules/gaxios/build/src/gaxios.js:24:22: ERROR: Could not resolve "url"
15:35:14.048 | node_modules/https-proxy-agent/dist/agent.js:15:38: ERROR: Could not resolve "net"
15:35:14.048 | ...
15:35:14.048 | at failureErrorWithLog (/opt/buildhome/repo/node_modules/esbuild/lib/main.js:1604:15)
15:35:14.049 | at /opt/buildhome/repo/node_modules/esbuild/lib/main.js:1056:28
15:35:14.049 | at /opt/buildhome/repo/node_modules/esbuild/lib/main.js:1001:67
15:35:14.049 | at buildResponseToResult (/opt/buildhome/repo/node_modules/esbuild/lib/main.js:1054:7)
15:35:14.049 | at /opt/buildhome/repo/node_modules/esbuild/lib/main.js:1166:14
15:35:14.049 | at responseCallbacks.<computed> (/opt/buildhome/repo/node_modules/esbuild/lib/main.js:701:9)
15:35:14.049 | at handleIncomingPacket (/opt/buildhome/repo/node_modules/esbuild/lib/main.js:756:9)
15:35:14.049 | at Socket.readFromStdout (/opt/buildhome/repo/node_modules/esbuild/lib/main.js:677:7)
15:35:14.049 | at Socket.emit (node:events:513:28)
15:35:14.049 | at addChunk (node:internal/streams/readable:315:12)
15:35:14.077 | Failed: build command exited with code: 1
15:35:15.012 | Failed: an internal error occurred
fosron commented 1 year ago

Hey, we do not officially support Cloudflare Pages Workers, you need to consult their support and figure out the missing packages that are required.