workos / workos-node

Official Node SDK for interacting with the WorkOS API
https://workos.com/docs/sdk/node
MIT License
119 stars 29 forks source link

Library does not work with NextJS 15 RC + Turbopack #1101

Closed f1shy-dev closed 2 months ago

f1shy-dev commented 2 months ago

Trying to use workos-node (from nextjs-authkit) causes these errors:

 ⨯ Error: Cannot find module 'node:http': Unsupported external type Url for commonjs reference
 Error: Cannot find module 'node:crypto': Unsupported external type Url for commonjs reference

I was able to fix it locally by commenting these out these lines from node_modules/@workos-inc/node/lib/index.js

18 // const node_crypto_provider_1 = require("./common/crypto/node-crypto-provider");
21 // const node_client_1 = require("./common/net/node-client");

45        // else {
46        //     return new node_client_1.NodeHttpClient(this.baseURL, opts);
47        // }

55         // else {
56        //     cryptoProvider = new node_crypto_provider_1.NodeCryptoProvider();
57        // }

However, could we please get a proper fix for this? (I would open a PR, however I am not entirely sure what the proper way would be to fix this. Possibly a dynamic import?)

PaulAsjes commented 2 months ago

Thanks for the report, judging by https://github.com/vercel/next.js/pull/66808 it looks like we need to provide a edge-lite export for Next 15 environments.