Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 36.4k
Support for import('./native.node') #55821
Copy link
Copy link
Closed
Labels
addonsIssues and PRs related to native addons.Issues and PRs related to native addons.esmIssues and PRs related to the ECMAScript Modules implementation.Issues and PRs related to the ECMAScript Modules implementation.feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.
Description
Metadata
Metadata
Assignees
Labels
addonsIssues and PRs related to native addons.Issues and PRs related to native addons.esmIssues and PRs related to the ECMAScript Modules implementation.Issues and PRs related to the ECMAScript Modules implementation.feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.
Type
Projects
StatusShow more project fields
Awaiting Triage
What is the problem this feature will solve?
Currently
requireneeds to be used in ES modules in order to be able to load native addons:Previous issue: #40541.
There is some discussion to be had around whether import assertions should be used for the type. Personally I would even prefer if the import assertion wasn't necessarily mandated like we do for Wasm imports.
What is the feature you are proposing to solve the problem?
Transparently add support for
import('./native.node')to work in the Node.js ESM implementation, based on the.nodefile extension.This is one of the few last features that
require()supports butimport()does not, and would help gain full parity between the module systems.What alternatives have you considered?
The alternative is to rely on
processor have a more ergonomicprocess.getNativeModule('./mode.node'), but I think users would prefer the ergonomics of a direct import.Some thought may need to be put to
defaultversus named exports support in this interface as well.