brk_rolldown_loader_utils 0.0.1

brk fork of rolldown_loader_utils
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()
}