-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
[node-api]: New variant napi_set_named_property
that treats '\0' as values.
#52979
Comments
If the property keys are definite, creating property keys with |
Thanks for the solution. I'm using the workaround like it, but still there is an extra napi call of |
I tried to make a quick improvement for this place @hyf0 @legendecas |
Closing issue, as #52984 has landed, adding |
What is the problem this feature will solve?
I'm developing rolldown, rust version of rollup. Rollup use
\0
as the virtual module name convention.Rolldown follows this convention and got problems while using
napi_set_named_property
.napi_set_named_property
considers\0
as the terminator rather than values. This makes passing"\0mvirtual-module"
to Node usingnapi_set_named_property
become""
.Related issues:
Nul
Error of CString while creating javascript object napi-rs/napi-rs#2110Nul
Error while dealing with virtual modules rolldown/rolldown#1115What is the feature you are proposing to solve the problem?
So I propose a new variant
napi_set_named_property
, maybe call ``napi_set_named_property_len`, which will receive string and the length. This way, it could treat '\0' as values.For alignment, If this request is accepted, I guess
napi_get_named_property
need a new variant too.What alternatives have you considered?
I'm using workaround said in rolldown/rolldown#1115 (comment). Create
JsString
first, then usingnapi_set_property
. But this cause extra napi calls and it's really not good for a bundler that address speed.The text was updated successfully, but these errors were encountered: