fn handle_export_stars(&self, ctx: &Ctx, entry: &mut Module) {
        {
            // Handle `export *` for non-wrapped modules.

            let mut extra_stmts = vec![];

            for stmt in entry.body.iter() {
                match stmt {
                    ModuleItem::Stmt(Stmt::Decl(Decl::Var(decl))) => {
                        let ids: Vec<Id> = find_ids(decl);

                        for id in ids {
                            if let Some(remapped) = ctx.transitive_remap.get(&id.ctxt()) {
                                let reexported = id.clone().with_ctxt(remapped);
                                extra_stmts.push(
                                    id.assign_to(reexported)
                                        .into_module_item("export_star_replacer"),
                                );
                            }
                        }
                    }

                    _ => {}
                }
            }

            entry.body.extend(extra_stmts);
        }

        {
            let mut map = ctx.export_stars_in_wrapped.lock();
            let mut additional_props = HashMap::<_, Vec<_>>::new();
            // Handle `export *` for wrapped modules.
            for (module_id, ctxts) in map.drain() {
                for stmt in entry.body.iter() {
                    match stmt {
                        ModuleItem::Stmt(Stmt::Decl(Decl::Var(decl))) => {
                            let ids: Vec<Id> = find_ids(decl);

                            for id in ids {
                                if ctxts.contains(&id.ctxt()) {
                                    additional_props.entry(module_id).or_default().push(
                                        PropOrSpread::Prop(Box::new(Prop::Shorthand(
                                            id.into_ident(),
                                        ))),
                                    );
                                }
                            }
                        }
                        _ => {}
                    }
                }
            }

            for (module_id, props) in additional_props {
                let id = match self.scope.wrapped_esm_id(module_id) {
                    Some(v) => v,
                    None => continue,
                };

                for stmt in &mut entry.body {
                    let var = match stmt {
                        ModuleItem::Stmt(Stmt::Decl(Decl::Var(
                            var
                            @
                            VarDecl {
                                kind: VarDeclKind::Const,
                                ..
                            },
                        ))) => var,
                        _ => continue,
                    };

                    if var.decls.len() != 1 {
                        continue;
                    }

                    let var_decl = &mut var.decls[0];
                    match &var_decl.name {
                        Pat::Ident(i) if id == *i => {}
                        _ => continue,
                    }

                    let callee = match &mut var_decl.init {
                        Some(init) => match &mut **init {
                            Expr::Call(CallExpr { callee, .. }) => match callee {
                                ExprOrSuper::Super(_) => continue,
                                ExprOrSuper::Expr(v) => v,
                            },
                            _ => continue,
                        },
                        None => continue,
                    };

                    let f = match &mut **callee {
                        Expr::Fn(f) => f,
                        _ => continue,
                    };

                    let body = match &mut f.function.body {
                        Some(body) => body,
                        None => continue,
                    };

                    let last_stmt = body.stmts.last_mut();

                    let return_stmt = match last_stmt {
                        Some(Stmt::Return(s)) => s,
                        _ => continue,
                    };

                    let ret_val = match &mut return_stmt.arg {
                        Some(arg) => arg,
                        None => continue,
                    };

                    let obj = match &mut **ret_val {
                        Expr::Object(obj) => obj,
                        _ => continue,
                    };

                    obj.props.extend(props);
                    break;
                }
            }
        }
    }
