Skip to content

Commit 16f514c

Browse files
authored
feat(napi): add tracing-subscriber feature; turned on by default (#546)
closes #545
1 parent d7e608f commit 16f514c

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed

README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,6 @@ OXC_LOG=DEBUG your_program
224224
RD_LOG='oxc_resolver' rolldown build
225225
```
226226

227-
### Rspack
228-
229-
```bash
230-
RSPACK_PROFILE='TRACE=filter=oxc_resolver=trace&layer=logger' rspack build
231-
```
232-
233227
## Test
234228

235229
Tests are ported from

napi/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ oxc_resolver = { workspace = true }
2424

2525
napi = { version = "3.0.0-beta", default-features = false, features = ["napi3", "serde-json"] }
2626
napi-derive = { version = "3.0.0-beta" }
27-
tracing-subscriber = { version = "0.3.18", default-features = false, features = ["std", "fmt"] } # Omit the `regex` feature
27+
tracing-subscriber = { version = "0.3.18", optional = true, default-features = false, features = ["std", "fmt"] } # Omit the `regex` feature
2828

2929
[target.'cfg(not(any(target_os = "linux", target_os = "freebsd", target_arch = "arm", target_family = "wasm")))'.dependencies]
3030
mimalloc-safe = { version = "0.1.51", optional = true, features = ["skip_collect_on_exit"] }
@@ -39,5 +39,6 @@ mimalloc-safe = { version = "0.1.51", optional = true, features = ["skip_collect
3939
napi-build = "2.2.0"
4040

4141
[features]
42-
default = []
42+
default = ["tracing-subscriber"]
4343
allocator = ["dep:mimalloc-safe"]
44+
tracing-subscriber = ["dep:tracing-subscriber"]

napi/src/lib.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,10 @@ use napi::{Task, bindgen_prelude::AsyncTask};
1414
use napi_derive::napi;
1515
use oxc_resolver::{PackageJson, ResolveOptions, Resolver};
1616

17-
use self::{
18-
options::{NapiResolveOptions, StrOrStrList},
19-
tracing::init_tracing,
20-
};
17+
use self::options::{NapiResolveOptions, StrOrStrList};
2118

2219
mod options;
20+
#[cfg(feature = "tracing-subscriber")]
2321
mod tracing;
2422

2523
#[napi(object)]
@@ -117,7 +115,10 @@ pub struct ResolverFactory {
117115
impl ResolverFactory {
118116
#[napi(constructor)]
119117
pub fn new(options: Option<NapiResolveOptions>) -> Self {
120-
init_tracing();
118+
#[cfg(feature = "tracing-subscriber")]
119+
{
120+
tracing::init_tracing();
121+
}
121122
let options = options.map_or_else(ResolveOptions::default, Self::normalize_options);
122123
Self { resolver: Arc::new(Resolver::new(options)) }
123124
}

0 commit comments

Comments
 (0)