Repository: denoland/deno
File: cli/tools/publish/module_content.rs (Rust)

Code before:
        "/** @jsxFactory {} */",
        jsx_options.jsx_factory,
      ));
    }
    if !leading_comments_has_re(&JSX_FRAGMENT_FACTORY_RE) {
      add_text_change(format!(
        "/** @jsxFragmentFactory {} */",
        jsx_options.jsx_fragment_factory,
      ));
    }
    Ok(())
  }

  fn resolve_jsx_options<'a>(
    &'a self,
    specifier: &Url,
    text_info: &SourceTextInfo,
    diagnostic_reporter: &mut dyn FnMut(SpecifierUnfurlerDiagnostic),
  ) -> Result<JsxFolderOptions<'a>, AnyError> {
    let compiler_options =
      self.compiler_options_resolver.for_specifier(specifier);
    let jsx_config = compiler_options.jsx_import_source_config()?;
    let transpile_options = &compiler_options.transpile_options()?.transpile;
    let jsx_runtime = if transpile_options.jsx_automatic {
      "automatic"
    } else {
      "classic"
    };
    let mut unfurl_import_source =
      |import_source: &str, referrer: &Url, resolution_kind: ResolutionKind| {
        let maybe_import_source = self
          .specifier_unfurler
          .unfurl_specifier_reporting_diagnostic(
            referrer,
            import_source,
            resolution_kind,
            text_info,
            &deno_graph::PositionRange::zeroed(),
            diagnostic_reporter,
          );
        maybe_import_source.unwrap_or_else(|| import_source.to_string())
      };
    let jsx_import_source = jsx_config
      .and_then(|c| c.import_source.as_ref())
      .map(|jsx_import_source| {
        unfurl_import_source(
          &jsx_import_source.specifier,
          &jsx_import_source.base,
          ResolutionKind::Execution,
        )
      });

Review comment (suggestion):
Using these options will be less error prone once https://github.com/denoland/deno_ast/pull/313 lands

Code after:
      add_text_change(format!(
        "/** @jsxFactory {} */",
        jsx_options.jsx_factory,
      ));
    }
    if is_classic && !leading_comments_has_re(&JSX_FRAGMENT_FACTORY_RE) {
      add_text_change(format!(
        "/** @jsxFragmentFactory {} */",
        jsx_options.jsx_fragment_factory,
      ));
    }
    Ok(())
  }

  fn resolve_jsx_options<'a>(
    &'a self,
    specifier: &Url,
    text_info: &SourceTextInfo,
    diagnostic_reporter: &mut dyn FnMut(SpecifierUnfurlerDiagnostic),
  ) -> Result<JsxFolderOptions<'a>, AnyError> {
    let compiler_options =
      self.compiler_options_resolver.for_specifier(specifier);
    let jsx_config = compiler_options.jsx_import_source_config()?;
    let transpile_options = &compiler_options.transpile_options()?.transpile;
    let jsx_runtime =
      if transpile_options.jsx_automatic || transpile_options.precompile_jsx {
        "automatic"
      } else {
        "classic"
      };
    let mut unfurl_import_source =
      |import_source: &str, referrer: &Url, resolution_kind: ResolutionKind| {
        let maybe_import_source = self
          .specifier_unfurler
          .unfurl_specifier_reporting_diagnostic(
            referrer,
            import_source,
            resolution_kind,
            text_info,
            &deno_graph::PositionRange::zeroed(),
            diagnostic_reporter,
          );
        maybe_import_source.unwrap_or_else(|| import_source.to_string())
      };
    let jsx_import_source = jsx_config
      .and_then(|c| c.import_source.as_ref())
      .map(|jsx_import_source| {
        unfurl_import_source(
          &jsx_import_source.specifier,
          &jsx_import_source.base,
          ResolutionKind::Execution,