Repository: vercel/next.js
File: turbopack/crates/turbopack-browser/src/chunking_context.rs (Rust)

Code before:

        let asset_root_path = tag
            .as_ref()
            .and_then(|tag| self.asset_root_paths.get(tag))
            .unwrap_or(&self.asset_root_path);

        Ok(asset_root_path.join(&asset_path)?.cell())
    }

    #[turbo_tasks::function]
    fn url_behavior(&self, tag: Option<RcStr>) -> Vc<UrlBehavior> {
        tag.as_ref()
            .and_then(|tag| self.url_behaviors.get(tag))
            .cloned()
            .or_else(|| self.default_url_behavior.clone())
            .unwrap_or(UrlBehavior {
                suffix: AssetSuffix::Inferred,
            })
            .cell()
    }

    #[turbo_tasks::function]
    fn css_url_suffix(&self) -> Vc<Option<RcStr>> {
        Vc::cell(self.css_url_suffix.clone())
    }

    #[turbo_tasks::function]
    fn is_hot_module_replacement_enabled(&self) -> Vc<bool> {
        Vc::cell(self.enable_hot_module_replacement)
    }

    #[turbo_tasks::function]
    fn chunking_configs(&self) -> Result<Vc<ChunkingConfigs>> {
        Ok(Vc::cell(self.chunking_configs.iter().cloned().collect()))
    }

    #[turbo_tasks::function]
    fn source_map_source_type(&self) -> Vc<SourceMapSourceType> {
        self.source_map_source_type.cell()
    }

    #[turbo_tasks::function]
    fn is_tracing_enabled(&self) -> Vc<bool> {
        Vc::cell(self.enable_tracing)
    }

    #[turbo_tasks::function]
    fn is_nested_async_availability_enabled(&self) -> Vc<bool> {
        Vc::cell(self.enable_nested_async_availability)
    }


Review comment (suggestion):
This shouldn't be a new method, but be inside of `UrlBehavior` or `AssetSuffix`
These should contain both a dynamic version (as right now, for JS, where we can compute dynamically) and a static version (for CSS where it has to be a constant string)

Code after:

    #[turbo_tasks::function]
    fn url_behavior(&self, tag: Option<RcStr>) -> Vc<UrlBehavior> {
        tag.as_ref()
            .and_then(|tag| self.url_behaviors.get(tag))
            .cloned()
            .or_else(|| self.default_url_behavior.clone())
            .unwrap_or(UrlBehavior {
                suffix: AssetSuffix::Inferred,
                static_suffix: None,
            })
            .cell()
    }

    #[turbo_tasks::function]
    fn is_hot_module_replacement_enabled(&self) -> Vc<bool> {
        Vc::cell(self.enable_hot_module_replacement)
    }

    #[turbo_tasks::function]
    fn chunking_configs(&self) -> Result<Vc<ChunkingConfigs>> {
        Ok(Vc::cell(self.chunking_configs.iter().cloned().collect()))
    }

    #[turbo_tasks::function]
    fn source_map_source_type(&self) -> Vc<SourceMapSourceType> {
        self.source_map_source_type.cell()
    }

    #[turbo_tasks::function]
    fn is_tracing_enabled(&self) -> Vc<bool> {
        Vc::cell(self.enable_tracing)
    }

    #[turbo_tasks::function]
    fn is_nested_async_availability_enabled(&self) -> Vc<bool> {
        Vc::cell(self.enable_nested_async_availability)
    }

    #[turbo_tasks::function]
    fn is_module_merging_enabled(&self) -> Vc<bool> {
        Vc::cell(self.enable_module_merging)
    }

    #[turbo_tasks::function]
    fn is_dynamic_chunk_content_loading_enabled(&self) -> Vc<bool> {
        Vc::cell(self.enable_dynamic_chunk_content_loading)
    }

    #[turbo_tasks::function]
    pub fn minify_type(&self) -> Vc<MinifyType> {