import
import copied to clipboard
getCallerUrl fallback to avoid invalid URL error
I have encountered following error while running example from unit as compiled executable
error: Uncaught (in promise) TypeError: Invalid URL: 'undefined'
at <anonymous> (ext:deno_url/00_url.js:89:11)
To reproduce, create sep28.ts
import { dynamicImport, importString } from './mod.ts';
const { default: renderer } = await importString(
`export default async function () {
const { render } = await dynamicImport('https://deno.land/x/[email protected]/mustache.ts');
const template = '{{foo}}, {{bar}}!'
const view = {
foo: 'Hello',
bar: 'World!'
}
const output = render(template, view)
return output;
};`,
{ parameters: { dynamicImport } },
);
console.log(await renderer());
Then compile
deno compile --allow-all --unstable --no-check sep28.ts