/// This should only be called after everything is merged.
///
/// This method does not care about orders of statement, and it's expected
/// to be called before `sort`.
This should only be called after everything is merged.
This method does not care about orders of statement, and it's expected
to be called before `sort`.
This should only be called after everything is merged . This method does not care about orders of statement and it ' s expected to be called before ` sort ` .
fn handle_export_stars(&self, ctx: &Ctx, entry: &mut Module) {
        {
            // Handle `export *` for non-wrapped modules.
            let mut extra_stmts = vec![];
            for stmt in entry.body.iter() {
                match stmt {
                    ModuleItem::Stmt(Stmt::Decl(Decl::Var(decl))) => {
                        let ids: Vec<Id> = find_ids(decl);
                        for id in ids {
                            if let Some(remapped) = ctx.transitive_remap.get(&id.ctxt()) {
                                let reexported = id.clone().with_ctxt(remapped);
                                extra_stmts.push(
                                    id.assign_to(reexported)
                                        .into_module_item("export_star_replacer"),
                                );
                            }
                        }
                    }
                    _ => {}
                }
            }
            entry.body.extend(extra_stmts);
        }
        {
            let mut map = ctx.export_stars_in_wrapped.lock();
            let mut additional_props = HashMap::<_, Vec<_>>::new();
            // Handle `export *` for wrapped modules.
            for (module_id, ctxts) in map.drain() {
                for stmt in entry.body.iter() {
                    match stmt {
                        ModuleItem::Stmt(Stmt::Decl(Decl::Var(decl))) => {
                            let ids: Vec<Id> = find_ids(decl);
                            for id in ids {
                                if ctxts.contains(&id.ctxt()) {
                                    additional_props.entry(module_id).or_default().push(
                                        PropOrSpread::Prop(Box::new(Prop::Shorthand(
                                            id.into_ident(),
                                        ))),
                                    );
                                }
                            }
                        }
                        _ => {}
                    }
                }
            }
            for (module_id, props) in additional_props {
                let id = match self.scope.wrapped_esm_id(module_id) {
                    Some(v) => v,
                    None => continue,
                };
                for stmt in &mut entry.body {
                    let var = match stmt {
                        ModuleItem::Stmt(Stmt::Decl(Decl::Var(
                            var
                            @
                            VarDecl {
                                kind: VarDeclKind::Const,
                                ..
                            },
                        ))) => var,
                        _ => continue,
                    };
                    if var.decls.len() != 1 {
                        continue;
                    }
                    let var_decl = &mut var.decls[0];
                    match &var_decl.name {
                        Pat::Ident(i) if id == *i => {}
                        _ => continue,
                    }
                    let callee = match &mut var_decl.init {
                        Some(init) => match &mut **init {
                            Expr::Call(CallExpr { callee, .. }) => match callee {
                                ExprOrSuper::Super(_) => continue,
                                ExprOrSuper::Expr(v) => v,
                            },
                            _ => continue,
                        },
                        None => continue,
                    };
                    let f = match &mut **callee {
                        Expr::Fn(f) => f,
                        _ => continue,
                    };
                    let body = match &mut f.function.body {
                        Some(body) => body,
                        None => continue,
                    };
                    let last_stmt = body.stmts.last_mut();
                    let return_stmt = match last_stmt {
                        Some(Stmt::Return(s)) => s,
                        _ => continue,
                    };
                    let ret_val = match &mut return_stmt.arg {
                        Some(arg) => arg,
                        None => continue,
                    };
                    let obj = match &mut **ret_val {
                        Expr::Object(obj) => obj,
                        _ => continue,
                    };
                    obj.props.extend(props);
                    break;
                }
            }
        }
    }
fn handle_export_stars ( & self , ctx : & Ctx , entry : & mut Module ) { { // Handle `export *` for non-wrapped modules. let mut extra_stmts = vec ! [ ] ; for stmt in entry . body . iter ( ) { match stmt { ModuleItem :: Stmt ( Stmt :: Decl ( Decl :: Var ( decl ) ) ) => { let ids : Vec < Id > = find_ids ( decl ) ; for id in ids { if let Some ( remapped ) = ctx . transitive_remap . get ( & id . ctxt ( ) ) { let reexported = id . clone ( ) . with_ctxt ( remapped ) ; extra_stmts . push ( id . assign_to ( reexported ) . into_module_item ( " " ) , ) ; } } } _ => { } } } entry . body . extend ( extra_stmts ) ; } { let mut map = ctx . export_stars_in_wrapped . lock ( ) ; let mut additional_props = HashMap :: < _ , Vec < _ > > :: new ( ) ; // Handle `export *` for wrapped modules. for ( module_id , ctxts ) in map . drain ( ) { for stmt in entry . body . iter ( ) { match stmt { ModuleItem :: Stmt ( Stmt :: Decl ( Decl :: Var ( decl ) ) ) => { let ids : Vec < Id > = find_ids ( decl ) ; for id in ids { if ctxts . contains ( & id . ctxt ( ) ) { additional_props . entry ( module_id ) . or_default ( ) . push ( PropOrSpread :: Prop ( Box :: new ( Prop :: Shorthand ( id . into_ident ( ) , ) ) ) , ) ; } } } _ => { } } } } for ( module_id , props ) in additional_props { let id = match self . scope . wrapped_esm_id ( module_id ) { Some ( v ) => v , None => continue , } ; for stmt in & mut entry . body { let var = match stmt { ModuleItem :: Stmt ( Stmt :: Decl ( Decl :: Var ( var @ VarDecl { kind : VarDeclKind :: Const , .. } , ) ) ) => var , _ => continue , } ; if var . decls . len ( ) != 1 { continue ; } let var_decl = & mut var . decls [ 0 ] ; match & var_decl . name { Pat :: Ident ( i ) if id == * i => { } _ => continue , } let callee = match & mut var_decl . init { Some ( init ) => match & mut * * init { Expr :: Call ( CallExpr { callee , .. } ) => match callee { ExprOrSuper :: Super ( _ ) => continue , ExprOrSuper :: Expr ( v ) => v , } , _ => continue , } , None => continue , } ; let f = match & mut * * callee { Expr :: Fn ( f ) => f , _ => continue , } ; let body = match & mut f . function . body { Some ( body ) => body , None => continue , } ; let last_stmt = body . stmts . last_mut ( ) ; let return_stmt = match last_stmt { Some ( Stmt :: Return ( s ) ) => s , _ => continue , } ; let ret_val = match & mut return_stmt . arg { Some ( arg ) => arg , None => continue , } ; let obj = match & mut * * ret_val { Expr :: Object ( obj ) => obj , _ => continue , } ; obj . props . extend ( props ) ; break ; } } } }
This should only be called after everything is merged.
This should only be called after everything is merged .
&self
ctx
&Ctx
entry
&mut Module
&self
ctx
&Ctx
entry
&mut Module