You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I love debug's simplicity, but it bugs me that it is so tightly coupled to environment variables (NodeJS impl)
I would like to integrate it in Metalsmith along with an abstraction of env.
Basically, as soon as a package where debug is used, is require'd, or perhaps with some NPM-derivatives, if multiple packages use the same version, debug reads its defaults from the environment.
constpkgContainingDebug=require('pkg-with-debug')// debug config set according to DEBUG_COLORS= (not defined)process.env.DEBUG_COLORS=falseconstlocalDebug=require('debug')// debug config takes into account dynamically set process.env.DEBUG_COLORSconstlocalDebugger=localDebug('app')// nothing happens here config-wiselocalDebugger('Hello world')pkgContainingDebug()// different config from localDebugger
This makes it impossible (in my case for metalsmith) to provide a user with a programmatic way of setting debug values, unless the current package + all its dependencies use the same debug dependency (other typical use case: expressjs)
If the env reading was done at debugger creation instead of require, this would provide a window to decouple the tight coupling of debug configuration and env vars across debug dependencies
constpkgContainingDebug=require('pkg-with-debug')// debug config not initialized unless dependency instantiates it at inclusionconstlocalDebug=require('debug')// does nothing yetprocess.env.DEBUG_COLORS=falseconstlocalDebugger=localDebug('app')// reads in envlocalDebugger('Hello world')pkgContainingDebug()// same config as localDebugger if the dependency's debugger only happens when the dep is first run
Hope this makes sense.
I haven't had the time to dive into the codebase for this yet
The text was updated successfully, but these errors were encountered:
Yeah makes sense, it's definitely a drawback. The next major version was planned to change a lot of this with full backwards compatibility but with the shifting loader system in Node a lot of the plans have been tabled until the ESM loaders reach parity.
I don't really have a great answer for you right now, unfortunately :/
I love debug's simplicity, but it bugs me that it is so tightly coupled to environment variables (NodeJS impl)
I would like to integrate it in Metalsmith along with an abstraction of
env
.Basically, as soon as a package where debug is used, is
require
'd, or perhaps with some NPM-derivatives, if multiple packages use the same version, debug reads its defaults from the environment.This makes it impossible (in my case for metalsmith) to provide a user with a programmatic way of setting debug values, unless the current package + all its dependencies use the same debug dependency (other typical use case: expressjs)
If the env reading was done at debugger creation instead of require, this would provide a window to decouple the tight coupling of debug configuration and env vars across debug dependencies
Hope this makes sense.
I haven't had the time to dive into the codebase for this yet
The text was updated successfully, but these errors were encountered: