From 4833625bf4d7f4e26db3f2a630e0412338cd80a1 Mon Sep 17 00:00:00 2001 From: Boshen Date: Wed, 3 Jul 2024 22:59:13 +0800 Subject: [PATCH] chore(napi): make napi binary smaller with minimal tracing features --- Cargo.lock | 65 --------------------------------------------- napi/Cargo.toml | 11 +++++--- napi/src/tracing.rs | 4 ++- 3 files changed, 10 insertions(+), 70 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fa9e3607..4440ec5a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -300,12 +300,6 @@ dependencies = [ "scopeguard", ] -[[package]] -name = "log" -version = "0.4.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" - [[package]] name = "memchr" version = "2.7.2" @@ -377,16 +371,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f5438dd2b2ff4c6df6e1ce22d825ed2fa93ee2922235cc45186991717f0a892d" -[[package]] -name = "nu-ansi-term" -version = "0.46.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" -dependencies = [ - "overload", - "winapi", -] - [[package]] name = "num-traits" version = "0.2.19" @@ -408,12 +392,6 @@ version = "11.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" -[[package]] -name = "overload" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" - [[package]] name = "oxc_napi_resolver" version = "0.0.0" @@ -700,18 +678,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", - "valuable", -] - -[[package]] -name = "tracing-log" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" -dependencies = [ - "log", - "once_cell", - "tracing-core", ] [[package]] @@ -720,12 +686,9 @@ version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" dependencies = [ - "nu-ansi-term", "sharded-slab", - "smallvec", "thread_local", "tracing-core", - "tracing-log", ] [[package]] @@ -740,12 +703,6 @@ version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" -[[package]] -name = "valuable" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" - [[package]] name = "vfs" version = "0.12.0" @@ -765,22 +722,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - [[package]] name = "winapi-util" version = "0.1.8" @@ -790,12 +731,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - [[package]] name = "windows-sys" version = "0.48.0" diff --git a/napi/Cargo.toml b/napi/Cargo.toml index 0c5aa57d..b97f9d94 100644 --- a/napi/Cargo.toml +++ b/napi/Cargo.toml @@ -11,10 +11,13 @@ test = false doctest = false [dependencies] -oxc_resolver = { path = ".." } -napi = { version = "2.16.7", default-features = false, features = ["napi3", "serde-json"] } -napi-derive = { version = "2.16.6" } -tracing-subscriber = { version = "0.3.18", features = [] } # Omit the `regex` feature +oxc_resolver = { path = ".." } +napi = { version = "2.16.7", default-features = false, features = ["napi3", "serde-json"] } +napi-derive = { version = "2.16.6" } +tracing-subscriber = { version = "0.3.18", default-features = false, features = [ + "std", + "fmt", +] } # Omit the `regex` feature [build-dependencies] napi-build = "2.1.3" diff --git a/napi/src/tracing.rs b/napi/src/tracing.rs index 1f7d309f..88e4cd7e 100644 --- a/napi/src/tracing.rs +++ b/napi/src/tracing.rs @@ -1,6 +1,8 @@ use std::sync::OnceLock; -use tracing_subscriber::{filter::Targets, prelude::*}; +use tracing_subscriber::filter::Targets; +use tracing_subscriber::prelude::__tracing_subscriber_SubscriberExt; +use tracing_subscriber::util::SubscriberInitExt; /// To debug `oxc_resolver`: /// `OXC_LOG=DEBUG your program`