From ed8ab6d7c8b51e21a4c850481d0fa87615f614eb Mon Sep 17 00:00:00 2001
From: IWANABETHATGUY <iwanabethatguy@qq.com>
Date: Fri, 6 Sep 2024 14:07:43 +0800
Subject: [PATCH] feat(oxc):  conditional expose `oxc_cfg` in `oxc` crate
 (#5524)

This is useful when the downside user wants to use `oxc_cfg`, and easy
to reuse `petgraph` in `oxc_cfg`
---
 Cargo.lock            | 1 +
 crates/oxc/Cargo.toml | 2 ++
 crates/oxc/src/lib.rs | 6 ++++++
 3 files changed, 9 insertions(+)

diff --git a/Cargo.lock b/Cargo.lock
index 316fa82cc3cb5..f4b170790bb07 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1395,6 +1395,7 @@ version = "0.26.0"
 dependencies = [
  "oxc_allocator",
  "oxc_ast",
+ "oxc_cfg",
  "oxc_codegen",
  "oxc_diagnostics",
  "oxc_index",
diff --git a/crates/oxc/Cargo.toml b/crates/oxc/Cargo.toml
index 64d8765f16115..cb38d9945c9bc 100644
--- a/crates/oxc/Cargo.toml
+++ b/crates/oxc/Cargo.toml
@@ -40,6 +40,7 @@ oxc_mangler               = { workspace = true, optional = true }
 oxc_codegen               = { workspace = true, optional = true }
 oxc_sourcemap             = { workspace = true, optional = true }
 oxc_isolated_declarations = { workspace = true, optional = true }
+oxc_cfg                   = { workspace = true, optional = true }
 
 [features]
 full = ["codegen", "mangler", "minifier", "semantic", "transformer"]
@@ -49,6 +50,7 @@ transformer = ["oxc_transformer"]
 minifier    = ["oxc_mangler", "oxc_minifier"]
 codegen     = ["oxc_codegen"]
 mangler     = ["oxc_mangler"]
+cfg         = ["oxc_cfg"]
 
 serialize = ["oxc_ast/serialize", "oxc_semantic?/serialize", "oxc_span/serialize", "oxc_syntax/serialize"]
 
diff --git a/crates/oxc/src/lib.rs b/crates/oxc/src/lib.rs
index 0cc28b899758f..7683c39ae84ea 100644
--- a/crates/oxc/src/lib.rs
+++ b/crates/oxc/src/lib.rs
@@ -84,3 +84,9 @@ pub mod sourcemap {
     #[doc(inline)]
     pub use oxc_sourcemap::*;
 }
+
+#[cfg(feature = "cfg")]
+pub mod cfg {
+    #[doc(inline)]
+    pub use oxc_cfg::*;
+}