@@ -6,7 +6,7 @@ use swc_config::merge::Merge;
66use swc_core:: common:: comments:: Comments ;
77use swc_core:: common:: iter:: IdentifyLast ;
88use swc_core:: common:: util:: take:: Take ;
9- use swc_core:: common:: { FileName , Mark , SourceMap , Span , Spanned , DUMMY_SP } ;
9+ use swc_core:: common:: { FileName , Mark , SourceMap , Span , Spanned , DUMMY_SP , SyntaxContext } ;
1010use swc_core:: ecma:: ast:: * ;
1111use swc_core:: ecma:: atoms:: { Atom , JsWord } ;
1212use swc_core:: ecma:: utils:: { drop_span, prepend_stmt, quote_ident, ExprFactory , StmtLike } ;
@@ -53,7 +53,10 @@ pub fn parse_expr_for_jsx(
5353 src : String ,
5454 top_level_mark : Mark ,
5555) -> Arc < Box < Expr > > {
56- let fm = cm. new_source_file ( FileName :: Custom ( format ! ( "<jsx-config-{}.js>" , name) ) , src) ;
56+ let fm = cm. new_source_file (
57+ FileName :: Custom ( format ! ( "<jsx-config-{}.js>" , name) ) . into ( ) ,
58+ src
59+ ) ;
5760
5861 parse_file_as_expr (
5962 & fm,
@@ -86,7 +89,7 @@ pub fn parse_expr_for_jsx(
8689fn apply_mark ( e : & mut Expr , mark : Mark ) {
8790 match e {
8891 Expr :: Ident ( i) => {
89- i. span = i. span . apply_mark ( mark) ;
92+ i. ctxt = i. ctxt . apply_mark ( mark) ;
9093 }
9194 Expr :: Member ( MemberExpr { obj, .. } ) => {
9295 apply_mark ( obj, mark) ;
@@ -138,7 +141,7 @@ fn merge_imports(
138141 . specifiers
139142 . push ( ImportSpecifier :: Named ( ImportNamedSpecifier {
140143 span : DUMMY_SP ,
141- local : quote_ident ! ( * import_to_add) ,
144+ local : quote_ident ! ( * import_to_add) . into ( ) ,
142145 imported : None ,
143146 is_type_only : false ,
144147 } ) )
@@ -285,7 +288,7 @@ where
285288
286289 let fragment = self
287290 . import_create_fragment
288- . get_or_insert_with ( || quote_ident ! ( "createFragment" ) )
291+ . get_or_insert_with ( || quote_ident ! ( "createFragment" ) . into ( ) )
289292 . clone ( ) ;
290293
291294 let mut children_requires_normalization: bool = false ;
@@ -314,11 +317,11 @@ where
314317 span : DUMMY_SP ,
315318 callee : self
316319 . import_create_text_vnode
317- . get_or_insert_with ( || quote_ident ! ( "createTextVNode" ) )
320+ . get_or_insert_with ( || quote_ident ! ( "createTextVNode" ) . into ( ) )
318321 . clone ( )
319322 . as_callee ( ) ,
320323 args : vec ! [ s. as_arg( ) ] ,
321- type_args : Default :: default ( ) ,
324+ .. Default :: default ( )
322325 } ) ) ,
323326 }
324327 }
@@ -376,6 +379,7 @@ where
376379 callee : fragment. as_callee ( ) ,
377380 args : create_fragment_vnode_args ( children, false , child_flags as u16 , None , None ) ,
378381 type_args : None ,
382+ ..Default :: default ( )
379383 } )
380384 }
381385
@@ -399,7 +403,7 @@ where
399403 if ident. sym == "Fragment" {
400404 vnode_kind = VNodeType :: Fragment ;
401405 mut_flags = VNodeFlags :: ComponentUnknown as u16 ;
402- name_expr = Expr :: Ident ( Ident :: new ( "createFragment" . into ( ) , ident. span ) ) ;
406+ name_expr = Expr :: Ident ( Ident :: new ( "createFragment" . into ( ) , ident. span . into ( ) , Default :: default ( ) ) ) ;
403407 } else {
404408 vnode_kind = Component ;
405409 mut_flags = VNodeFlags :: ComponentUnknown as u16 ;
@@ -424,7 +428,7 @@ where
424428
425429 return Expr :: Invalid ( Invalid { span : DUMMY_SP } ) ;
426430 }
427- JSXElementName :: JSXMemberExpr ( JSXMemberExpr { obj, prop } ) => {
431+ JSXElementName :: JSXMemberExpr ( JSXMemberExpr { obj, prop, .. } ) => {
428432 vnode_kind = Component ;
429433 mut_flags = VNodeFlags :: ComponentUnknown as u16 ;
430434
@@ -520,9 +524,9 @@ where
520524 . props
521525 . push ( PropOrSpread :: Prop ( Box :: new ( Prop :: KeyValue (
522526 KeyValueProp {
523- key : PropName :: Ident ( Ident :: new (
527+ key : PropName :: Ident ( IdentName :: new (
524528 "onDblClick" . into ( ) ,
525- span,
529+ span
526530 ) ) ,
527531 value : match attr. value {
528532 Some ( v) => jsx_attr_value_to_expr ( v)
@@ -688,10 +692,9 @@ where
688692 value : converted_sym. into ( ) ,
689693 } )
690694 } else {
691- PropName :: Ident ( Ident {
695+ PropName :: Ident ( IdentName {
692696 span : i. span ,
693- sym : converted_sym. into ( ) ,
694- optional : i. optional ,
697+ sym : converted_sym. into ( )
695698 } )
696699 } ;
697700
@@ -702,7 +705,7 @@ where
702705 value,
703706 } ) ) ) ) ;
704707 }
705- JSXAttrName :: JSXNamespacedName ( JSXNamespacedName { ns, name } ) => {
708+ JSXAttrName :: JSXNamespacedName ( JSXNamespacedName { ns, name, .. } ) => {
706709 let value = match attr. value {
707710 Some ( v) => {
708711 jsx_attr_value_to_expr ( v) . expect ( "empty expression container?" )
@@ -767,9 +770,10 @@ where
767770 spread : None ,
768771 expr : Box :: new ( Expr :: Call ( CallExpr {
769772 span : DUMMY_SP ,
773+ ctxt : SyntaxContext :: empty ( ) . apply_mark ( self . unresolved_mark ) ,
770774 callee : self
771775 . import_create_text_vnode
772- . get_or_insert_with ( || quote_ident ! ( "createTextVNode" ) )
776+ . get_or_insert_with ( || quote_ident ! ( "createTextVNode" ) . into ( ) )
773777 . clone ( )
774778 . as_callee ( ) ,
775779 args : vec ! [ s. as_arg( ) ] ,
@@ -832,10 +836,11 @@ where
832836 spread : None ,
833837 expr : Box :: new ( Expr :: Call ( CallExpr {
834838 span : DUMMY_SP ,
839+ ctxt : SyntaxContext :: empty ( ) . apply_mark ( self . unresolved_mark ) ,
835840 callee : self
836841 . import_create_text_vnode
837842 . get_or_insert_with ( || {
838- quote_ident ! ( "createTextVNode" )
843+ quote_ident ! ( "createTextVNode" ) . into ( )
839844 } )
840845 . clone ( )
841846 . as_callee ( ) ,
@@ -963,15 +968,15 @@ where
963968
964969 let create_method = if vnode_kind == Component {
965970 self . import_create_component
966- . get_or_insert_with ( || quote_ident ! ( "createComponentVNode" ) )
971+ . get_or_insert_with ( || quote_ident ! ( "createComponentVNode" ) . into ( ) )
967972 . clone ( )
968973 } else if vnode_kind == VNodeType :: Element {
969974 self . import_create_vnode
970- . get_or_insert_with ( || quote_ident ! ( "createVNode" ) )
975+ . get_or_insert_with ( || quote_ident ! ( "createVNode" ) . into ( ) )
971976 . clone ( )
972977 } else {
973978 self . import_create_fragment
974- . get_or_insert_with ( || quote_ident ! ( "createFragment" ) )
979+ . get_or_insert_with ( || quote_ident ! ( "createFragment" ) . into ( ) )
975980 . clone ( )
976981 } ;
977982
@@ -1016,6 +1021,7 @@ where
10161021
10171022 let create_expr = Expr :: Call ( CallExpr {
10181023 span,
1024+ ctxt : SyntaxContext :: empty ( ) . apply_mark ( self . unresolved_mark ) ,
10191025 callee : create_method. as_callee ( ) ,
10201026 args : create_method_args,
10211027 type_args : Default :: default ( ) ,
@@ -1024,9 +1030,10 @@ where
10241030 if needs_normalization {
10251031 return Expr :: Call ( CallExpr {
10261032 span,
1033+ ctxt : SyntaxContext :: empty ( ) . apply_mark ( self . unresolved_mark ) ,
10271034 callee : self
10281035 . import_normalize_props
1029- . get_or_insert_with ( || quote_ident ! ( "normalizeProps" ) )
1036+ . get_or_insert_with ( || quote_ident ! ( "normalizeProps" ) . into ( ) )
10301037 . clone ( )
10311038 . as_callee ( ) ,
10321039 args : vec ! [ create_expr. as_arg( ) ] ,
@@ -1354,7 +1361,7 @@ where
13541361 . map ( |imported| {
13551362 ImportSpecifier :: Named ( ImportNamedSpecifier {
13561363 span : DUMMY_SP ,
1357- local : quote_ident ! ( imported) ,
1364+ local : quote_ident ! ( imported) . into ( ) ,
13581365 imported : None ,
13591366 is_type_only : false ,
13601367 } )
@@ -1393,6 +1400,7 @@ where
13931400fn add_require ( imports : Vec < & str > , src : & str , unresolved_mark : Mark ) -> Stmt {
13941401 Stmt :: Decl ( Decl :: Var ( Box :: new ( VarDecl {
13951402 span : DUMMY_SP ,
1403+ ctxt : SyntaxContext :: empty ( ) . apply_mark ( unresolved_mark) ,
13961404 kind : VarDeclKind :: Const ,
13971405 declare : false ,
13981406 decls : vec ! [ VarDeclarator {
@@ -1407,6 +1415,7 @@ fn add_require(imports: Vec<&str>, src: &str, unresolved_mark: Mark) -> Stmt {
14071415 key: BindingIdent {
14081416 id: Ident {
14091417 span: DUMMY_SP ,
1418+ ctxt: SyntaxContext :: empty( ) . apply_mark( unresolved_mark) ,
14101419 sym: imported. into( ) ,
14111420 optional: false ,
14121421 } ,
@@ -1422,10 +1431,12 @@ fn add_require(imports: Vec<&str>, src: &str, unresolved_mark: Mark) -> Stmt {
14221431 // require('inferno')
14231432 init: Some ( Box :: new( Expr :: Call ( CallExpr {
14241433 span: DUMMY_SP ,
1434+ ctxt: SyntaxContext :: empty( ) . apply_mark( unresolved_mark) ,
14251435 callee: Callee :: Expr ( Box :: new( Expr :: Ident ( Ident {
1426- span : DUMMY_SP . apply_mark( unresolved_mark) ,
1436+ ctxt : SyntaxContext :: empty ( ) . apply_mark( unresolved_mark) ,
14271437 sym: "require" . into( ) ,
14281438 optional: false ,
1439+ ..Default :: default ( )
14291440 } ) ) ) ,
14301441 args: vec![ ExprOrSpread {
14311442 spread: None ,
0 commit comments