Open segevfiner opened 2 years ago
same question
I have tried banner option, it doesn't work. So I hacked it with some code
const fs = require('fs')
const path = require('path')
const build = path.join(__dirname, '../dist', 'index.cjs.js')
const unpatchedBuild = fs.readFileSync(build, 'utf-8')
const patchedBuild = unpatchedBuild.replace(
"'use strict';",
"#!/usr/bin/env node\n\n'use strict;'\n"
)
fs.writeFileSync(build, patchedBuild, 'utf-8')
I don't know if this is possibly related: https://github.com/egoist/tsup/issues/910
Steps to reproduce:
Run
npm install & npm build
, it will error with:CJS Build failed Error: Build failed with 1 error: src/index.ts:10:1: ERROR: Syntax error "!" at failureErrorWithLog (/prj/tsup-fileloc/node_modules/esbuild/lib/main.js:1621:15) at /prj/tsup-fileloc/node_modules/esbuild/lib/main.js:1263:28 at runOnEndCallbacks (/prj/tsup-fileloc/node_modules/esbuild/lib/main.js:1043:63) at buildResponseToResult (/prj/tsup-fileloc/node_modules/esbuild/lib/main.js:1261:7) at /prj/tsup-fileloc/node_modules/esbuild/lib/main.js:1374:14 at /prj/tsup-fileloc/node_modules/esbuild/lib/main.js:675:9 at handleIncomingPacket (/prj/tsup-fileloc/node_modules/esbuild/lib/main.js:772:9) at Socket.readFromStdout (/prj/tsup-fileloc/node_modules/esbuild/lib/main.js:641:7) at Socket.emit (node:events:527:28) at addChunk (node:internal/streams/readable:315:12)