rspack
                                
                                 rspack copied to clipboard
                                
                                    rspack copied to clipboard
                            
                            
                            
                        Perf: Reuse AST passed from bultin:swc_loader to avoid double parse
span is not valid after transformation
currrently Rspack will do double parse for all file processed by builtin:swc-loader, the reason Rspack do double parse is caused by swc transform will make the origin span invalid which cause it's bad for following dependency generation
- before transformed by builtin:swc-loader
import { b }  from './b';
const  a = b;  // now AstNode('b') span is 37-38
- after transformed by builtin:swc-loader
import { b }  from './b';
var a = b; // the span in ast is still 37-38 but after codegen the valid span is actually 34-35
span can be fixed by srcmapbuf generated by codegen
so the span in ASTNode is not valid after transformation, but we can fix the span use src_map generated by emitter, the src_map contains the right mapping from span in ast to span after codegen https://github.com/web-infra-dev/rspack/blob/9112e35f97eeac430691e15c0305763fec56e890/crates/rspack_plugin_javascript/src/ast/stringify.rs#L79-L84
we fix ast span using visit_mut_span in SpanFixerVisitor
struct SpanFixerVisitor {
   src_map_buf: SrcMapBuf
};
impl VisitMut for SpanFixerVisitor {
   fn visit_mut_span(&mut self, span: &mut Span){
             let codegen_span = self.src_map_buf.get(span);
             span.start = codegen_span.start;
             span.end = codegen_span.end;
   }
}
ast invalidation
we should mark the ast dirty | invalid, if the code is modified by following loader
reuse span in module.build
if the AST contains the valid span, then parse can reuse ast passing from builtin:swc-loader, no need to do double parse in module.build
https://github.com/web-infra-dev/rspack/blob/9112e35f97eeac430691e15c0305763fec56e890/crates/rspack_core/src/normal_module.rs#L542