besscroft opened a new issue, #6237: URL: https://github.com/apache/opendal/issues/6237
### Describe the bug I'm encountering issues using Opendal in Next.js after importing it.  bindings-nodejs is a CommonJS project and needs to be adapted before it can be used in ES Module. Or change the way use it. ### Steps to Reproduce - code example ```ts import 'server-only' import { Operator } from 'opendal' let s3Operator: Operator | null = null export async function getS3Operator(findConfig: Config[]) { if (!findConfig.length) { console.warn('s3 init error') } if (s3Operator) return s3Operator s3Operator = new Operator('s3', { bucket: bucket, region: region, endpoint: endpoint, access_key_id: accesskeyId, secret_access_key: accesskeySecret, }) return s3Operator } ``` ### Expected Behavior It should work fine. I was able to get it to work properly with `next dev --turbopack` after modifying some of the source code. I'm not sure if it complies with the spec, and there are some other issues that may be worth discussing. ### Additional Context Two questions: - Nextjs seems to parse the package incorrectly, causing esm to be unable to load dependencies normally. - Regarding the opendal.xxx.node file, nextjs itself is not adapted and needs to be configured in next.config. [serverExternalPackages](https://nextjs.org/docs/app/api-reference/config/next-config-js/serverExternalPackages) > I would like to add the separate configuration required for nextjs to use opendal in the document to facilitate other people's use. ### Are you willing to submit a PR to fix this bug? - [x] Yes, I would like to submit a PR. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
