webpacker: don't run `yarn check --integrity` on every rails command
yarn check --integrity
is always run. Even if I do a rails g migration ...
, which obviously has nothing to do with yarn.
I benchmarked it and noticed it adds about 400ms delay to such commands in my case, which is huge imo. It should be changed that it only runs when it makes sense to check for it, like when starting up the web server or the webpack-dev-server.
Since I am not familiar with the rails/railtie internals, I don’t know if this is possible or how to implement such checks at the right place.
Is this possible? What do you think?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 24
- Comments: 17 (4 by maintainers)
You can disable that in
development.rb
.Just set
config.webpacker.check_yarn_integrity = false
@kriansa yes, I know this, but this disables it completely. It often saved me already when running
bin/webpacker
orrails server
with outdated deps, so in general it makes sense to have it enabled on development. But not when I runrails g migration
,rails routes
, …This is quite annoying. The check now (since #1774) also runs
yarn check --verify-tree
, which takes a whooping 2.7s on my system, effectively doubling environment loading time on every rails command:Like the OP, I would like to keep the check for
rails s
, but I don’t see why it needs to be run for everything else.I would love to see this revisited. If anything, I feel like
yarn.lock
should be checked on runningrails assets:precompile
(and, as mentioned, on runningbin/webpack
orbin/webpack-dev-server
). Otherwise, it doesn’t really matter, since Webpack is run in a separate process.This check also breaks adding webpacker to an existing project if
yarn.lock
exists. Runningrails webpacker:install
loads rails, so this initializer tries to fetch :check_yarn_integrity, which loadsconfig/webpacker.yml
. However, this doesn’t exist until after we run this rake task.I had a chuckle at the error message suggesting I run
rails webpacker:install
:We could update the installation instructions to:
…but that seems hacky. I like the idea of this initializer being smarter. I haven’t learned enough about it to suggest how.
Run
rm - rf node_modules && yarn
On Wed, 25 Sep 2019, 9:46 aliraxa-max, notifications@github.com wrote:
config.webpacker.check_yarn_integrity = false
Faced this issues with rails 5.2.3. I was able to fix it with the following:
curl --compressed -o- -L https://yarnpkg.com/install.sh | bash
@doits Can we close this issue? Fixed in #2518.
I fixed this by doing the following steps;
I had to create a symlink because the node binary was not found. sudo ln -s /usr/bin/nodejs /usr/bin/node
Upgrading NodeJS to 13.* (probably swapped the binary path here, symlink might have been overkill).
Updating Yarn, https://yarnpkg.com/en/package/yarn Refreshing the shell instance.