localhostL
Deno11mo ago
localhost

Compiled Deno project can't import typescript code

Does Deno compile remove its ability to import typescript code? This only work in deno run, but fails on the deno compile bynary

async function importjs(js: string, filename = "importedjs") {
  const dataUri =
    "data:text/typescript;charset=utf-8," +
    encodeURIComponent(js) +
    `//# sourceURL=${filename}.ts;`;
  const r = await import(dataUri);
  return r;
}

console.log(
  (await importjs(`export default () => "hello world" as any`)).default()
);
Was this page helpful?