Skip to content

Commit 388060e

Browse files
committed
refactor(es/react): reorganize imports and visibility for JSX components
1 parent 6c60549 commit 388060e

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

crates/swc_ecma_transforms_react/src/jsx/automatic.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ use swc_ecma_utils::{prepend_stmt, private_ident, quote_ident, ExprFactory, Stmt
1212
use swc_ecma_visit::{noop_visit_mut_type, visit_mut_pass, VisitMut, VisitMutWith};
1313

1414
use crate::{
15-
jsx::{should_use_create_element, DevelopmentContext, JsxDev},
16-
jsx_name, jsx_text_to_str, transform_jsx_attr_str, visit_mut_development, AutomaticConfig,
17-
CommonConfig,
15+
jsx::{
16+
development::{visit_mut_development, DevelopmentContext, JsxDev},
17+
should_use_create_element,
18+
},
19+
jsx_name, jsx_text_to_str, transform_jsx_attr_str, AutomaticConfig, CommonConfig,
1820
};
1921

2022
/// Automatic runtime JSX transformer

crates/swc_ecma_transforms_react/src/jsx/classic.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ use swc_ecma_utils::{drop_span, quote_ident, ExprFactory};
1818
use swc_ecma_visit::{noop_visit_mut_type, visit_mut_pass, VisitMut, VisitMutWith};
1919

2020
use crate::{
21-
jsx::{DevelopmentContext, JsxDev},
22-
jsx_name, jsx_text_to_str, transform_jsx_attr_str, visit_mut_development, ClassicConfig,
23-
CommonConfig,
21+
jsx::development::{visit_mut_development, DevelopmentContext, JsxDev},
22+
jsx_name, jsx_text_to_str, transform_jsx_attr_str, ClassicConfig, CommonConfig,
2423
};
2524

2625
/// Parse `src` to use as a `pragma` or `pragmaFrag` in jsx.

crates/swc_ecma_transforms_react/src/jsx/development.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ use swc_ecma_visit::{VisitMut, VisitMutWith};
44

55
/// Context for tracking jsx self state
66
#[derive(Clone, Copy, Default)]
7-
pub struct DevelopmentContext {
7+
pub(crate) struct DevelopmentContext {
88
pub in_constructor: bool,
99
pub in_derived_class: bool,
1010
}
1111

12-
pub trait JsxDev: VisitMut {
12+
pub(crate) trait JsxDev: VisitMut {
1313
fn development_ctxt(&mut self) -> &mut DevelopmentContext;
1414

1515
/// Helper method to run a closure with modified in_constructor state
@@ -68,7 +68,6 @@ pub trait JsxDev: VisitMut {
6868
}
6969
}
7070

71-
#[macro_export]
7271
macro_rules! visit_mut_development {
7372
() => {
7473
fn visit_mut_class(&mut self, n: &mut Class) {
@@ -92,3 +91,5 @@ macro_rules! visit_mut_development {
9291
}
9392
};
9493
}
94+
95+
pub(crate) use visit_mut_development;

crates/swc_ecma_transforms_react/src/jsx/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ mod static_check;
2121

2222
pub use automatic::automatic;
2323
pub use classic::{classic, parse_expr_for_jsx};
24-
pub use development::{DevelopmentContext, JsxDev};
2524
pub use parse_directives::parse_directives;
2625

2726
#[cfg(test)]

0 commit comments

Comments
 (0)