feat(napi-derive): add noop feature to skip napi function register
This commit is contained in:
parent
454711981b
commit
b2e71b5e03
6 changed files with 9 additions and 7 deletions
|
@ -6,11 +6,12 @@ license = "MIT"
|
||||||
name = "napi-derive-backend"
|
name = "napi-derive-backend"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
repository = "https://github.com/napi-rs/napi-rs"
|
repository = "https://github.com/napi-rs/napi-rs"
|
||||||
version = "1.0.15"
|
version = "1.0.16"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
strict = []
|
strict = []
|
||||||
type-def = ["regex", "once_cell"]
|
type-def = ["regex", "once_cell"]
|
||||||
|
noop = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
convert_case = "0.4"
|
convert_case = "0.4"
|
||||||
|
|
|
@ -38,7 +38,7 @@ impl NapiConst {
|
||||||
}
|
}
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
#[allow(clippy::all)]
|
#[allow(clippy::all)]
|
||||||
#[cfg(not(test))]
|
#[cfg(all(not(test), not(feature = "noop")))]
|
||||||
#[napi::bindgen_prelude::ctor]
|
#[napi::bindgen_prelude::ctor]
|
||||||
fn #register_name() {
|
fn #register_name() {
|
||||||
napi::bindgen_prelude::register_module_export(#js_mod_ident, #js_name_lit, #cb_name);
|
napi::bindgen_prelude::register_module_export(#js_mod_ident, #js_name_lit, #cb_name);
|
||||||
|
|
|
@ -147,7 +147,7 @@ impl NapiEnum {
|
||||||
}
|
}
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
#[allow(clippy::all)]
|
#[allow(clippy::all)]
|
||||||
#[cfg(not(test))]
|
#[cfg(all(not(test), not(feature = "noop")))]
|
||||||
#[napi::bindgen_prelude::ctor]
|
#[napi::bindgen_prelude::ctor]
|
||||||
fn #register_name() {
|
fn #register_name() {
|
||||||
napi::bindgen_prelude::register_module_export(#js_mod_ident, #js_name_lit, #callback_name);
|
napi::bindgen_prelude::register_module_export(#js_mod_ident, #js_name_lit, #callback_name);
|
||||||
|
|
|
@ -327,7 +327,7 @@ impl NapiFn {
|
||||||
|
|
||||||
#[allow(clippy::all)]
|
#[allow(clippy::all)]
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
#[cfg(not(test))]
|
#[cfg(all(not(test), not(feature = "noop")))]
|
||||||
#[napi::bindgen_prelude::ctor]
|
#[napi::bindgen_prelude::ctor]
|
||||||
fn #module_register_name() {
|
fn #module_register_name() {
|
||||||
napi::bindgen_prelude::register_module_export(#js_mod_ident, #js_name, #cb_name);
|
napi::bindgen_prelude::register_module_export(#js_mod_ident, #js_name, #cb_name);
|
||||||
|
|
|
@ -453,7 +453,7 @@ impl NapiStruct {
|
||||||
quote! {
|
quote! {
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
#[allow(clippy::all)]
|
#[allow(clippy::all)]
|
||||||
#[cfg(not(test))]
|
#[cfg(all(not(test), not(feature = "noop")))]
|
||||||
#[napi::bindgen_prelude::ctor]
|
#[napi::bindgen_prelude::ctor]
|
||||||
fn #struct_register_name() {
|
fn #struct_register_name() {
|
||||||
napi::bindgen_prelude::register_class(#name_str, #js_mod_ident, #js_name, vec![#(#props),*]);
|
napi::bindgen_prelude::register_class(#name_str, #js_mod_ident, #js_name, vec![#(#props),*]);
|
||||||
|
@ -523,7 +523,7 @@ impl NapiImpl {
|
||||||
use super::*;
|
use super::*;
|
||||||
#(#methods)*
|
#(#methods)*
|
||||||
|
|
||||||
#[cfg(not(test))]
|
#[cfg(all(not(test), not(feature = "noop")))]
|
||||||
#[napi::bindgen_prelude::ctor]
|
#[napi::bindgen_prelude::ctor]
|
||||||
fn #register_name() {
|
fn #register_name() {
|
||||||
napi::bindgen_prelude::register_class(#name_str, #js_mod_ident, #js_name, vec![#(#props),*]);
|
napi::bindgen_prelude::register_class(#name_str, #js_mod_ident, #js_name, vec![#(#props),*]);
|
||||||
|
|
|
@ -7,7 +7,7 @@ license = "MIT"
|
||||||
name = "napi-derive"
|
name = "napi-derive"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
repository = "https://github.com/napi-rs/napi-rs"
|
repository = "https://github.com/napi-rs/napi-rs"
|
||||||
version = "2.0.0-beta.3"
|
version = "2.0.0-beta.4"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
compat-mode = []
|
compat-mode = []
|
||||||
|
@ -15,6 +15,7 @@ default = ["compat-mode", "full"]
|
||||||
full = ["type-def", "strict"]
|
full = ["type-def", "strict"]
|
||||||
strict = ["napi-derive-backend/strict"]
|
strict = ["napi-derive-backend/strict"]
|
||||||
type-def = ["napi-derive-backend/type-def"]
|
type-def = ["napi-derive-backend/type-def"]
|
||||||
|
noop = ["napi-derive-backend/noop"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
convert_case = "0.4"
|
convert_case = "0.4"
|
||||||
|
|
Loading…
Reference in a new issue