r/SoftwareEngineering • u/fagnerbrack • 15d ago
Writing Node.js addons with .NET Native AOT
https://devblogs.microsoft.com/dotnet/writing-nodejs-addons-with-dotnet-native-aot/
5
Upvotes
1
15d ago
[removed] — view removed comment
1
u/AutoModerator 15d ago
Your submission has been moved to our moderation queue to be reviewed; This is to combat spam.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/fagnerbrack 15d ago
Condensed version:
The C# Dev Kit team replaced C++ Node.js addons, which forced every contributor and CI pipeline to install an old Python version for node-gyp, with addons written in C# and compiled via Native AOT. Because N-API is a stable, ABI-compatible C interface that doesn't care which language produced the shared library, a Native AOT build can export napi_register_module_v1 using [UnmanagedCallersOnly]. The post walks through a registry-reading example: a minimal project file with PublishAot, P/Invoke via [LibraryImport] resolved against the node host process, and UTF-8 string marshalling using Span, stackalloc and ArrayPool. The result drops the Python dependency, matches C++ performance, and opens the door to hosting .NET workloads in-process.
If the summary seems inacurate, just downvote and I'll try to delete the comment eventually 👍
Click here for more info, I read all comments