I'm currently working on a serverless project where I'm using ESBuild to bundle my JavaScript code for AWS Lambda functions. Everything has been working smoothly so far, but I've run into a situation where I need to load a Node.js module that is not natively supported by ESBuild.
Whenever I run the serverless package command, I encounter the following error:
✘ [ERROR] No loader is configured for ".node" files: node_modules/.pnpm/[email protected]/node_modules/nodejs-polars-darwin-arm64/nodejs-polars.darwin-arm64.node
Specifically, I need to use a Node.js module loader to load a module that contains native bindings with a .node extension. However, ESBuild doesn't seem to support this out of the box, and I'm not sure how to configure it to work with a custom Node.js module loader.
I've read about similar issues with Webpack, where you can use the node-loader package to load Node.js modules, but I'm not sure how to achieve the same result with ESBuild in a serverless environment.
Has anyone successfully configured ESBuild to work with a custom Node.js module loader to resolve .node files in a serverless context? Any guidance or examples would be greatly appreciated. Thanks!