Webpacker: Option to select package manager

Created on 11 Oct 2018  路  8Comments  路  Source: rails/webpacker

Hi guys,

Is there any intention to implement an option to select the package manager? We prefer to use NPM instead Yarn

enhancement

Most helpful comment

Any update on this? We don't like to be forced to use one tool or another, also npm picked up their game. I looked through the source and it doesn't seem that hard to make it configurable or at least allow people to pick between yarn and npm.

Willing to put some time on this if its going to be accepted

All 8 comments

I think it is unlikely. Webpacker was conceived during the npm@5->6 debacle. I am sure that those conceptions are still fresh in the minds of the webpacker maintainers (rightly so). But, it is _mostly_ all better now.

It's not too bad to flip webpacker over to npm. (https://github.com/rails/webpacker/issues/1603#issuecomment-410377914)

That being said, an option to use npm out of the box would be very nice. Especially given some of the improvements npm is offering over and above yarn lately.

It's not too bad to flip webpacker over to npm. (#1603 (comment))

master now explicitly requires for yarn: https://github.com/rails/webpacker/blob/bb132d591da35095e3246082cba3d693f847e0b5/lib/webpacker/runner.rb#L13

Any update on this? We don't like to be forced to use one tool or another, also npm picked up their game. I looked through the source and it doesn't seem that hard to make it configurable or at least allow people to pick between yarn and npm.

Willing to put some time on this if its going to be accepted

Same here. It honestly makes no sense to vendor-lock yourself in an ecosystem that doesn't even belong to you, and make your users implicitly do the same choice on top of that. We're willing to help implement this too if you guys are on board.

master now explicitly requires for yarn

Yeah, but you can declare that ENV (this can be a relative path and I will just work)

As for deployment WEBPACKER_PRECOMPILE can be set to false and you will have to write your own compile task to skip webpacker:verify_install step as right now it's not very flexible.

Overall it's doable - personally I'm using webpacker without yarn for over half a year now (dev & prod) - I was against adding yet another dependency on top of the project when npm was already there.

Context behind the yarn decision: https://github.com/rails/webpacker/pull/475#issuecomment-325230920 (I don't think it has been linked here)

Webpacker is designed to work primarily with Rails 5.1+ and Rails has picked Yarn for now as the JavaScript packaging approach. That doesn't mean that someone couldn't go another route, but just that what we'll support out the box is Yarn. Now that we've extracted all logic from the tasks and moved them into the Webpacker class, it's trivially easy for someone who'd like to use a different approach to call the logic without relying on the tasks and prechecks we have.

I don't agree. It really isn't trivially easy to switch package managers. Even if it was made trivially easy, that would work for me as well.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

amandapouget picture amandapouget  路  3Comments

christianrojas picture christianrojas  路  3Comments

pioz picture pioz  路  3Comments

eriknygren picture eriknygren  路  3Comments

inopinatus picture inopinatus  路  3Comments