@@ -5,14 +5,37 @@ use crate::convert_ast::converter::ast_constants::{
5
5
EXPORT_DEFAULT_DECLARATION_DECLARATION_OFFSET , EXPORT_DEFAULT_DECLARATION_RESERVED_BYTES ,
6
6
TYPE_CLASS_DECLARATION , TYPE_EXPORT_DEFAULT_DECLARATION , TYPE_FUNCTION_DECLARATION ,
7
7
} ;
8
- use crate :: convert_ast:: converter:: AstConverter ;
8
+
9
+ use crate :: convert_ast:: converter:: { get_outside_class_span_decorators_info, AstConverter } ;
9
10
10
11
impl AstConverter < ' _ > {
11
12
pub ( crate ) fn store_export_default_declaration (
12
13
& mut self ,
13
14
span : & Span ,
14
15
expression : StoredDefaultExportExpression ,
16
+ module_item_insert_position : & mut u32 ,
15
17
) {
18
+ let (
19
+ mut outside_class_span_decorators_insert_position,
20
+ are_decorators_before_export,
21
+ are_decorators_after_export,
22
+ outside_class_span_decorators,
23
+ ) = get_outside_class_span_decorators_info (
24
+ span,
25
+ match expression {
26
+ StoredDefaultExportExpression :: Class ( class_expression) => Some ( & class_expression. class ) ,
27
+ _ => None ,
28
+ } ,
29
+ ) ;
30
+
31
+ if are_decorators_before_export {
32
+ self . store_outside_class_span_decorators (
33
+ outside_class_span_decorators,
34
+ & mut outside_class_span_decorators_insert_position,
35
+ ) ;
36
+ * module_item_insert_position = ( self . buffer . len ( ) as u32 ) >> 2 ;
37
+ }
38
+
16
39
let end_position = self . add_type_and_start (
17
40
& TYPE_EXPORT_DEFAULT_DECLARATION ,
18
41
span,
@@ -23,14 +46,25 @@ impl AstConverter<'_> {
23
46
| StoredDefaultExportExpression :: Function ( _)
24
47
) ,
25
48
) ;
49
+
50
+ if are_decorators_after_export {
51
+ self . store_outside_class_span_decorators (
52
+ outside_class_span_decorators,
53
+ & mut outside_class_span_decorators_insert_position,
54
+ ) ;
55
+ }
26
56
// declaration
27
57
self . update_reference_position ( end_position + EXPORT_DEFAULT_DECLARATION_DECLARATION_OFFSET ) ;
28
58
match expression {
29
59
StoredDefaultExportExpression :: Expression ( expression) => {
30
60
self . convert_expression ( expression) ;
31
61
}
32
62
StoredDefaultExportExpression :: Class ( class_expression) => {
33
- self . store_class_expression ( class_expression, & TYPE_CLASS_DECLARATION )
63
+ self . store_class_expression (
64
+ class_expression,
65
+ & TYPE_CLASS_DECLARATION ,
66
+ outside_class_span_decorators_insert_position,
67
+ ) ;
34
68
}
35
69
StoredDefaultExportExpression :: Function ( function_expression) => self . convert_function (
36
70
& function_expression. function ,
@@ -45,6 +79,7 @@ impl AstConverter<'_> {
45
79
pub ( crate ) fn convert_export_default_declaration (
46
80
& mut self ,
47
81
export_default_declaration : & ExportDefaultDecl ,
82
+ module_item_insert_position : & mut u32 ,
48
83
) {
49
84
self . store_export_default_declaration (
50
85
& export_default_declaration. span ,
@@ -59,16 +94,19 @@ impl AstConverter<'_> {
59
94
unimplemented ! ( "Cannot convert ExportDefaultDeclaration with TsInterfaceDecl" )
60
95
}
61
96
} ,
97
+ module_item_insert_position,
62
98
) ;
63
99
}
64
100
65
101
pub ( crate ) fn convert_export_default_expression (
66
102
& mut self ,
67
103
export_default_expression : & ExportDefaultExpr ,
104
+ module_item_insert_position : & mut u32 ,
68
105
) {
69
106
self . store_export_default_declaration (
70
107
& export_default_expression. span ,
71
108
StoredDefaultExportExpression :: Expression ( & export_default_expression. expr ) ,
109
+ module_item_insert_position,
72
110
) ;
73
111
}
74
112
}
0 commit comments