rails / jsbundling-rails

Bundle and transpile JavaScript in Rails with esbuild, rollup.js, or Webpack.
MIT License
831 stars 143 forks source link

Allow npm or pnpm to be used as a package manager instead of yarn #176

Closed KevinNorth closed 8 months ago

KevinNorth commented 10 months ago

If I understand correctly, jsbundling-rails is hard-coded to use yarn. Can this please be changed to allow consumers to specify their preferred Node package manager?

KevinNorth commented 10 months ago

I successfully monkey-patched jsbundling-rails to use pnpm in a project I'm working on, so I have some ideas on how this could be implemented. If you think this feature request is a good idea, I would be happy to put together a pull request for it!

h0jeZvgoxFepBQ2C commented 10 months ago

yes pleas create a PR, I would like to use npm too instead of yarn

h0jeZvgoxFepBQ2C commented 10 months ago

Same request in the cssbundling-rails repo too https://github.com/rails/cssbundling-rails/issues/138

G-Rath commented 10 months ago

fwiw I recently created package_json to facilitate this, which is in the process of being landed in Shakapacker.

You can follow that here, and we've also got it working in our rails-template across the five main package managers (npm, pnpm, yarn classic, yarn berry, and bun).

My understanding is that jsbundling-rails is primarily only using package managers in its install templates and it looks like a single build call in a rake task that should be easy to customize per app so I wasn't going to look at suggesting package_json here until after Shakapacker has been switched over in a new major and proven stable for a while, but if folks are already interested and open to it here I'm happy to help with its integration :)

KevinNorth commented 10 months ago

Hello! Thanks for the encouragement to pursue this. I'm going to be busy on a higher-priority project for a little while. But I'll plan to come back to this and hopefully have a PR up by the end of the year or early next year.

I'll definitely look into your contributions when I do so, G-Rath!