Targets by default, as in the docs, are strings like "pino/file" or "pino-pretty". This implicitly requires any package using these transports to have this NPM package installed in the correct way, and any bundling they do to keep this pattern.
There are existing tools like depcheck that can analyze source code to find that all dependencies used are actually installed, and can warn against dependencies that are not installed. However, depcheck doesn't work in this case since these imports are dynamic.
To take advantage of existing static analysis tools it'd be nice if Pino transports were not named by an arbitrary string, but rather some interface that the transport library could export, and pino could expect.
For example:
import { pino } from "pino"l
import { pinoPretty } from "pino-pretty";
pino(pino.transport({
targets: [
{ target: pinoPretty, level: 'info', options: { destination: 1 }
],
}));
and in this way, analysis tools would find usages of transports that aren't installed, and it's obvious to users that these transports need to be installed.
So it'd be nice for target to be type string | PinoTarget or something, where PinoTarget might be:
export type PinoTarget = {
name: string;
}
Targets by default, as in the docs, are strings like
"pino/file"or"pino-pretty". This implicitly requires any package using these transports to have this NPM package installed in the correct way, and any bundling they do to keep this pattern.There are existing tools like depcheck that can analyze source code to find that all dependencies used are actually installed, and can warn against dependencies that are not installed. However,
depcheckdoesn't work in this case since these imports are dynamic.To take advantage of existing static analysis tools it'd be nice if Pino transports were not named by an arbitrary string, but rather some interface that the transport library could export, and
pinocould expect.For example:
and in this way, analysis tools would find usages of transports that aren't installed, and it's obvious to users that these transports need to be installed.
So it'd be nice for
targetto be typestring | PinoTargetor something, wherePinoTargetmight be: