-
Notifications
You must be signed in to change notification settings - Fork 2
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
3.2.4 createRequire
to allow copy loader from esbuild to work in SEA
#48
Conversation
createRequire
to allow copy loader from esbuild to work in SEA
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have to list ruspty as external to the esbuild bundle now?
@@ -6,6 +6,8 @@ | |||
|
|||
const { existsSync, readFileSync } = require('fs') | |||
const { join } = require('path') | |||
const { createRequire } = require('node:module') | |||
require = createRequire(__filename) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not const require make it local?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤷 the node docs recommend it like this, i assume theres some static analysis things at work here
no it should still bundle ok |
The JS Bindings that NAPI-RS produces use raw require calls for local files.
With esbuild, this is normally fine as you can use the copy loader to just move the .node addon to the right place but SEAs dont allow requiring from the fs: nodejs.org/docs/latest-v20.x/api/single-executable-applications.html#requireid-in-the-injected-main-script-is-not-file-based
They recommend using createRequire instead
This change should allow native addons created by NAPI-RS to be used in SEAs