Skip to content

Commit

Permalink
refactor(swc/core): align feature cfg
Browse files Browse the repository at this point in the history
  • Loading branch information
kwonoj committed Aug 2, 2022
1 parent c00b4d1 commit 46da5d3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions crates/swc_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,36 @@

// Quote
#[cfg(any(docsrs, feature = "quote"))]
#[cfg_attr(docsrs, doc(cfg(feature = "quote")))]
pub mod quote {
pub use swc_ecma_quote::*;
}

// Plugins
#[cfg(any(docsrs, feature = "__plugin_transform"))]
#[cfg_attr(docsrs, doc(cfg(feature = "__plugin_transform")))]
pub mod plugin;

// ast exposed via swc_ecma_ast
// TODO: Can dependency tree simplified
// by swc_ecma_ast reexports swc_atoms?
#[cfg(any(docsrs, feature = "__ast"))]
#[cfg_attr(docsrs, doc(cfg(feature = "__ast")))]
pub mod ast {
pub use swc_atoms::*;
pub use swc_ecma_ast::*;
}

// visit* interfaces
#[cfg(any(docsrs, feature = "__visit"))]
#[cfg_attr(docsrs, doc(cfg(feature = "__visit")))]
pub mod visit {
pub use swc_ecma_visit::*;
}

// swc_common features
#[cfg(any(docsrs, feature = "__common"))]
#[cfg_attr(docsrs, doc(cfg(feature = "__common")))]
pub mod common {
pub use swc_common::*;
}
4 changes: 4 additions & 0 deletions crates/swc_core/src/plugin.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// #[plugin_transform] macro
#[cfg(any(docsrs, feature = "__plugin_transform"))]
#[cfg_attr(docsrs, doc(cfg(feature = "__plugin_transform")))]
pub use swc_plugin_macro::plugin_transform;

/// exported __alloc / __free fn for the guest (plugin)
Expand All @@ -13,6 +14,7 @@ pub mod memory {
/// Global HANDLER implementation for the plugin
/// for error reporting.
#[cfg(any(docsrs, feature = "__plugin_transform"))]
#[cfg_attr(docsrs, doc(cfg(feature = "__plugin_transform")))]
pub mod errors {
/// global context HANDLER in plugin's transform function.
pub static HANDLER: swc_plugin::pseudo_scoped_key::PseudoScopedKey<
Expand All @@ -24,13 +26,15 @@ pub mod errors {

/// Plugin's environment metadata context.
#[cfg(any(docsrs, feature = "__plugin_transform"))]
#[cfg_attr(docsrs, doc(cfg(feature = "__plugin_transform")))]
pub mod metadata {
pub use swc_common::plugin::metadata::TransformPluginMetadataContextKind;
pub use swc_plugin_proxy::TransformPluginProgramMetadata;
}

/// Proxy to the host's data not attached to the AST, like sourcemap / comments.
#[cfg(any(docsrs, feature = "__plugin_transform"))]
#[cfg_attr(docsrs, doc(cfg(feature = "__plugin_transform")))]
pub mod proxies {
pub use swc_plugin_proxy::*;
}

0 comments on commit 46da5d3

Please sign in to comment.