rspack_core 0.100.0-rc.3

rspack core
Documentation
use cow_utils::CowUtils;

#[inline]
pub fn to_comment(str: &str) -> String {
  if str.is_empty() {
    return String::new();
  }

  let result = str.cow_replace("*/", "* /");
  format!("/*! {result} */")
}

#[inline]
pub fn to_comment_with_nl(str: &str) -> String {
  if str.is_empty() {
    return String::new();
  }

  let result = str.cow_replace("*/", "* /");
  format!("/*! {result} */\n")
}