Skip to content

Commit 6ab72ca

Browse files
committed
fix: support shebangs
1 parent 28eb5ef commit 6ab72ca

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"devDependencies": {
3030
"bent": "^7.3.9",
3131
"estest": "^10.3.1",
32+
"rollup-plugin-preserve-shebangs": "^0.2.0",
3233
"standard": "^14.3.4",
3334
"tempy": "^0.6.0"
3435
},

src/package/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@ import path from '../path-to-url.js'
66
import { fileURLToPath } from 'url'
77
import { join } from 'path'
88
import rmtree from '@tgrajewski/rmtree'
9+
import preserveShebangs from 'rollup-plugin-preserve-shebangs'
910

1011
const copy = o => JSON.parse(JSON.stringify(o))
1112
const vals = Object.values
1213

1314
const { writeFile, mkdir, unlink, readdir, readFile } = fs
1415

16+
const plugins = [ preserveShebangs.preserveShebangs() ]
17+
1518
class Package {
1619
constructor ({ cwd, hooks, tests }) {
1720
this.cwd = cwd
@@ -146,7 +149,7 @@ class Package {
146149
}
147150
}
148151

149-
const compile = await rollup({ input: fileURLToPath(input), treeshake: false, onwarn })
152+
const compile = await rollup({ input: fileURLToPath(input), treeshake: false, onwarn, plugins })
150153
const dir = fileURLToPath(new URL(dist + '/cjs'))
151154
await compile.write({ preserveModules: true, dir, format: 'cjs' })
152155
await unlink(input)

0 commit comments

Comments
 (0)