-
Notifications
You must be signed in to change notification settings - Fork 5.6k
feat(compile): support for ffi and node native addons #28934
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
feat(compile): support for ffi and node native addons #28934
Conversation
@@ -87,6 +87,7 @@ impl CliCjsCodeAnalyzer { | |||
source: &str, | |||
esm_analysis_mode: EsmAnalysisMode, | |||
) -> Result<CliCjsAnalysis, JsErrorBox> { | |||
let source = source.strip_prefix('\u{FEFF}').unwrap_or(source); // strip BOM |
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.
Ran into this while testing.
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.
Pull Request Overview
This PR adds support for FFI and Node native addons by extracting shared libraries and .node modules to a temporary file, introducing new runtime options and helper functionality.
- Introduces a new option (deno_rt_native_addon_loader) to various worker service options.
- Updates initialization calls for deno_ffi and deno_napi extensions to pass native addon loader parameters.
- Adds a new helper library (denort_helper) for native addon loading and associated error handling.
Reviewed Changes
Copilot reviewed 28 out of 28 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
runtime/worker.rs | Added new option and updated extension initialization. |
runtime/web_worker.rs | Added native addon loader option to web worker service options. |
runtime/snapshot_info.rs & snapshot.rs | Updated snapshot extension initialization calls. |
runtime/examples/extension/main.rs | Example now provides a native addon loader parameter. |
ext/rt_helper/* | Introduced new helper library for native addon loading. |
ext/napi/* and ext/ffi/* | Updated modules to pass and use the new native addon loader option. |
cli/* | Updated CLI components and Cargo.toml for addon loader support. |
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.
LGTM
This extracts out the shared libraries and
.node
native modules to a temp file and opens them from there. This means that this implementation will not work in every scenario. For example, a library could require other files that only exist in the in-memory file system. To solve that, we'll introduce #28918 later or adapt this solution to solve more issues.Additionally, this will not work when run on readonly file systems.
Closes #23266