Webpacker: Reduced Rails comfort when switching git branches

Created on 24 Mar 2020  路  3Comments  路  Source: rails/webpacker

I switch my git branches like a brisk bird. I work on a feature, then check out a remote change and then switch back to the master.

Since we got _Webpacker_ in _Rails_, my life became less comfortable: while switching branches works well with _Ruby_ gems (because you can have multiple versions installed and dependency resolution is fast), it doesn't with _node_ packages. I encounter the following message way too often when running rails s:

========================================
  Your Yarn packages are out of date!
  Please run `yarn install --check-files` to update.
========================================

https://github.com/rails/webpacker/issues/1135 makes it even worse.

_Rails_ should not annoy me because of _Webpacker_. Can we do something about that?
A naive idea would be to make separate node_modules folders for each yarn.lock.

Are there any other (more feasible) ideas?

dependencies

All 3 comments

I think this is one of the places that Yarn 2 (specifically PnP #2112) would be very beneficial. It would remove the need for a node_modules folder and module resolution would happen on the fly so re-installs should not be necessary.

while switching branches works well with Ruby gems (because you can have multiple versions installed and dependency resolution is fast), it doesn't with node packages.

Do you have your yarn.lock file under version control?

I don鈥檛 think this is a problem Webpacker should solve. This is an issue for any yarn- or npm-managed project: you have to run yarn install each time you switch branches. This can be handled with a git hook https://andy-carter.com/blog/automating-npm-and-composer-with-git-hooks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vtno picture vtno  路  3Comments

amandapouget picture amandapouget  路  3Comments

pioz picture pioz  路  3Comments

ankitrg picture ankitrg  路  3Comments

iChip picture iChip  路  3Comments