maudit_rolldown_loader_utils 0.1.0

Fork of Rolldown for the Maudit project until Rolldown is published on crates.io
Documentation
use rolldown_common::Platform;

pub fn binary_to_esm(base64: &str, platform: Platform, runtime_module_id: &str) -> String {
  let to_binary = match platform {
    Platform::Node => "__toBinaryNode",
    _ => "__toBinary",
  };
  [
    "import {",
    to_binary,
    "} from '",
    runtime_module_id,
    "'; export default ",
    to_binary,
    "('",
    base64,
    "')",
  ]
  .concat()
}