Repository: swc-project/swc
File: crates/swc_ecma_lexer/src/common/parser/module_item.rs (Rust)

Code before:
                    || peek!(p).is_some_and(|cur| cur.is_from())
                {
                    // For defer phase, we expect only namespace imports, so break here
                    // and let the subsequent code handle validation
                    if new_phase == ImportPhase::Defer {
                        break 'import_maybe_ident;
                    }
                    phase = new_phase;
                    local = parse_imported_default_binding(p)?;
                }
            }

            //TODO: Better error reporting
            if !p.input_mut().is(&P::Token::FROM) {
                expect!(p, &P::Token::COMMA);
            }
            specifiers.push(ImportSpecifier::Default(ImportDefaultSpecifier {
                span: local.span,
                local,
            }));
        }
    }

    {
        let import_spec_start = p.cur_pos();
        // Nmesapce imports are not allowed in source phase.
        if phase != ImportPhase::Source && p.input_mut().eat(&P::Token::MUL) {
            expect!(p, &P::Token::AS);
            let local = parse_imported_binding(p)?;
            specifiers.push(ImportSpecifier::Namespace(ImportStarAsSpecifier {
                span: p.span(import_spec_start),
                local,
            }));
            // Named imports are only allowed in evaluation phase.
        } else if phase == ImportPhase::Evaluation && p.input_mut().eat(&P::Token::LBRACE) {
            while !eof!(p) && !p.input_mut().is(&P::Token::RBRACE) {
                specifiers.push(parse_import_specifier(p, type_only)?);

                if p.input_mut().is(&P::Token::RBRACE) {
                    break;
                } else {
                    expect!(p, &P::Token::COMMA);
                }
            }
            expect!(p, &P::Token::RBRACE);
        }
    }

    let src = {
        expect!(p, &P::Token::FROM);
        if p.input_mut().cur().is_some_and(|cur| cur.is_str()) {

Review comment (suggestion):
There is a typo in the comment. 'Nmesapce' should be 'Namespace'.
```suggestion
        // Namespace imports are not allowed in source phase.
```

Code after:
                    || peek!(p).is_some_and(|cur| cur.is_from())
                {
                    // For defer phase, we expect only namespace imports, so break here
                    // and let the subsequent code handle validation
                    if new_phase == ImportPhase::Defer {
                        break 'import_maybe_ident;
                    }
                    phase = new_phase;
                    local = parse_imported_default_binding(p)?;
                }
            }

            //TODO: Better error reporting
            if !p.input_mut().is(&P::Token::FROM) {
                expect!(p, &P::Token::COMMA);
            }
            specifiers.push(ImportSpecifier::Default(ImportDefaultSpecifier {
                span: local.span,
                local,
            }));
        }
    }

    {
        let import_spec_start = p.cur_pos();
        // Namespace imports are not allowed in source phase.
        if phase != ImportPhase::Source && p.input_mut().eat(&P::Token::MUL) {
            expect!(p, &P::Token::AS);
            let local = parse_imported_binding(p)?;
            specifiers.push(ImportSpecifier::Namespace(ImportStarAsSpecifier {
                span: p.span(import_spec_start),
                local,
            }));
            // Named imports are only allowed in evaluation phase.
        } else if phase == ImportPhase::Evaluation && p.input_mut().eat(&P::Token::LBRACE) {
            while !eof!(p) && !p.input_mut().is(&P::Token::RBRACE) {
                specifiers.push(parse_import_specifier(p, type_only)?);

                if p.input_mut().is(&P::Token::RBRACE) {
                    break;
                } else {
                    expect!(p, &P::Token::COMMA);
                }
            }
            expect!(p, &P::Token::RBRACE);
        }
    }

    let src = {
        expect!(p, &P::Token::FROM);
        if p.input_mut().cur().is_some_and(|cur| cur.is_str()) {