-
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
Declare ModuleWrap::ResolveModuleCallback as public instead of private #45707
Comments
Have you considered using |
Thank you for the info. Actually, that was just an easy sample using |
I suspect plain exposing The loaders API that @aduh95 linked to is probably the way to go for now. |
Thank you for the confirmation. I'm afraid that doesn't serve the embedder I'm working on, because the custom Here are 2 options I'm thinking of for your reference.
|
(2) isn't a bad option for now because loaders are experimental and likely to change. (1) could work but the devil is in the details and here too any such API may need to change again in the future. |
Fair enough. Thank you for sharing the insights. I'll take option 2. |
UpdateIt's hard to fall back to ModuleWrap* dependent = GetFromModule(env, referrer);
if (dependent == nullptr) {
THROW_ERR_VM_MODULE_LINK_FAILURE(
env, "request for '%s' is from invalid module", specifier_std);
return MaybeLocal<Module>();
} It seems Node.js is only friendly with pure JS modules that will be registered as dependent module wraps. Other C++ modules don't seem to be working that way. |
Update: I created synthetic modules calling |
What is the problem this feature will solve?
An embedder is not able to fallback to the built-in Node.js
ModuleWrap::ResolveModuleCallback
if that embedder callsInstantiateModule
with its ownResolveModuleCallback
.For instance:
With the built-in
ModuleWrap::ResolveModuleCallback
, line 1 will fail with:With the embedder's
ResolveModuleCallback
, line 2 will fail with:What is the feature you are proposing to solve the problem?
The embedder is able to fallback to the built-in Node.js
ModuleWrap::ResolveModuleCallback
if it fails to find a suitable external module.The change is very simple: to declare
ModuleWrap::ResolveModuleCallback
aspublic
instead ofprivate
so that the embedder'sResolveModuleCallback
is able to reference and call the built-in Node.jsModuleWrap::ResolveModuleCallback
.I'm using v18.12.1. It's appreciated that the change is applied to the latest v18.
What alternatives have you considered?
No.
The text was updated successfully, but these errors were encountered: