-
Notifications
You must be signed in to change notification settings - Fork 30.2k
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
Support for import('./native.node') #55821
Comments
That would either load |
cc @nodejs/loaders +1 for this. In my mind the only question is whether or not to require the type attribute; see #40541 (comment) and #40766. Are there any spec concerns with leaving it off? If we eventually support non-experimental |
Wasm was landed in HTML recently without requiring the |
What is the problem this feature will solve?
Currently
require
needs 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.node
file 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
process
or 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
default
versus named exports support in this interface as well.The text was updated successfully, but these errors were encountered: