rslib
rslib copied to clipboard
[Bug]: Rslib build breaks shebang line in bin file
Version
System:
OS: macOS 14.6.1
CPU: (10) arm64 Apple M1 Pro
Memory: 2.72 GB / 32.00 GB
Shell: 5.9 - /bin/zsh
Browsers:
Chrome: 128.0.6613.86
Safari: 17.6
npmPackages:
@rslib/core: 0.0.4 => 0.0.4
Details
Rslib build breaks shebang line in bin file:
- Input:
- Output:
- Failed to run:
Reproduce link
https://github.com/web-infra-dev/rsbuild/tree/8a2a850aad336b726e50b2b1bb203d8c72c1c48a/packages/create-rsbuild
Reproduce Steps
- pnpm i
- pnpm build
- webpack / Rspack will adding
//to strip the shebang, see https://github.com/webpack/webpack/pull/13961. - webpack / Rspack will not hoist shebang to the top of the bundle intentionally.
- esbuild already handles chmod internally https://github.com/evanw/esbuild/commit/b808c0d905551dde55e2485eb18d488b12e4ba94.
Shortly we could use https://github.com/shuangwhywhy/webpack-shebang-plugin. In longterm, we could considering making this a built-in plugin to webpack / Rspack.
Yes, we can add a built-in plugin to webpack and Rspack when the target is node.