wd-David/esbuild-plugin-pino

Support bundling pino-pretty

Opened this issue · 2 comments

Would it be possble support creating bundle for "pino-pretty" wrapper as well?

I added node_modules/.bin/pino-pretty" to entryPoints:

build({
  entryPoints: [
    "./src/index.ts", // <-- or whatever was before
    "./node_modules/.bin/pino-pretty",
  ],

it created bundle, but seems it expect some files to be unbundled:

✖ dist/node_modules/.bin/pino-pretty.js
/dist/node_modules/.bin/pino-pretty.js:40
        throw new Error(`${opts.dir} is not a directory`);
        ^

Error: /dist/node_modules/.bin/help is not a directory
    at helpMe (/dist/node_modules/.bin/pino-pretty.js:40:15)
    at Object.<anonymous> (/dist/node_modules/.bin/pino-pretty.js:15744:29)
    at Module._compile (node:internal/modules/cjs/loader:1356:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1414:10)
    at Module.load (node:internal/modules/cjs/loader:1197:32)
    at Module._load (node:internal/modules/cjs/loader:1013:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12)
    at node:internal/main/run_main_module:28:49

Node.js v18.19.1

I guess the problematic part is from here:

➜ readlink -f node_modules/.bin/pino-pretty
node_modules/pino-pretty/bin.js

➜ ls -l node_modules/pino-pretty/help  
total 4.0K
-rw-r--r-- 1 glen staff 3.5K Jan 17 14:22 help.txt

➜ 

for now, could just copy missing directory:

install -d dist/node_modules/.bin; cp -a node_modules/pino-pretty/help dist/node_modules/.bin