deno_console not being properly instantiated?

Not sure if it's indended, or if I am missing a step, but several core extensions, for example the deno_console crate, do not: - specify an entrypoint for esm, leading to a panic on startup - add their APIs to window or global, making them inert by default In my implementation I've had to include a small extension of my own along-side console that does the following:
import { Console } from 'ext:deno_console/01_console.js'; // If nothing imports this file, the runtime will panic
const core = globalThis.Deno.core;
globalThis.console = new Console((msg, level) => core.print(msg, level > 1)); // The console never actually gets built so let's do that
import { Console } from 'ext:deno_console/01_console.js'; // If nothing imports this file, the runtime will panic
const core = globalThis.Deno.core;
globalThis.console = new Console((msg, level) => core.print(msg, level > 1)); // The console never actually gets built so let's do that
So my question; is that intended behaviour? Or did I miss a step somewhere
4 Replies
Andreu Botella (they/them)
about the second point, deno_console doesn't actually add any APIs to the global rather, V8 ships with a default console built-in that doesn't print to stdout but instead sends the logs to devtools
baphomet_the_traveller
Oh! Ok so that snippet is the correct way to redirect it to deno_console and proper output?
baphomet_the_traveller
Ok sweet. And since that's needed anyway the import thing doesn't matter either Thanks!