Repository: swc-project/swc
File: crates/swc/src/config/mod.rs (Rust)

Code before:
            }
        };

        let is_mangler_enabled = js_minify
            .as_ref()
            .map(|v| v.mangle.is_obj() || v.mangle.is_true())
            .unwrap_or(false);

        let rewrite_import_pass = {
            let swc_import_rewriter = match resolver.clone() {
                Some((base, resolver)) => match cfg.module {
                    None | Some(ModuleConfig::Es6(..)) | Some(ModuleConfig::NodeNext(..)) => {
                        Box::new(import_rewriter(base, resolver)) as Box<dyn Pass>
                    }
                    _ => Box::new(noop_pass()),
                },
                None => Box::new(noop_pass()),
            };

            let typescript_import_rewriter = Optional::new(
                rewriter::typescript_import_rewriter(),
                rewrite_relative_import_extensions.into_bool(),
            );

            // swc_import_rewriter should be in front of typescript_import_rewriter
            // because typescript_import_rewriter only works without path alias
            (swc_import_rewriter, typescript_import_rewriter)
        };

        let built_pass = (
            pass,
            Optional::new(
                paren_remover(comments.map(|v| v as &dyn Comments)),
                fixer_enabled,
            ),
            compat_pass,
            // module / helper
            Optional::new(
                modules::import_analysis::import_analyzer(import_interop, ignore_dynamic),
                need_analyzer,
            ),
            // Rewrite import pass should be before inject_helpers pass because typescript import
            // rewriter may require ts_rewrite_relative_import_extension helper
            rewrite_import_pass,
            Optional::new(helpers::inject_helpers(unresolved_mark), inject_helpers),
            ModuleConfig::build(
                cm.clone(),
                comments.map(|v| v as &dyn Comments),
                cfg.module,
                unresolved_mark,
                resolver.clone(),

Review comment (suggestion):
The comment states that "typescript_import_rewriter only works without path alias", which is misleading. Based on the PR description and test cases, the correct behavior is that swc_import_rewriter should resolve path aliases first, and then typescript_import_rewriter can rewrite the resolved paths. Consider rephrasing to: "because path aliases should be resolved before rewriting relative import extensions".
```suggestion
            // because path aliases should be resolved before rewriting relative import extensions
```

Code after:
            }
        };

        let is_mangler_enabled = js_minify
            .as_ref()
            .map(|v| v.mangle.is_obj() || v.mangle.is_true())
            .unwrap_or(false);

        let rewrite_import_pass = {
            let swc_import_rewriter = match resolver.clone() {
                Some((base, resolver)) => match cfg.module {
                    None | Some(ModuleConfig::Es6(..)) | Some(ModuleConfig::NodeNext(..)) => {
                        Box::new(import_rewriter(base, resolver)) as Box<dyn Pass>
                    }
                    _ => Box::new(noop_pass()),
                },
                None => Box::new(noop_pass()),
            };

            let typescript_import_rewriter = Optional::new(
                rewriter::typescript_import_rewriter(),
                rewrite_relative_import_extensions.into_bool(),
            );

            // swc_import_rewriter should be in front of typescript_import_rewriter
            // because path aliases should be resolved before rewriting relative import
            // extensions
            (swc_import_rewriter, typescript_import_rewriter)
        };

        let built_pass = (
            pass,
            Optional::new(
                paren_remover(comments.map(|v| v as &dyn Comments)),
                fixer_enabled,
            ),
            compat_pass,
            // module / helper
            Optional::new(
                modules::import_analysis::import_analyzer(import_interop, ignore_dynamic),
                need_analyzer,
            ),
            // Rewrite import pass should be before inject_helpers pass because typescript import
            // rewriter may require ts_rewrite_relative_import_extension helper
            rewrite_import_pass,
            Optional::new(helpers::inject_helpers(unresolved_mark), inject_helpers),
            ModuleConfig::build(
                cm.clone(),
                comments.map(|v| v as &dyn Comments),
                cfg.module,
                unresolved_mark,