rslib icon indicating copy to clipboard operation
rslib copied to clipboard

[Bug]: Rslib build breaks shebang line in bin file

Open chenjiahan opened this issue 1 year ago • 2 comments

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:

image

  • Output:

image

  • Failed to run:

image

Reproduce link

https://github.com/web-infra-dev/rsbuild/tree/8a2a850aad336b726e50b2b1bb203d8c72c1c48a/packages/create-rsbuild

Reproduce Steps

  1. pnpm i
  2. pnpm build

chenjiahan avatar Sep 02 '24 02:09 chenjiahan

  • 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.

fi3ework avatar Sep 02 '24 05:09 fi3ework

Yes, we can add a built-in plugin to webpack and Rspack when the target is node.

chenjiahan avatar Sep 02 '24 05:09 chenjiahan