diff --git a/crates/oxc/Cargo.toml b/crates/oxc/Cargo.toml index 98bb16132..74cae3052 100644 --- a/crates/oxc/Cargo.toml +++ b/crates/oxc/Cargo.toml @@ -15,13 +15,18 @@ categories.workspace = true [dependencies] oxc_allocator = { workspace = true } oxc_ast = { workspace = true } -oxc_ast_lower = { workspace = true } oxc_diagnostics = { workspace = true } -oxc_formatter = { workspace = true } -oxc_hir = { workspace = true } oxc_index = { workspace = true } -oxc_minifier = { workspace = true } oxc_parser = { workspace = true } -oxc_semantic = { workspace = true } oxc_span = { workspace = true } oxc_syntax = { workspace = true } +oxc_semantic = { workspace = true, optional = true } +oxc_formatter = { workspace = true, optional = true } +oxc_ast_lower = { workspace = true, optional = true } +oxc_hir = { workspace = true, optional = true } +oxc_minifier = { workspace = true, optional = true } + +[features] +formatter = ["oxc_formatter"] +semantic = ["oxc_semantic"] +minifier = ["oxc_hir", "oxc_ast_lower", "oxc_minifier"] diff --git a/crates/oxc/src/lib.rs b/crates/oxc/src/lib.rs index 515ae4086..2e8a46f6f 100644 --- a/crates/oxc/src/lib.rs +++ b/crates/oxc/src/lib.rs @@ -12,6 +12,7 @@ pub mod ast { pub use oxc_ast::*; } +#[cfg(feature = "minifier")] pub mod ast_lower { #[doc(inline)] pub use oxc_ast_lower::*; @@ -22,11 +23,13 @@ pub mod diagnostics { pub use oxc_diagnostics::*; } +#[cfg(feature = "formatter")] pub mod formatter { #[doc(inline)] pub use oxc_formatter::*; } +#[cfg(feature = "minifier")] pub mod hir { #[doc(inline)] pub use oxc_hir::*; @@ -37,6 +40,7 @@ pub mod index { pub use oxc_index::*; } +#[cfg(feature = "minifier")] pub mod minifier { #[doc(inline)] pub use oxc_minifier::*; @@ -47,6 +51,7 @@ pub mod parser { pub use oxc_parser::*; } +#[cfg(feature = "semantic")] pub mod semantic { #[doc(inline)] pub use oxc_semantic::*; @@ -61,13 +66,3 @@ pub mod syntax { #[doc(inline)] pub use oxc_syntax::*; } - -#[allow(unused_imports)] -#[test] -fn import_smoke_test() { - use crate::{ - allocator::Allocator, ast::ast::Program as AstProgram, ast_lower::AstLower, - diagnostics::Error, formatter::Formatter, hir::hir::Program as HirProgram, index::IndexVec, - minifier::Minifier, parser::Parser, semantic::Semantic, span::Span, syntax::NumberBase, - }; -}