`.extend` is undefined in cloudflare workers
Why browser version doesnt contain .extend method? It easily make package incompatible with the browser/serverless (Related https://github.com/gramiojs/gramio/issues/10)
As a workaround i switch from .extend to just createDebugger('some:1:2:3')
Which browser? Which version?
How are you using the code?
Which browser? Which version?
How are you using the code?
There is no need to mention which browser Debug module has a browser export which misses .extend function (but @types/debug and common js export has it)
About using u can see the referenced commit
https://github.com/gramiojs/gramio/issues/10
First it is reproduced on serverless environments such as cloudflare workers (which depends on browsers exports because of nature)
This is a fix: https://github.com/gramiojs/gramio/commit/1f0636b5fe8fed275ae10ff661f63b2901f1b665 Just remove .extend usage which works in node/bun and other serverside runtimes but it missed in browser export
@kravetsone what makes you think the browser version doesn't contain an .extend method?
- starts with
setup(env)https://github.com/debug-js/debug/blob/master/src/browser.js#L258 - common.js only export is this
setupfactory, which returnscreateDebug - the
createDebugfactory places the extend method on the debug factory
import debug from 'debug';
...
declare global {
interface Window {
logger: ReturnType<typeof debug>;
}
}
export default function RouteComponent() {
window.logger = debug("Root");
...
@kravetsone what makes you think the browser version doesn't contain an
.extendmethod?
- starts with
setup(env)https://github.com/debug-js/debug/blob/master/src/browser.js#L258- common.js only export is this
setupfactory, which returnscreateDebug- the
createDebugfactory places the extend method on the debug factoryimport debug from 'debug'; ... declare global { interface Window { logger: ReturnType<typeof debug>; } } export default function RouteComponent() { window.logger = debug("Root"); ...
Okay I really miss it
But idk why it didn't exists in cf workers
Ran into this a couple times lately using nitropack to build the worker bundle. If you externalize debug it works fine. Perhaps nitro is mangling it somehow?