vike
Version:
The Framework *You* Control - Next.js & Nuxt alternative for unprecedented flexibility and dependability.
22 lines (21 loc) • 785 B
JavaScript
export { debug };
export { setCreateDebugger };
// Using createDebugger() for isomorphic code without bloating the client-side.
// On the server-side, this is just a transparent proxy.
// On the client-side, this is an empty shell.
import { getGlobalObject } from '../../utils/getGlobalObject.js';
const globalObject = getGlobalObject('route/debug.ts', {});
function debug(...args) {
// Client-side => does nothing
if (!globalObject.createDebugger)
return;
// Server-side => just a proxy
if (!globalObject.debug) {
globalObject.debug = globalObject.createDebugger('vike:routing');
}
globalObject.debug(...args);
}
// Called only on the server-side
function setCreateDebugger(createDebugger) {
globalObject.createDebugger = createDebugger;
}