diff --git a/crates/swc/tests/fixture/issues-8xxx/8210/output/1.js b/crates/swc/tests/fixture/issues-8xxx/8210/output/1.js index ea1bbedd0ad5..50d292db91b8 100644 --- a/crates/swc/tests/fixture/issues-8xxx/8210/output/1.js +++ b/crates/swc/tests/fixture/issues-8xxx/8210/output/1.js @@ -5,7 +5,7 @@ const Component = ()=>{ fileName: "$DIR/tests/fixture/issues-8xxx/8210/input/1.js", lineNumber: 2, columnNumber: 23 - }, void 0), + }, this), children: "Hello" }, void 0, false, { fileName: "$DIR/tests/fixture/issues-8xxx/8210/input/1.js", diff --git a/crates/swc_ecma_transforms_react/src/jsx/automatic.rs b/crates/swc_ecma_transforms_react/src/jsx/automatic.rs index 588441b19351..badfe66fa726 100644 --- a/crates/swc_ecma_transforms_react/src/jsx/automatic.rs +++ b/crates/swc_ecma_transforms_react/src/jsx/automatic.rs @@ -4,16 +4,19 @@ use std::iter::once; use swc_atoms::{atom, Atom}; use swc_common::{ - comments::Comments, errors::HANDLER, sync::Lrc, util::take::Take, BytePos, Mark, Spanned, - SyntaxContext, DUMMY_SP, + comments::Comments, errors::HANDLER, sync::Lrc, util::take::Take, BytePos, Mark, SourceMap, + Spanned, SyntaxContext, DUMMY_SP, }; use swc_ecma_ast::*; use swc_ecma_utils::{prepend_stmt, private_ident, quote_ident, ExprFactory, StmtLike}; use swc_ecma_visit::{noop_visit_mut_type, visit_mut_pass, VisitMut, VisitMutWith}; use crate::{ - jsx::should_use_create_element, jsx_name, jsx_text_to_str, transform_jsx_attr_str, - AutomaticConfig, CommonConfig, + jsx::{ + development::{visit_mut_development, DevelopmentContext, JsxDev}, + should_use_create_element, + }, + jsx_name, jsx_text_to_str, transform_jsx_attr_str, AutomaticConfig, CommonConfig, }; /// Automatic runtime JSX transformer @@ -27,6 +30,7 @@ pub fn automatic( common: CommonConfig, unresolved_mark: Mark, comments: Option, + cm: Lrc, ) -> impl Pass + VisitMut where C: Comments + 'static, @@ -46,9 +50,13 @@ where import_fragment: None, import_create_element: None, - development: common.development.into_bool(), throw_if_namespace: common.throw_if_namespace.into_bool(), + + development: common.development.into_bool(), + development_ctx: DevelopmentContext::default(), + add_pure_comment, + cm, }) } @@ -61,10 +69,13 @@ struct Automatic { import_create_element: Option, import_fragment: Option, - development: bool, throw_if_namespace: bool, + development: bool, + development_ctx: DevelopmentContext, + add_pure_comment: Lrc, + cm: Lrc, } impl Automatic { @@ -241,8 +252,6 @@ impl Automatic { }; let mut key = None; - let mut source_props = None; - let mut self_props = None; for attr in el.opening.attrs { match attr { @@ -270,36 +279,6 @@ impl Automatic { continue; } - if !use_create_element && *i.sym == *"__source" && self.development { - if source_props.is_some() { - panic!("Duplicate __source is found"); - } - source_props = attr - .value - .and_then(jsx_attr_value_to_expr) - .map(|expr| expr.as_arg()); - assert_ne!( - source_props, None, - "value of property '__source' should not be empty" - ); - continue; - } - - if !use_create_element && *i.sym == *"__self" && self.development { - if self_props.is_some() { - panic!("Duplicate __self is found"); - } - self_props = attr - .value - .and_then(jsx_attr_value_to_expr) - .map(|expr| expr.as_arg()); - assert_ne!( - self_props, None, - "value of property '__self' should not be empty" - ); - continue; - } - let value = match attr.value { Some(v) => { jsx_attr_value_to_expr(v).expect("empty expression container?") @@ -407,6 +386,23 @@ impl Automatic { } } + if use_create_element && self.development { + props_obj.props.push( + Prop::KeyValue(KeyValueProp { + key: quote_ident!("__source").into(), + value: self.source_props(el.span.lo).into(), + }) + .into(), + ); + props_obj.props.push( + Prop::KeyValue(KeyValueProp { + key: quote_ident!("__self").into(), + value: self.self_props().into(), + }) + .into(), + ); + } + let args = once(name.as_arg()).chain(once(props_obj.as_arg())); let args = if use_create_element { args.chain(children.into_iter().flatten()).collect() @@ -417,21 +413,10 @@ impl Automatic { None => Expr::undefined(DUMMY_SP).as_arg(), }; - // set undefined literal to __source if __source is None - let source_props = match source_props { - Some(source_props) => source_props, - None => Expr::undefined(DUMMY_SP).as_arg(), - }; - - // set undefined literal to __self if __self is None - let self_props = match self_props { - Some(self_props) => self_props, - None => Expr::undefined(DUMMY_SP).as_arg(), - }; args.chain(once(key)) .chain(once(use_jsxs.as_arg())) - .chain(once(source_props)) - .chain(once(self_props)) + .chain(once(self.source_props(el.span.lo).as_arg())) + .chain(once(self.self_props().as_arg())) .collect() } else { args.chain(key).collect() @@ -488,9 +473,44 @@ impl Automatic { } } +impl Automatic { + fn source_props(&self, pos: BytePos) -> ObjectLit { + let loc = self.cm.lookup_char_pos(pos); + + ObjectLit { + props: vec![ + Prop::KeyValue(KeyValueProp { + key: quote_ident!("fileName").into(), + value: loc.file.name.to_string().into(), + }) + .into(), + Prop::KeyValue(KeyValueProp { + key: quote_ident!("lineNumber").into(), + value: loc.line.into(), + }) + .into(), + Prop::KeyValue(KeyValueProp { + key: quote_ident!("columnNumber").into(), + value: (loc.col.0 + 1).into(), + }) + .into(), + ], + ..Default::default() + } + } +} + +impl JsxDev for Automatic { + fn development_ctxt(&mut self) -> &mut DevelopmentContext { + &mut self.development_ctx + } +} + impl VisitMut for Automatic { noop_visit_mut_type!(); + visit_mut_development!(); + fn visit_mut_expr(&mut self, expr: &mut Expr) { if let Expr::JSXElement(el) = expr { //
=> React.createElement('div', null); diff --git a/crates/swc_ecma_transforms_react/src/jsx/classic.rs b/crates/swc_ecma_transforms_react/src/jsx/classic.rs index 98249e957db7..15ae86b6f542 100644 --- a/crates/swc_ecma_transforms_react/src/jsx/classic.rs +++ b/crates/swc_ecma_transforms_react/src/jsx/classic.rs @@ -14,10 +14,13 @@ use swc_common::{ }; use swc_ecma_ast::*; use swc_ecma_parser::{parse_file_as_expr, Syntax}; -use swc_ecma_utils::{drop_span, ExprFactory}; +use swc_ecma_utils::{drop_span, quote_ident, ExprFactory}; use swc_ecma_visit::{noop_visit_mut_type, visit_mut_pass, VisitMut, VisitMutWith}; -use crate::{jsx_name, jsx_text_to_str, transform_jsx_attr_str, ClassicConfig, CommonConfig}; +use crate::{ + jsx::development::{visit_mut_development, DevelopmentContext, JsxDev}, + jsx_name, jsx_text_to_str, transform_jsx_attr_str, ClassicConfig, CommonConfig, +}; /// Parse `src` to use as a `pragma` or `pragmaFrag` in jsx. pub fn parse_expr_for_jsx( @@ -107,20 +110,29 @@ where visit_mut_pass(Classic { pragma, - pragma_frag, + throw_if_namespace: common.throw_if_namespace.into_bool(), + + development: common.development.into_bool(), + development_ctx: DevelopmentContext::default(), + add_pure_comment, + cm, }) } struct Classic { pragma: Lrc>, - pragma_frag: Lrc>, + throw_if_namespace: bool, + development: bool, + development_ctx: DevelopmentContext, + add_pure_comment: Lrc, + cm: Lrc, } #[cfg(feature = "concurrent")] @@ -317,10 +329,20 @@ impl Classic { } } +impl JsxDev for Classic { + fn development_ctxt(&mut self) -> &mut DevelopmentContext { + &mut self.development_ctx + } +} + impl VisitMut for Classic { noop_visit_mut_type!(); + visit_mut_development!(); + fn visit_mut_expr(&mut self, expr: &mut Expr) { + expr.visit_mut_children_with(self); + if let Expr::JSXElement(el) = expr { //
=> React.createElement('div', null); *expr = self.jsx_elem_to_expr(*el.take()); @@ -340,8 +362,69 @@ impl VisitMut for Classic { *expr = self.jsx_frag_to_expr(frag.take()); } } + } - expr.visit_mut_children_with(self); + fn visit_mut_jsx_opening_element(&mut self, e: &mut JSXOpeningElement) { + e.visit_mut_children_with(self); + + if !self.development { + return; + } + + let loc = self.cm.lookup_char_pos(e.span.lo); + let file_name = loc.file.name.to_string(); + + e.attrs.push( + JSXAttr { + span: DUMMY_SP, + name: quote_ident!("__source").into(), + value: Some( + JSXExprContainer { + span: DUMMY_SP, + expr: JSXExpr::Expr( + ObjectLit { + span: DUMMY_SP, + props: vec![ + Prop::KeyValue(KeyValueProp { + key: quote_ident!("fileName").into(), + value: file_name.into(), + }) + .into(), + Prop::KeyValue(KeyValueProp { + key: quote_ident!("lineNumber").into(), + value: loc.line.into(), + }) + .into(), + Prop::KeyValue(KeyValueProp { + key: quote_ident!("columnNumber").into(), + value: (loc.col.0 + 1).into(), + }) + .into(), + ], + } + .into(), + ), + } + .into(), + ), + } + .into(), + ); + + e.attrs.push( + JSXAttr { + span: DUMMY_SP, + name: quote_ident!("__self").into(), + value: Some( + JSXExprContainer { + span: DUMMY_SP, + expr: JSXExpr::Expr(self.self_props().into()), + } + .into(), + ), + } + .into(), + ); } } diff --git a/crates/swc_ecma_transforms_react/src/jsx/development.rs b/crates/swc_ecma_transforms_react/src/jsx/development.rs new file mode 100644 index 000000000000..3954af184054 --- /dev/null +++ b/crates/swc_ecma_transforms_react/src/jsx/development.rs @@ -0,0 +1,95 @@ +use swc_common::{util::take::Take, DUMMY_SP}; +use swc_ecma_ast::*; +use swc_ecma_visit::{VisitMut, VisitMutWith}; + +/// Context for tracking jsx self state +#[derive(Clone, Copy, Default)] +pub(crate) struct DevelopmentContext { + pub in_constructor: bool, + pub in_derived_class: bool, +} + +pub(crate) trait JsxDev: VisitMut { + fn development_ctxt(&mut self) -> &mut DevelopmentContext; + + /// Helper method to run a closure with modified in_constructor state + fn with_in_constructor>(&mut self, in_constructor: bool, n: &mut N) { + let ctxt = *self.development_ctxt(); + self.development_ctxt().in_constructor = in_constructor; + n.visit_mut_children_with(self); + *self.development_ctxt() = ctxt; + } + + fn visit_mut_class(&mut self, n: &mut Class) { + let ctxt = *self.development_ctxt(); + self.development_ctxt().in_derived_class = n.super_class.is_some(); + n.visit_mut_children_with(self); + *self.development_ctxt() = ctxt; + } + + fn visit_mut_fn_decl(&mut self, n: &mut FnDecl) { + self.with_in_constructor(false, n); + } + + fn visit_mut_fn_expr(&mut self, n: &mut FnExpr) { + self.with_in_constructor(false, n); + } + + fn visit_mut_prop(&mut self, n: &mut Prop) { + match n { + Prop::Getter(_) | Prop::Setter(_) | Prop::Method(_) => { + self.with_in_constructor(false, n) + } + _ => n.visit_mut_children_with(self), + } + } + + fn visit_mut_class_member(&mut self, n: &mut ClassMember) { + match n { + ClassMember::Constructor(_) => self.with_in_constructor(true, n), + ClassMember::Method(_) + | ClassMember::PrivateMethod(_) + | ClassMember::StaticBlock(_) => self.with_in_constructor(false, n), + _ => n.visit_mut_children_with(self), + } + } + + /// https://github.com/babel/babel/blob/1bdb1a4175ed1fc40751fb84dc4ad1900260f28f/packages/babel-plugin-transform-react-jsx-self/src/index.ts#L50 + fn is_this_allowed(&mut self) -> bool { + !(self.development_ctxt().in_constructor && self.development_ctxt().in_derived_class) + } + + fn self_props(&mut self) -> Expr { + if self.is_this_allowed() { + Expr::This(ThisExpr::dummy()) + } else { + *Expr::undefined(DUMMY_SP) + } + } +} + +macro_rules! visit_mut_development { + () => { + fn visit_mut_class(&mut self, n: &mut Class) { + JsxDev::visit_mut_class(self, n); + } + + fn visit_mut_fn_decl(&mut self, n: &mut FnDecl) { + JsxDev::visit_mut_fn_decl(self, n); + } + + fn visit_mut_fn_expr(&mut self, n: &mut FnExpr) { + JsxDev::visit_mut_fn_expr(self, n); + } + + fn visit_mut_prop(&mut self, n: &mut Prop) { + JsxDev::visit_mut_prop(self, n); + } + + fn visit_mut_class_member(&mut self, n: &mut ClassMember) { + JsxDev::visit_mut_class_member(self, n); + } + }; +} + +pub(crate) use visit_mut_development; diff --git a/crates/swc_ecma_transforms_react/src/jsx/mod.rs b/crates/swc_ecma_transforms_react/src/jsx/mod.rs index 084f725937ae..7453c2e3c230 100644 --- a/crates/swc_ecma_transforms_react/src/jsx/mod.rs +++ b/crates/swc_ecma_transforms_react/src/jsx/mod.rs @@ -15,6 +15,7 @@ use crate::refresh::options::{deserialize_refresh, RefreshOptions}; mod automatic; mod classic; +mod development; mod parse_directives; mod static_check; @@ -274,7 +275,13 @@ where match runtime { Runtime::Automatic(config) => ( - Some(automatic(config, common, unresolved_mark, comments.clone())), + Some(automatic( + config, + common, + unresolved_mark, + comments.clone(), + cm.clone(), + )), None, ), Runtime::Classic(config) => ( diff --git a/crates/swc_ecma_transforms_react/src/jsx_self/mod.rs b/crates/swc_ecma_transforms_react/src/jsx_self/mod.rs deleted file mode 100644 index 0ff43babd533..000000000000 --- a/crates/swc_ecma_transforms_react/src/jsx_self/mod.rs +++ /dev/null @@ -1,106 +0,0 @@ -use swc_common::DUMMY_SP; -use swc_ecma_ast::*; -use swc_ecma_transforms_base::perf::Parallel; -use swc_ecma_utils::quote_ident; -use swc_ecma_visit::{noop_visit_mut_type, visit_mut_pass, VisitMut, VisitMutWith}; - -#[cfg(test)] -mod tests; - -/// `@babel/plugin-transform-react-jsx-self` -/// -/// Add a __self prop to all JSX Elements -pub fn jsx_self(dev: bool) -> impl Pass { - visit_mut_pass(JsxSelf { - dev, - ctx: Default::default(), - }) -} - -/// See -#[derive(Clone, Copy, Default)] -struct Context { - in_constructor: bool, - in_derived_class: bool, -} - -#[derive(Clone, Copy)] -struct JsxSelf { - dev: bool, - ctx: Context, -} - -impl JsxSelf { - fn with_in_constructor>(&mut self, in_constructor: bool, n: &mut N) { - let old = self.ctx; - self.ctx.in_constructor = in_constructor; - n.visit_mut_children_with(self); - self.ctx = old; - } -} - -impl Parallel for JsxSelf { - fn create(&self) -> Self { - *self - } - - fn merge(&mut self, _: Self) {} -} - -impl VisitMut for JsxSelf { - noop_visit_mut_type!(); - - fn visit_mut_class(&mut self, n: &mut Class) { - let old = self.ctx; - self.ctx.in_derived_class = n.super_class.is_some(); - n.visit_mut_children_with(self); - self.ctx = old; - } - - fn visit_mut_fn_decl(&mut self, n: &mut FnDecl) { - self.with_in_constructor(false, n); - } - - fn visit_mut_fn_expr(&mut self, n: &mut FnExpr) { - self.with_in_constructor(false, n); - } - - fn visit_mut_prop(&mut self, n: &mut Prop) { - match n { - Prop::Getter(_) | Prop::Setter(_) | Prop::Method(_) => { - self.with_in_constructor(false, n) - } - _ => n.visit_mut_children_with(self), - } - } - - fn visit_mut_class_member(&mut self, n: &mut ClassMember) { - match n { - ClassMember::Constructor(_) => self.with_in_constructor(true, n), - ClassMember::Method(_) - | ClassMember::PrivateMethod(_) - | ClassMember::StaticBlock(_) => self.with_in_constructor(false, n), - _ => n.visit_mut_children_with(self), - } - } - - fn visit_mut_jsx_opening_element(&mut self, n: &mut JSXOpeningElement) { - if !self.dev { - return; - } - - // https://github.com/babel/babel/blob/1bdb1a4175ed1fc40751fb84dc4ad1900260f28f/packages/babel-plugin-transform-react-jsx-self/src/index.ts#L50 - if self.ctx.in_constructor && self.ctx.in_derived_class { - return; - } - - n.attrs.push(JSXAttrOrSpread::JSXAttr(JSXAttr { - span: DUMMY_SP, - name: JSXAttrName::Ident(quote_ident!("__self")), - value: Some(JSXAttrValue::JSXExprContainer(JSXExprContainer { - span: DUMMY_SP, - expr: JSXExpr::Expr(Box::new(ThisExpr { span: DUMMY_SP }.into())), - })), - })); - } -} diff --git a/crates/swc_ecma_transforms_react/src/jsx_self/tests.rs b/crates/swc_ecma_transforms_react/src/jsx_self/tests.rs deleted file mode 100644 index 62f23db76a4c..000000000000 --- a/crates/swc_ecma_transforms_react/src/jsx_self/tests.rs +++ /dev/null @@ -1,107 +0,0 @@ -use swc_common::Mark; -use swc_ecma_transforms_base::resolver; -use swc_ecma_transforms_compat::es2015::arrow; -use swc_ecma_transforms_testing::test; - -use super::*; - -fn tr() -> impl Pass { - jsx_self(true) -} - -test!( - module, - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { - jsx: true, - ..Default::default() - }), - |_| tr(), - basic_sample, - r#"var x = "# -); - -test!( - module, - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { - jsx: true, - ..Default::default() - }), - |_| tr(), - disable_with_super, - r#"class A { } - -class B extends A { - constructor() { - ; - super(); - ; - } -} - -class C { - constructor() { - ; - class D extends A { - constructor() { - super(); - } - } - const E = class extends A { - constructor() { - super(); - } - }; - } -} - -class E extends A { - constructor() { - this.x = () => ; - this.y = function () { - return ; - }; - function z() { - return ; - } - { } - super(); - } -} - -class F { - constructor() { - - } -} - -class G extends A { - constructor() { - return ; - } -}"# -); - -test!( - module, - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { - jsx: true, - ..Default::default() - }), - |_| { - let unresolved_mark = Mark::new(); - let top_level_mark = Mark::new(); - ( - resolver(unresolved_mark, top_level_mark, false), - tr(), - arrow(unresolved_mark), - ) - }, - arrow_function, - r#"
; -() =>
; - -function fn() { -
; - () =>
; -}"# -); diff --git a/crates/swc_ecma_transforms_react/src/jsx_src/mod.rs b/crates/swc_ecma_transforms_react/src/jsx_src/mod.rs deleted file mode 100644 index 615cfb194d29..000000000000 --- a/crates/swc_ecma_transforms_react/src/jsx_src/mod.rs +++ /dev/null @@ -1,74 +0,0 @@ -use swc_common::{sync::Lrc, SourceMap, DUMMY_SP}; -use swc_ecma_ast::*; -use swc_ecma_transforms_base::perf::Parallel; -use swc_ecma_utils::quote_ident; -use swc_ecma_visit::{noop_visit_mut_type, visit_mut_pass, VisitMut, VisitMutWith}; - -#[cfg(test)] -mod tests; - -/// `@babel/plugin-transform-react-jsx-source` -pub fn jsx_src(dev: bool, cm: Lrc) -> impl Pass { - visit_mut_pass(JsxSrc { cm, dev }) -} - -#[derive(Clone)] -struct JsxSrc { - cm: Lrc, - dev: bool, -} - -impl Parallel for JsxSrc { - fn create(&self) -> Self { - self.clone() - } - - fn merge(&mut self, _: Self) {} -} - -impl VisitMut for JsxSrc { - noop_visit_mut_type!(); - - fn visit_mut_jsx_opening_element(&mut self, e: &mut JSXOpeningElement) { - if !self.dev || e.span == DUMMY_SP { - return; - } - - e.visit_mut_children_with(self); - - let loc = self.cm.lookup_char_pos(e.span.lo); - let file_name = loc.file.name.to_string(); - - e.attrs.push(JSXAttrOrSpread::JSXAttr(JSXAttr { - span: DUMMY_SP, - name: JSXAttrName::Ident(quote_ident!("__source")), - value: Some(JSXAttrValue::JSXExprContainer(JSXExprContainer { - span: DUMMY_SP, - expr: JSXExpr::Expr(Box::new( - ObjectLit { - span: DUMMY_SP, - props: vec![ - PropOrSpread::Prop(Box::new(Prop::KeyValue(KeyValueProp { - key: PropName::Ident(quote_ident!("fileName")), - value: Box::new(Expr::Lit(Lit::Str(Str { - span: DUMMY_SP, - raw: None, - value: file_name.into(), - }))), - }))), - PropOrSpread::Prop(Box::new(Prop::KeyValue(KeyValueProp { - key: PropName::Ident(quote_ident!("lineNumber")), - value: loc.line.into(), - }))), - PropOrSpread::Prop(Box::new(Prop::KeyValue(KeyValueProp { - key: PropName::Ident(quote_ident!("columnNumber")), - value: (loc.col.0 + 1).into(), - }))), - ], - } - .into(), - )), - })), - })); - } -} diff --git a/crates/swc_ecma_transforms_react/src/jsx_src/tests.rs b/crates/swc_ecma_transforms_react/src/jsx_src/tests.rs deleted file mode 100644 index 79e24b9e50d3..000000000000 --- a/crates/swc_ecma_transforms_react/src/jsx_src/tests.rs +++ /dev/null @@ -1,66 +0,0 @@ -use swc_common::FilePathMapping; -use swc_ecma_transforms_testing::{test, test_exec}; - -use super::*; - -fn tr() -> impl Pass { - let cm = Lrc::new(SourceMap::new(FilePathMapping::empty())); - jsx_src(true, cm) -} - -test_exec!( - ignore, - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { - jsx: true, - ..Default::default() - }), - |_| tr(), - basic_sample, - r#" -var actual = transform( - 'var x = ', - Object.assign({}, opts, { filename: '/fake/path/mock.js' }) -).code; - -var expected = multiline([ - 'var _jsxFileName = "/fake/path/mock.js";', - 'var x = ;', -]); - -expect(actual).toBe(expected); -"# -); - -test!( - module, - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { - jsx: true, - ..Default::default() - }), - |_| tr(), - no_jsx, - r#"var x = 42;"# -); - -test_exec!( - ignore, - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { - jsx: true, - ..Default::default() - }), - |_| tr(), - with_source, - r#" -var actual = transform( - 'var x = ;', - Object.assign({}, opts, { filename: '/fake/path/mock.js' }) -).code; - -var expected = 'var x = ;'; - -expect(actual).toBe(expected); -"# -); diff --git a/crates/swc_ecma_transforms_react/src/lib.rs b/crates/swc_ecma_transforms_react/src/lib.rs index ea0e9faf7bd4..bd76e37606bb 100644 --- a/crates/swc_ecma_transforms_react/src/lib.rs +++ b/crates/swc_ecma_transforms_react/src/lib.rs @@ -12,16 +12,12 @@ use swc_ecma_ast::Pass; pub use self::{ display_name::display_name, jsx::*, - jsx_self::jsx_self, - jsx_src::jsx_src, pure_annotations::pure_annotations, refresh::{options::RefreshOptions, refresh}, }; mod display_name; mod jsx; -mod jsx_self; -mod jsx_src; mod pure_annotations; mod refresh; @@ -59,8 +55,6 @@ where let refresh_options = options.refresh; ( - jsx_src(development, cm.clone()), - jsx_self(development), refresh( development, refresh_options, @@ -68,8 +62,15 @@ where comments.clone(), top_level_mark, ), - auto_config - .map(|config| automatic(config, options.common, unresolved_mark, comments.clone())), + auto_config.map(|config| { + automatic( + config, + options.common, + unresolved_mark, + comments.clone(), + cm.clone(), + ) + }), classic_config.map(|config| { classic( config,