Repository: swc-project/swc
File: crates/swc_cli_impl/src/commands/compile.rs (Rust)

Code before:
                            },
                            p.1,
                        )
                    })
                    .collect()
            });

        if let Some(file_path) = *file_path {
            file_path
                .to_str()
                .unwrap_or_default()
                .clone_into(&mut options.filename);
        }

        if let Some(env_name) = &self.env_name {
            options.env_name = env_name.to_string();
        }

        if let Some(root_mode) = self.root_mode {
            options.root_mode = root_mode;
            // Enable .swcrc search for upward modes
            if matches!(root_mode, RootMode::Upward | RootMode::UpwardOptional) {
                options.swcrc = true;
            }
        }

        if let Some(source_maps) = &self.source_maps {
            options.source_maps = Some(match source_maps.as_str() {
                "false" => SourceMapsConfig::Bool(false),
                "true" => SourceMapsConfig::Bool(true),
                value => SourceMapsConfig::Str(value.to_string()),
            });

            self.source_file_name
                .clone_into(&mut options.source_file_name);
            self.source_root.clone_into(&mut options.source_root);
        }

        Ok(options)
    }

    /// Create canonical list of inputs to be processed across stdin / single
    /// file / multiple files.
    fn collect_inputs(&self) -> anyhow::Result<Vec<InputContext>> {
        let compiler = COMPILER.clone();

        if !self.files.is_empty() {
            let included_extensions = if let Some(extensions) = &self.extensions {
                extensions.clone()
            } else {
                DEFAULT_EXTENSIONS.iter().map(|v| v.to_string()).collect()

Review comment (suggestion):
Setting `swcrc = true` only for `Upward` and `UpwardOptional` modes is inconsistent with the feature's intent. The `root` mode should also enable `.swcrc` search (just not in parent directories). Consider setting `options.swcrc = true` unconditionally when `root_mode` is provided, or add a comment explaining why `root` mode doesn't need it.
```suggestion
            // Enable .swcrc search whenever a root mode is specified
            options.swcrc = true;
        }
```

Code after:
                                    path.absolutize().unwrap().display().to_string()
                                }
                                _ => p.0,
                            },
                            p.1,
                        )
                    })
                    .collect()
            });

        if let Some(file_path) = *file_path {
            file_path
                .to_str()
                .unwrap_or_default()
                .clone_into(&mut options.filename);
        }

        if let Some(env_name) = &self.env_name {
            options.env_name = env_name.to_string();
        }

        if let Some(root_mode) = self.root_mode {
            options.root_mode = root_mode;
        }

        if let Some(source_maps) = &self.source_maps {
            options.source_maps = Some(match source_maps.as_str() {
                "false" => SourceMapsConfig::Bool(false),
                "true" => SourceMapsConfig::Bool(true),
                value => SourceMapsConfig::Str(value.to_string()),
            });

            self.source_file_name
                .clone_into(&mut options.source_file_name);
            self.source_root.clone_into(&mut options.source_root);
        }

        Ok(options)
    }

    /// Create canonical list of inputs to be processed across stdin / single
    /// file / multiple files.
    fn collect_inputs(&self) -> anyhow::Result<Vec<InputContext>> {
        let compiler = COMPILER.clone();

        if !self.files.is_empty() {
            let included_extensions = if let Some(extensions) = &self.extensions {
                extensions.clone()
            } else {
                DEFAULT_EXTENSIONS.iter().map(|v| v.to_string()).collect()
            };