esbuild-plugin-pino
Advanced tools
Comparing version 1.2.8 to 1.3.0
@@ -1,82 +0,82 @@ | ||
type Platform = 'browser' | 'node' | 'neutral'; | ||
type Format = 'iife' | 'cjs' | 'esm'; | ||
type Loader = 'base64' | 'binary' | 'copy' | 'css' | 'dataurl' | 'default' | 'empty' | 'file' | 'js' | 'json' | 'jsx' | 'text' | 'ts' | 'tsx'; | ||
type LogLevel = 'verbose' | 'debug' | 'info' | 'warning' | 'error' | 'silent'; | ||
type Charset = 'ascii' | 'utf8'; | ||
type Drop = 'console' | 'debugger'; | ||
type Platform = 'browser' | 'node' | 'neutral' | ||
type Format = 'iife' | 'cjs' | 'esm' | ||
type Loader = 'base64' | 'binary' | 'copy' | 'css' | 'dataurl' | 'default' | 'empty' | 'file' | 'js' | 'json' | 'jsx' | 'text' | 'ts' | 'tsx' | ||
type LogLevel = 'verbose' | 'debug' | 'info' | 'warning' | 'error' | 'silent' | ||
type Charset = 'ascii' | 'utf8' | ||
type Drop = 'console' | 'debugger' | ||
interface CommonOptions { | ||
/** Documentation: https://esbuild.github.io/api/#sourcemap */ | ||
sourcemap?: boolean | 'linked' | 'inline' | 'external' | 'both'; | ||
sourcemap?: boolean | 'linked' | 'inline' | 'external' | 'both' | ||
/** Documentation: https://esbuild.github.io/api/#legal-comments */ | ||
legalComments?: 'none' | 'inline' | 'eof' | 'linked' | 'external'; | ||
legalComments?: 'none' | 'inline' | 'eof' | 'linked' | 'external' | ||
/** Documentation: https://esbuild.github.io/api/#source-root */ | ||
sourceRoot?: string; | ||
sourceRoot?: string | ||
/** Documentation: https://esbuild.github.io/api/#sources-content */ | ||
sourcesContent?: boolean; | ||
sourcesContent?: boolean | ||
/** Documentation: https://esbuild.github.io/api/#format */ | ||
format?: Format; | ||
format?: Format | ||
/** Documentation: https://esbuild.github.io/api/#global-name */ | ||
globalName?: string; | ||
globalName?: string | ||
/** Documentation: https://esbuild.github.io/api/#target */ | ||
target?: string | string[]; | ||
target?: string | string[] | ||
/** Documentation: https://esbuild.github.io/api/#supported */ | ||
supported?: Record<string, boolean>; | ||
supported?: Record<string, boolean> | ||
/** Documentation: https://esbuild.github.io/api/#platform */ | ||
platform?: Platform; | ||
platform?: Platform | ||
/** Documentation: https://esbuild.github.io/api/#mangle-props */ | ||
mangleProps?: RegExp; | ||
mangleProps?: RegExp | ||
/** Documentation: https://esbuild.github.io/api/#mangle-props */ | ||
reserveProps?: RegExp; | ||
reserveProps?: RegExp | ||
/** Documentation: https://esbuild.github.io/api/#mangle-props */ | ||
mangleQuoted?: boolean; | ||
mangleQuoted?: boolean | ||
/** Documentation: https://esbuild.github.io/api/#mangle-props */ | ||
mangleCache?: Record<string, string | false>; | ||
mangleCache?: Record<string, string | false> | ||
/** Documentation: https://esbuild.github.io/api/#drop */ | ||
drop?: Drop[]; | ||
drop?: Drop[] | ||
/** Documentation: https://esbuild.github.io/api/#minify */ | ||
minify?: boolean; | ||
minify?: boolean | ||
/** Documentation: https://esbuild.github.io/api/#minify */ | ||
minifyWhitespace?: boolean; | ||
minifyWhitespace?: boolean | ||
/** Documentation: https://esbuild.github.io/api/#minify */ | ||
minifyIdentifiers?: boolean; | ||
minifyIdentifiers?: boolean | ||
/** Documentation: https://esbuild.github.io/api/#minify */ | ||
minifySyntax?: boolean; | ||
minifySyntax?: boolean | ||
/** Documentation: https://esbuild.github.io/api/#charset */ | ||
charset?: Charset; | ||
charset?: Charset | ||
/** Documentation: https://esbuild.github.io/api/#tree-shaking */ | ||
treeShaking?: boolean; | ||
treeShaking?: boolean | ||
/** Documentation: https://esbuild.github.io/api/#ignore-annotations */ | ||
ignoreAnnotations?: boolean; | ||
ignoreAnnotations?: boolean | ||
/** Documentation: https://esbuild.github.io/api/#jsx */ | ||
jsx?: 'transform' | 'preserve' | 'automatic'; | ||
jsx?: 'transform' | 'preserve' | 'automatic' | ||
/** Documentation: https://esbuild.github.io/api/#jsx-factory */ | ||
jsxFactory?: string; | ||
jsxFactory?: string | ||
/** Documentation: https://esbuild.github.io/api/#jsx-fragment */ | ||
jsxFragment?: string; | ||
jsxFragment?: string | ||
/** Documentation: https://esbuild.github.io/api/#jsx-import-source */ | ||
jsxImportSource?: string; | ||
jsxImportSource?: string | ||
/** Documentation: https://esbuild.github.io/api/#jsx-development */ | ||
jsxDev?: boolean; | ||
jsxDev?: boolean | ||
/** Documentation: https://esbuild.github.io/api/#jsx-side-effects */ | ||
jsxSideEffects?: boolean; | ||
jsxSideEffects?: boolean | ||
/** Documentation: https://esbuild.github.io/api/#define */ | ||
define?: { [key: string]: string }; | ||
define?: { [key: string]: string } | ||
/** Documentation: https://esbuild.github.io/api/#pure */ | ||
pure?: string[]; | ||
pure?: string[] | ||
/** Documentation: https://esbuild.github.io/api/#keep-names */ | ||
keepNames?: boolean; | ||
keepNames?: boolean | ||
/** Documentation: https://esbuild.github.io/api/#color */ | ||
color?: boolean; | ||
color?: boolean | ||
/** Documentation: https://esbuild.github.io/api/#log-level */ | ||
logLevel?: LogLevel; | ||
logLevel?: LogLevel | ||
/** Documentation: https://esbuild.github.io/api/#log-limit */ | ||
logLimit?: number; | ||
logLimit?: number | ||
/** Documentation: https://esbuild.github.io/api/#log-override */ | ||
logOverride?: Record<string, LogLevel>; | ||
logOverride?: Record<string, LogLevel> | ||
} | ||
@@ -86,84 +86,76 @@ | ||
/** Documentation: https://esbuild.github.io/api/#bundle */ | ||
bundle?: boolean; | ||
bundle?: boolean | ||
/** Documentation: https://esbuild.github.io/api/#splitting */ | ||
splitting?: boolean; | ||
splitting?: boolean | ||
/** Documentation: https://esbuild.github.io/api/#preserve-symlinks */ | ||
preserveSymlinks?: boolean; | ||
preserveSymlinks?: boolean | ||
/** Documentation: https://esbuild.github.io/api/#outfile */ | ||
outfile?: string; | ||
outfile?: string | ||
/** Documentation: https://esbuild.github.io/api/#metafile */ | ||
metafile?: boolean; | ||
metafile?: boolean | ||
/** Documentation: https://esbuild.github.io/api/#outdir */ | ||
outdir?: string; | ||
outdir?: string | ||
/** Documentation: https://esbuild.github.io/api/#outbase */ | ||
outbase?: string; | ||
outbase?: string | ||
/** Documentation: https://esbuild.github.io/api/#external */ | ||
external?: string[]; | ||
external?: string[] | ||
/** Documentation: https://esbuild.github.io/api/#packages */ | ||
packages?: 'external'; | ||
packages?: 'external' | ||
/** Documentation: https://esbuild.github.io/api/#alias */ | ||
alias?: Record<string, string>; | ||
alias?: Record<string, string> | ||
/** Documentation: https://esbuild.github.io/api/#loader */ | ||
loader?: { [ext: string]: Loader }; | ||
loader?: { [ext: string]: Loader } | ||
/** Documentation: https://esbuild.github.io/api/#resolve-extensions */ | ||
resolveExtensions?: string[]; | ||
resolveExtensions?: string[] | ||
/** Documentation: https://esbuild.github.io/api/#main-fields */ | ||
mainFields?: string[]; | ||
mainFields?: string[] | ||
/** Documentation: https://esbuild.github.io/api/#conditions */ | ||
conditions?: string[]; | ||
conditions?: string[] | ||
/** Documentation: https://esbuild.github.io/api/#write */ | ||
write?: boolean; | ||
write?: boolean | ||
/** Documentation: https://esbuild.github.io/api/#allow-overwrite */ | ||
allowOverwrite?: boolean; | ||
allowOverwrite?: boolean | ||
/** Documentation: https://esbuild.github.io/api/#tsconfig */ | ||
tsconfig?: string; | ||
tsconfig?: string | ||
/** Documentation: https://esbuild.github.io/api/#out-extension */ | ||
outExtension?: { [ext: string]: string }; | ||
outExtension?: { [ext: string]: string } | ||
/** Documentation: https://esbuild.github.io/api/#public-path */ | ||
publicPath?: string; | ||
publicPath?: string | ||
/** Documentation: https://esbuild.github.io/api/#entry-names */ | ||
entryNames?: string; | ||
entryNames?: string | ||
/** Documentation: https://esbuild.github.io/api/#chunk-names */ | ||
chunkNames?: string; | ||
chunkNames?: string | ||
/** Documentation: https://esbuild.github.io/api/#asset-names */ | ||
assetNames?: string; | ||
assetNames?: string | ||
/** Documentation: https://esbuild.github.io/api/#inject */ | ||
inject?: string[]; | ||
inject?: string[] | ||
/** Documentation: https://esbuild.github.io/api/#banner */ | ||
banner?: { [type: string]: string }; | ||
banner?: { [type: string]: string } | ||
/** Documentation: https://esbuild.github.io/api/#footer */ | ||
footer?: { [type: string]: string }; | ||
/** Documentation: https://esbuild.github.io/api/#incremental */ | ||
incremental?: boolean; | ||
footer?: { [type: string]: string } | ||
/** Documentation: https://esbuild.github.io/api/#entry-points */ | ||
entryPoints?: string[] | Record<string, string>; | ||
entryPoints?: string[] | Record<string, string> | { in: string, out: string }[] | ||
/** Documentation: https://esbuild.github.io/api/#stdin */ | ||
stdin?: StdinOptions; | ||
stdin?: StdinOptions | ||
/** Documentation: https://esbuild.github.io/plugins/ */ | ||
plugins?: Plugin[]; | ||
plugins?: Plugin[] | ||
/** Documentation: https://esbuild.github.io/api/#working-directory */ | ||
absWorkingDir?: string; | ||
absWorkingDir?: string | ||
/** Documentation: https://esbuild.github.io/api/#node-paths */ | ||
nodePaths?: string[]; // The "NODE_PATH" variable from Node.js | ||
/** Documentation: https://esbuild.github.io/api/#watch */ | ||
watch?: boolean | WatchMode; | ||
} | ||
interface WatchMode { | ||
onRebuild?: (error: BuildFailure | null, result: BuildResult | null) => void; | ||
} | ||
interface StdinOptions { | ||
contents: string | Uint8Array; | ||
resolveDir?: string; | ||
sourcefile?: string; | ||
loader?: Loader; | ||
contents: string | Uint8Array | ||
resolveDir?: string | ||
sourcefile?: string | ||
loader?: Loader | ||
} | ||
interface Message { | ||
id: string; | ||
pluginName: string; | ||
text: string; | ||
location: Location | null; | ||
notes: Note[]; | ||
id: string | ||
pluginName: string | ||
text: string | ||
location: Location | null | ||
notes: Note[] | ||
@@ -174,75 +166,59 @@ /** | ||
*/ | ||
detail: any; | ||
detail: any | ||
} | ||
interface Note { | ||
text: string; | ||
location: Location | null; | ||
text: string | ||
location: Location | null | ||
} | ||
interface Location { | ||
file: string; | ||
namespace: string; | ||
file: string | ||
namespace: string | ||
/** 1-based */ | ||
line: number; | ||
line: number | ||
/** 0-based, in bytes */ | ||
column: number; | ||
column: number | ||
/** in bytes */ | ||
length: number; | ||
lineText: string; | ||
suggestion: string; | ||
length: number | ||
lineText: string | ||
suggestion: string | ||
} | ||
interface OutputFile { | ||
path: string; | ||
path: string | ||
/** "text" as bytes */ | ||
contents: Uint8Array; | ||
contents: Uint8Array | ||
/** "contents" as text (changes automatically with "contents") */ | ||
get text(): string; | ||
readonly text: string | ||
} | ||
interface BuildInvalidate { | ||
(): Promise<BuildIncremental>; | ||
dispose(): void; | ||
} | ||
interface BuildIncremental extends BuildResult { | ||
rebuild: BuildInvalidate; | ||
} | ||
interface BuildResult { | ||
errors: Message[]; | ||
warnings: Message[]; | ||
interface BuildResult<SpecificOptions extends BuildOptions = BuildOptions> { | ||
errors: Message[] | ||
warnings: Message[] | ||
/** Only when "write: false" */ | ||
outputFiles?: OutputFile[]; | ||
/** Only when "incremental: true" */ | ||
rebuild?: BuildInvalidate; | ||
/** Only when "watch: true" */ | ||
stop?: () => void; | ||
outputFiles: OutputFile[] | (SpecificOptions['write'] extends false ? never : undefined) | ||
/** Only when "metafile: true" */ | ||
metafile?: Metafile; | ||
metafile: Metafile | (SpecificOptions['metafile'] extends true ? never : undefined) | ||
/** Only when "mangleCache" is present */ | ||
mangleCache?: Record<string, string | false>; | ||
mangleCache: Record<string, string | false> | (SpecificOptions['mangleCache'] extends Object ? never : undefined) | ||
} | ||
interface BuildFailure extends Error { | ||
errors: Message[]; | ||
warnings: Message[]; | ||
} | ||
/** Documentation: https://esbuild.github.io/api/#serve-arguments */ | ||
interface ServeOptions { | ||
port?: number; | ||
host?: string; | ||
servedir?: string; | ||
onRequest?: (args: ServeOnRequestArgs) => void; | ||
port?: number | ||
host?: string | ||
servedir?: string | ||
keyfile?: string | ||
certfile?: string | ||
onRequest?: (args: ServeOnRequestArgs) => void | ||
} | ||
interface ServeOnRequestArgs { | ||
remoteAddress: string; | ||
method: string; | ||
path: string; | ||
status: number; | ||
remoteAddress: string | ||
method: string | ||
path: string | ||
status: number | ||
/** The time to generate the response, not to send it */ | ||
timeInMS: number; | ||
timeInMS: number | ||
} | ||
@@ -252,6 +228,4 @@ | ||
interface ServeResult { | ||
port: number; | ||
host: string; | ||
wait: Promise<void>; | ||
stop: () => void; | ||
port: number | ||
host: string | ||
} | ||
@@ -272,41 +246,54 @@ | ||
}, | ||
}; | ||
} | ||
sourcefile?: string; | ||
loader?: Loader; | ||
banner?: string; | ||
footer?: string; | ||
sourcefile?: string | ||
loader?: Loader | ||
banner?: string | ||
footer?: string | ||
} | ||
interface TransformResult { | ||
code: string; | ||
map: string; | ||
warnings: Message[]; | ||
interface TransformResult<SpecificOptions extends TransformOptions = TransformOptions> { | ||
code: string | ||
map: string | ||
warnings: Message[] | ||
/** Only when "mangleCache" is present */ | ||
mangleCache?: Record<string, string | false>; | ||
mangleCache: Record<string, string | false> | (SpecificOptions['mangleCache'] extends Object ? never : undefined) | ||
/** Only when "legalComments" is "external" */ | ||
legalComments?: string; | ||
legalComments: string | (SpecificOptions['legalComments'] extends 'external' ? never : undefined) | ||
} | ||
interface Plugin { | ||
name: string; | ||
setup: (build: PluginBuild) => (void | Promise<void>); | ||
name: string | ||
setup: (build: PluginBuild) => (void | Promise<void>) | ||
} | ||
interface PluginBuild { | ||
initialOptions: BuildOptions; | ||
resolve(path: string, options?: ResolveOptions): Promise<ResolveResult>; | ||
/** Documentation: https://esbuild.github.io/plugins/#build-options */ | ||
initialOptions: BuildOptions | ||
/** Documentation: https://esbuild.github.io/plugins/#resolve */ | ||
resolve(path: string, options?: ResolveOptions): Promise<ResolveResult> | ||
/** Documentation: https://esbuild.github.io/plugins/#on-start */ | ||
onStart(callback: () => | ||
(OnStartResult | null | void | Promise<OnStartResult | null | void>)): void; | ||
(OnStartResult | null | void | Promise<OnStartResult | null | void>)): void | ||
/** Documentation: https://esbuild.github.io/plugins/#on-end */ | ||
onEnd(callback: (result: BuildResult) => | ||
(void | Promise<void>)): void; | ||
(OnEndResult | null | void | Promise<OnEndResult | null | void>)): void | ||
/** Documentation: https://esbuild.github.io/plugins/#on-resolve */ | ||
onResolve(options: OnResolveOptions, callback: (args: OnResolveArgs) => | ||
(OnResolveResult | null | undefined | Promise<OnResolveResult | null | undefined>)): void; | ||
(OnResolveResult | null | undefined | Promise<OnResolveResult | null | undefined>)): void | ||
/** Documentation: https://esbuild.github.io/plugins/#on-load */ | ||
onLoad(options: OnLoadOptions, callback: (args: OnLoadArgs) => | ||
(OnLoadResult | null | undefined | Promise<OnLoadResult | null | undefined>)): void; | ||
(OnLoadResult | null | undefined | Promise<OnLoadResult | null | undefined>)): void | ||
/** Documentation: https://esbuild.github.io/plugins/#on-dispose */ | ||
onDispose(callback: () => void): void | ||
// This is a full copy of the esbuild library in case you need it | ||
esbuild: { | ||
serve: typeof serve, | ||
context: typeof context, | ||
build: typeof build, | ||
@@ -322,43 +309,52 @@ buildSync: typeof buildSync, | ||
version: typeof version, | ||
}; | ||
} | ||
} | ||
/** Documentation: https://esbuild.github.io/plugins/#resolve-options */ | ||
interface ResolveOptions { | ||
pluginName?: string; | ||
importer?: string; | ||
namespace?: string; | ||
resolveDir?: string; | ||
kind?: ImportKind; | ||
pluginData?: any; | ||
pluginName?: string | ||
importer?: string | ||
namespace?: string | ||
resolveDir?: string | ||
kind?: ImportKind | ||
pluginData?: any | ||
} | ||
/** Documentation: https://esbuild.github.io/plugins/#resolve-results */ | ||
interface ResolveResult { | ||
errors: Message[]; | ||
warnings: Message[]; | ||
errors: Message[] | ||
warnings: Message[] | ||
path: string; | ||
external: boolean; | ||
sideEffects: boolean; | ||
namespace: string; | ||
suffix: string; | ||
pluginData: any; | ||
path: string | ||
external: boolean | ||
sideEffects: boolean | ||
namespace: string | ||
suffix: string | ||
pluginData: any | ||
} | ||
interface OnStartResult { | ||
errors?: PartialMessage[]; | ||
warnings?: PartialMessage[]; | ||
errors?: PartialMessage[] | ||
warnings?: PartialMessage[] | ||
} | ||
interface OnEndResult { | ||
errors?: PartialMessage[] | ||
warnings?: PartialMessage[] | ||
} | ||
/** Documentation: https://esbuild.github.io/plugins/#on-resolve-options */ | ||
interface OnResolveOptions { | ||
filter: RegExp; | ||
namespace?: string; | ||
filter: RegExp | ||
namespace?: string | ||
} | ||
/** Documentation: https://esbuild.github.io/plugins/#on-resolve-arguments */ | ||
interface OnResolveArgs { | ||
path: string; | ||
importer: string; | ||
namespace: string; | ||
resolveDir: string; | ||
kind: ImportKind; | ||
pluginData: any; | ||
path: string | ||
importer: string | ||
namespace: string | ||
resolveDir: string | ||
kind: ImportKind | ||
pluginData: any | ||
} | ||
@@ -379,60 +375,65 @@ | ||
/** Documentation: https://esbuild.github.io/plugins/#on-resolve-results */ | ||
interface OnResolveResult { | ||
pluginName?: string; | ||
pluginName?: string | ||
errors?: PartialMessage[]; | ||
warnings?: PartialMessage[]; | ||
errors?: PartialMessage[] | ||
warnings?: PartialMessage[] | ||
path?: string; | ||
external?: boolean; | ||
sideEffects?: boolean; | ||
namespace?: string; | ||
suffix?: string; | ||
pluginData?: any; | ||
path?: string | ||
external?: boolean | ||
sideEffects?: boolean | ||
namespace?: string | ||
suffix?: string | ||
pluginData?: any | ||
watchFiles?: string[]; | ||
watchDirs?: string[]; | ||
watchFiles?: string[] | ||
watchDirs?: string[] | ||
} | ||
/** Documentation: https://esbuild.github.io/plugins/#on-load-options */ | ||
interface OnLoadOptions { | ||
filter: RegExp; | ||
namespace?: string; | ||
filter: RegExp | ||
namespace?: string | ||
} | ||
/** Documentation: https://esbuild.github.io/plugins/#on-load-arguments */ | ||
interface OnLoadArgs { | ||
path: string; | ||
namespace: string; | ||
suffix: string; | ||
pluginData: any; | ||
path: string | ||
namespace: string | ||
suffix: string | ||
pluginData: any | ||
} | ||
/** Documentation: https://esbuild.github.io/plugins/#on-load-results */ | ||
interface OnLoadResult { | ||
pluginName?: string; | ||
pluginName?: string | ||
errors?: PartialMessage[]; | ||
warnings?: PartialMessage[]; | ||
errors?: PartialMessage[] | ||
warnings?: PartialMessage[] | ||
contents?: string | Uint8Array; | ||
resolveDir?: string; | ||
loader?: Loader; | ||
pluginData?: any; | ||
contents?: string | Uint8Array | ||
resolveDir?: string | ||
loader?: Loader | ||
pluginData?: any | ||
watchFiles?: string[]; | ||
watchDirs?: string[]; | ||
watchFiles?: string[] | ||
watchDirs?: string[] | ||
} | ||
interface PartialMessage { | ||
id?: string; | ||
pluginName?: string; | ||
text?: string; | ||
location?: Partial<Location> | null; | ||
notes?: PartialNote[]; | ||
detail?: any; | ||
id?: string | ||
pluginName?: string | ||
text?: string | ||
location?: Partial<Location> | null | ||
notes?: PartialNote[] | ||
detail?: any | ||
} | ||
interface PartialNote { | ||
text?: string; | ||
location?: Partial<Location> | null; | ||
text?: string | ||
location?: Partial<Location> | null | ||
} | ||
/** Documentation: https://esbuild.github.io/api/#metafile */ | ||
interface Metafile { | ||
@@ -446,3 +447,5 @@ inputs: { | ||
external?: boolean | ||
original?: string | ||
}[] | ||
format?: 'cjs' | 'esm' | ||
} | ||
@@ -471,12 +474,29 @@ } | ||
interface FormatMessagesOptions { | ||
kind: 'error' | 'warning'; | ||
color?: boolean; | ||
terminalWidth?: number; | ||
kind: 'error' | 'warning' | ||
color?: boolean | ||
terminalWidth?: number | ||
} | ||
interface AnalyzeMetafileOptions { | ||
color?: boolean; | ||
verbose?: boolean; | ||
color?: boolean | ||
verbose?: boolean | ||
} | ||
interface WatchOptions { | ||
} | ||
interface BuildContext<SpecificOptions extends BuildOptions = BuildOptions> { | ||
/** Documentation: https://esbuild.github.io/api/#rebuild */ | ||
rebuild(): Promise<BuildResult<SpecificOptions>> | ||
/** Documentation: https://esbuild.github.io/api/#watch */ | ||
watch(options?: WatchOptions): Promise<void> | ||
/** Documentation: https://esbuild.github.io/api/#serve */ | ||
serve(options?: ServeOptions): Promise<ServeResult> | ||
cancel(): Promise<void> | ||
dispose(): Promise<void> | ||
} | ||
/** | ||
@@ -490,13 +510,10 @@ * This function invokes the "esbuild" command-line tool for you. It returns a | ||
* | ||
* Documentation: https://esbuild.github.io/api/#build-api | ||
* Documentation: https://esbuild.github.io/api/#build | ||
*/ | ||
declare function build(options: BuildOptions & { write: false }): Promise<BuildResult & { outputFiles: OutputFile[] }>; | ||
declare function build(options: BuildOptions & { incremental: true, metafile: true }): Promise<BuildIncremental & { metafile: Metafile }>; | ||
declare function build(options: BuildOptions & { incremental: true }): Promise<BuildIncremental>; | ||
declare function build(options: BuildOptions & { metafile: true }): Promise<BuildResult & { metafile: Metafile }>; | ||
declare function build(options: BuildOptions): Promise<BuildResult>; | ||
declare function build<SpecificOptions extends BuildOptions>(options: SpecificOptions): Promise<BuildResult<SpecificOptions>> | ||
declare function build(options: BuildOptions): Promise<BuildResult> | ||
/** | ||
* This function is similar to "build" but it serves the resulting files over | ||
* HTTP on a localhost address with the specified port. | ||
* This is the advanced long-running form of "build" that supports additional | ||
* features such as watch mode and a local development server. | ||
* | ||
@@ -506,5 +523,6 @@ * - Works in node: yes | ||
* | ||
* Documentation: https://esbuild.github.io/api/#serve | ||
* Documentation: https://esbuild.github.io/api/#build | ||
*/ | ||
declare function serve(serveOptions: ServeOptions, buildOptions: BuildOptions): Promise<ServeResult>; | ||
declare function context<T extends BuildOptions>(options: T): Promise<BuildContext<T>> | ||
declare function context(options: BuildOptions): Promise<BuildContext> | ||
@@ -520,5 +538,6 @@ /** | ||
* | ||
* Documentation: https://esbuild.github.io/api/#transform-api | ||
* Documentation: https://esbuild.github.io/api/#transform | ||
*/ | ||
declare function transform(input: string | Uint8Array, options?: TransformOptions): Promise<TransformResult>; | ||
declare function transform<SpecificOptions extends TransformOptions>(input: string | Uint8Array, options?: SpecificOptions): Promise<TransformResult<SpecificOptions>> | ||
declare function transform(input: string | Uint8Array, options?: TransformOptions): Promise<TransformResult> | ||
@@ -533,3 +552,3 @@ /** | ||
*/ | ||
declare function formatMessages(messages: PartialMessage[], options: FormatMessagesOptions): Promise<string[]>; | ||
declare function formatMessages(messages: PartialMessage[], options: FormatMessagesOptions): Promise<string[]> | ||
@@ -546,3 +565,3 @@ /** | ||
*/ | ||
declare function analyzeMetafile(metafile: Metafile | string, options?: AnalyzeMetafileOptions): Promise<string>; | ||
declare function analyzeMetafile(metafile: Metafile | string, options?: AnalyzeMetafileOptions): Promise<string> | ||
@@ -555,6 +574,6 @@ /** | ||
* | ||
* Documentation: https://esbuild.github.io/api/#build-api | ||
* Documentation: https://esbuild.github.io/api/#build | ||
*/ | ||
declare function buildSync(options: BuildOptions & { write: false }): BuildResult & { outputFiles: OutputFile[] }; | ||
declare function buildSync(options: BuildOptions): BuildResult; | ||
declare function buildSync<SpecificOptions extends BuildOptions>(options: SpecificOptions): BuildResult<SpecificOptions> | ||
declare function buildSync(options: BuildOptions): BuildResult | ||
@@ -567,5 +586,6 @@ /** | ||
* | ||
* Documentation: https://esbuild.github.io/api/#transform-api | ||
* Documentation: https://esbuild.github.io/api/#transform | ||
*/ | ||
declare function transformSync(input: string, options?: TransformOptions): TransformResult; | ||
declare function transformSync<SpecificOptions extends TransformOptions>(input: string, options?: SpecificOptions): TransformResult<SpecificOptions> | ||
declare function transformSync(input: string | Uint8Array, options?: TransformOptions): TransformResult | ||
@@ -578,3 +598,3 @@ /** | ||
*/ | ||
declare function formatMessagesSync(messages: PartialMessage[], options: FormatMessagesOptions): string[]; | ||
declare function formatMessagesSync(messages: PartialMessage[], options: FormatMessagesOptions): string[] | ||
@@ -589,3 +609,3 @@ /** | ||
*/ | ||
declare function analyzeMetafileSync(metafile: Metafile | string, options?: AnalyzeMetafileOptions): string; | ||
declare function analyzeMetafileSync(metafile: Metafile | string, options?: AnalyzeMetafileOptions): string | ||
@@ -600,5 +620,5 @@ /** | ||
* | ||
* Documentation: https://esbuild.github.io/api/#running-in-the-browser | ||
* Documentation: https://esbuild.github.io/api/#browser | ||
*/ | ||
declare function initialize(options: InitializeOptions): Promise<void>; | ||
declare function initialize(options: InitializeOptions): Promise<void> | ||
@@ -630,3 +650,3 @@ interface InitializeOptions { | ||
declare let version: string; | ||
declare let version: string | ||
@@ -633,0 +653,0 @@ /** |
@@ -17,4 +17,38 @@ 'use strict'; | ||
function isStringArray(entryPoints) { | ||
if (Array.isArray(entryPoints) && entryPoints.some((entrypoint) => typeof entrypoint === "string")) | ||
return true; | ||
return false; | ||
} | ||
function transformToObject(entryPoints, outbase) { | ||
const separator = entryPoints[0].includes("\\") ? path__default["default"].win32.sep : path__default["default"].posix.sep; | ||
if (!outbase) { | ||
const hierarchy = entryPoints[0].split(separator); | ||
let i = 0; | ||
outbase = ""; | ||
let nextOutbase = ""; | ||
do { | ||
outbase = nextOutbase; | ||
i++; | ||
nextOutbase = hierarchy.slice(0, i).join(separator); | ||
} while (entryPoints.every( | ||
(entrypoint) => entrypoint.startsWith(`${nextOutbase}${separator}`) | ||
)); | ||
} | ||
const newEntrypoints = {}; | ||
for (const entrypoint of entryPoints) { | ||
const destination = (outbase ? entrypoint.replace(`${outbase}${separator}`, "") : entrypoint).replace(/.(js|ts)$/, ""); | ||
newEntrypoints[destination] = entrypoint; | ||
} | ||
return newEntrypoints; | ||
} | ||
function transformToNewEntryPointsType(entryPoints) { | ||
const newEntrypointsType = []; | ||
for (const [key, value] of Object.entries(entryPoints)) { | ||
newEntrypointsType.push({ in: value, out: key }); | ||
} | ||
return newEntrypointsType; | ||
} | ||
function esbuildPluginPino({ | ||
transports | ||
transports = [] | ||
}) { | ||
@@ -26,24 +60,3 @@ return { | ||
const threadStream = path__default["default"].dirname(require$1.resolve("thread-stream")); | ||
let entrypoints = currentBuild.initialOptions.entryPoints; | ||
if (Array.isArray(entrypoints)) { | ||
const separator = entrypoints[0].includes("\\") ? path__default["default"].win32.sep : path__default["default"].posix.sep; | ||
let outbase = currentBuild.initialOptions.outbase; | ||
if (!outbase) { | ||
const hierarchy = entrypoints[0].split(separator); | ||
let i = 0; | ||
outbase = ""; | ||
let nextOutbase = ""; | ||
do { | ||
outbase = nextOutbase; | ||
i++; | ||
nextOutbase = hierarchy.slice(0, i).join(separator); | ||
} while (entrypoints.every((e) => e.startsWith(`${nextOutbase}${separator}`))); | ||
} | ||
const newEntrypoints = {}; | ||
for (const entrypoint of entrypoints) { | ||
const destination = (outbase ? entrypoint.replace(`${outbase}${separator}`, "") : entrypoint).replace(/.(js|ts)$/, ""); | ||
newEntrypoints[destination] = entrypoint; | ||
} | ||
entrypoints = newEntrypoints; | ||
} | ||
const { entryPoints, outbase } = currentBuild.initialOptions; | ||
const customEntrypoints = { | ||
@@ -56,9 +69,27 @@ "thread-stream-worker": path__default["default"].join(threadStream, "lib/worker.js"), | ||
const transportsEntrypoints = Object.fromEntries( | ||
(transports || []).map((t) => [t, require$1.resolve(t)]) | ||
transports.map((transport) => [transport, require$1.resolve(transport)]) | ||
); | ||
currentBuild.initialOptions.entryPoints = { | ||
...entrypoints, | ||
...customEntrypoints, | ||
...transportsEntrypoints | ||
}; | ||
let newEntrypoints = []; | ||
if (isStringArray(entryPoints)) { | ||
newEntrypoints = transformToNewEntryPointsType({ | ||
...transformToObject(entryPoints, outbase), | ||
...customEntrypoints, | ||
...transportsEntrypoints | ||
}); | ||
} else if (Array.isArray(entryPoints)) { | ||
newEntrypoints = [ | ||
...entryPoints, | ||
...transformToNewEntryPointsType({ | ||
...customEntrypoints, | ||
...transportsEntrypoints | ||
}) | ||
]; | ||
} else { | ||
newEntrypoints = transformToNewEntryPointsType({ | ||
...entryPoints, | ||
...customEntrypoints, | ||
...transportsEntrypoints | ||
}); | ||
} | ||
currentBuild.initialOptions.entryPoints = newEntrypoints; | ||
let pinoBundlerRan = false; | ||
@@ -65,0 +96,0 @@ currentBuild.onEnd(() => { |
{ | ||
"name": "esbuild-plugin-pino", | ||
"version": "1.2.8", | ||
"version": "1.3.0", | ||
"description": "An esbuild plugin to generate extra pino files for bundling", | ||
@@ -28,21 +28,21 @@ "main": "dist/index.js", | ||
"devDependencies": { | ||
"@types/node": "18.11.17", | ||
"@typescript-eslint/eslint-plugin": "5.47.0", | ||
"@typescript-eslint/parser": "5.47.0", | ||
"esbuild": "0.16.10", | ||
"eslint": "8.30.0", | ||
"eslint-config-prettier": "8.5.0", | ||
"@types/node": "18.15.11", | ||
"@typescript-eslint/eslint-plugin": "5.57.0", | ||
"@typescript-eslint/parser": "5.57.0", | ||
"esbuild": "0.17.14", | ||
"eslint": "8.37.0", | ||
"eslint-config-prettier": "8.8.0", | ||
"eslint-plugin-prettier": "4.2.1", | ||
"execa": "6.1.0", | ||
"nodemon": "2.0.20", | ||
"pino": "8.8.0", | ||
"pino-loki": "2.0.3", | ||
"pino-pretty": "9.1.1", | ||
"pkgroll": "1.8.0", | ||
"prettier": "2.8.1", | ||
"execa": "7.1.1", | ||
"nodemon": "2.0.22", | ||
"pino": "8.11.0", | ||
"pino-loki": "2.0.4", | ||
"pino-pretty": "10.0.0", | ||
"pkgroll": "1.9.0", | ||
"prettier": "2.8.7", | ||
"standard-version": "9.5.0", | ||
"thread-stream": "2.2.0", | ||
"tsx": "3.12.1", | ||
"typescript": "4.9.4", | ||
"vitest": "0.26.0" | ||
"thread-stream": "2.3.0", | ||
"tsx": "3.12.6", | ||
"typescript": "5.0.2", | ||
"vitest": "0.29.8" | ||
}, | ||
@@ -54,2 +54,3 @@ "scripts": { | ||
"buildTS": "pkgroll && tsx test/buildScripts/buildTS.ts", | ||
"buildTS2": "pkgroll && tsx test/buildScripts/arrayOfObjects.ts", | ||
"test": "rm -rf dist && pkgroll && vitest run", | ||
@@ -56,0 +57,0 @@ "format": "prettier --write .", |
@@ -5,7 +5,5 @@ # esbuild-plugin-pino | ||
![npm bundle size](https://img.shields.io/bundlephobia/min/esbuild-plugin-pino) | ||
![dep](https://img.shields.io/librariesio/github/davipon/esbuild-plugin-pino) | ||
![CI](https://github.com/davipon/esbuild-plugin-pino/actions/workflows/ci.yml/badge.svg) | ||
![Release](https://github.com/davipon/esbuild-plugin-pino/actions/workflows/release.yml/badge.svg) | ||
![license](https://img.shields.io/github/license/davipon/esbuild-plugin-pino) | ||
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) | ||
@@ -67,2 +65,24 @@ An esbuild plugin to generate extra pino files for bundling | ||
```js | ||
// Start from esbuild@^0.17.1 | ||
// Multiple entryPoints in an array of object & pino transports | ||
const { build } = require('esbuild') | ||
const esbuildPluginPino = require('esbuild-plugin-pino') | ||
build({ | ||
entryPoints: [ | ||
{ | ||
in: './test/fixtures/first.js', | ||
out: 'first' | ||
}, | ||
{ | ||
in: './test/fixtures/second.js', | ||
out: 'abc/cde/second' | ||
} | ||
], | ||
outdir: 'dist', | ||
plugins: [esbuildPluginPino({ transports: ['pino-pretty', 'pino-loki'] })], | ||
}).catch(() => process.exit(1)) | ||
``` | ||
## Deploy to production | ||
@@ -69,0 +89,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
36351
839
95