Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hashbang not included in CLIs #10

Closed
ayuhito opened this issue Jun 28, 2022 · 3 comments · Fixed by #40
Closed

Hashbang not included in CLIs #10

ayuhito opened this issue Jun 28, 2022 · 3 comments · Fixed by #40

Comments

@ayuhito
Copy link
Contributor

ayuhito commented Jun 28, 2022

I think the current version doesn't work to include the hashbang for any files included in the bin field of package.json. Or more accurately, I don't think the bundler even recognises bin field at all, considering the cli.ts file is compiled to both cli.js and cli.mjs when pkgroll is run, rather than just cli.js with just the hashbang.

Here's a simple repro, although there really isn't anything special to it. I've copied the instructions on the README which leads to this bug. The dist files are shown so you can see the result.

I wonder if #7 is related to this?

@privatenumber
Copy link
Owner

It works based on these tests but you may have discovered an edge-case.

Thanks for the reproduction, will look into it

@Shuunen
Copy link

Shuunen commented Jun 26, 2023

I have the same issue on my side,

On linux #!/usr/bin/env node is injected in dist/my-cli.js, not in cjs or mjs files

On Windows 10 Pro 22H2 (up to date) no hashbang in any files

So it seems related to OS only

@ayuhito
Copy link
Contributor Author

ayuhito commented Jun 26, 2023

Yup, I can confirm it is definitely a Windows only bug.

This is a current workaround I have for all my packages in the meantime which runs after every build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants