Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

esbuild fails with - No loader is configured for ".node" files #131

Closed
mattrochon opened this issue Mar 13, 2024 · 9 comments
Closed

esbuild fails with - No loader is configured for ".node" files #131

mattrochon opened this issue Mar 13, 2024 · 9 comments

Comments

@mattrochon
Copy link

Trying to build my project with esbuild, index.js throws errors for all of the binary targets.

image

@stefan-gorules
Copy link
Contributor

Hi @mattrochon,

To resolve the above issue you would need to use .node loader. See: evanw/esbuild#1051. Let me know if this helps.

@mattrochon
Copy link
Author

I have tried that solution but it is not able to resolve the files on deployment to a lambda function.
The plugin proposed there tries to load all of the binaries, even ones that havent been installed and fails.

Bit out of my depth on this bundling stuff but very much would like to be able to use the node engine in my lambda function.

@stefan-gorules
Copy link
Contributor

@mattrochon What specific set-up are you using (e.g. aws starter template, esbuild template, etc.)?

@mattrochon
Copy link
Author

mattrochon commented Mar 14, 2024

no starter template, using the aws-lambda package

image

Build invoked like this:

image

I use other modules that have native .node files (prisma, for example) which totally work. I only just recently added gorules and it doesnt seem to handle it int he same way.

***edit

To add context, this configuration passes the build, but on deployment its not loading the .node files so i get an error that

new ZenEngine() is not a constructor.

@mattrochon
Copy link
Author

I'm not sure how to get this to build properly using esbuild. Do you have any insight here?

@mattrochon
Copy link
Author

ok, add

--external:@gorules/zen-engine

and make sure your node modules has the binary targets you need

and itll work

@stefan-gorules
Copy link
Contributor

Thanks for sharing! I'll close the issue now.

@raymondKelly
Copy link

ok, add

--external:@gorules/zen-engine

and make sure your node modules has the binary targets you need

and itll work

@mattrochon I'm in a very similar position to yourself. Why would you mark zen-engine as an external module? Are you also copying that into the lambda? Would you mind sharing your esbuild config?

Thanks for any help you can provide

@tokict
Copy link

tokict commented Oct 25, 2024

So, copy it in the lambda and exclude specific platforms used. If you do local seploy from mac, then exclude darwin one, and if you do it via GH actions, exclude the x64 one like so:

Screenshot 2024-10-25 at 11 42 39

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants