-
Notifications
You must be signed in to change notification settings - Fork 30
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
yarn install
, webpacker, and assets:precompile
#744
Comments
Oh, and I'm pretty sure any changes here won't affect the Guard setup, which is running the webpack-dev-server as a separate process... but double-checking is definitely in order! FWIW with the above hack in place, and a round or two of on-the-fly recompilation via Guard, none of my debug messages appeared. |
Very thorough @rebeccacremona ! I don't know how the deploy process calls Setting |
I would love to override the behavior of |
re: Vue's production mode: https://vuejs.org/v2/guide/deployment.html I think in our case, it's primarily about stripping/silencing warnings and not about anything particularly meaningful. I'll look more thoroughly soon, both to see whether webpacker's override of re: deployment + PR, sounds good to me! PR forthcoming some time this week. |
@cgruppioni It's as I suspected: webpacker is arranging for The correct value for Travis is less clear to me. Since Travis is also pre-compiling assets, it should probably be 'production' there too, for clarity.... but
implies that it's not using the pre-compiled javascript. Do you have an opinion about whether Travis should be using pre-compiled assets, like prod, or on-the-fly assets, like your dev instance does? Demo that
|
@rebeccacremona hi! Anything specific you did to fix that aside from your initial comment? I posted your solution to double heroku yarn installs here (with credits): https://dev.to/vvo/a-rails-6-setup-guide-for-2019-and-2020-hf5#heroku-and-double-yarn-installs and the heroku maintainer said it should not happen here: https://dev.to/vvo/a-rails-6-setup-guide-for-2019-and-2020-hf5#heroku-and-double-yarn-installs but I never got back again. Let me know! |
On every call to
assets:precompile
,yarn install
is getting run twice, both times without--frozen-lockfile
. It can (and does) install/uninstall packages.We certainly don't want it running twice. We might not want it running at all: it's not clear to me that asset compilation is the best moment to update node packages, in whatever environment.
Even more fun: the runs can (and do) install different packages, under the right circumstances. For example, if you run
RAILS_ENV=development bin/bundle exec rake assets:precompile
locally, the first installation move will make sure devDependencies are installed, and the second installation move will make sure devDependencies are removed.Here's why
yarn install
is being run at all.Answer 1: Rails always runs
yarn install
beforeassets:precompile
https://github.com/rails/rails/blob/v5.2.2.1/railties/lib/rails/tasks/yarn.rake. In Rails 6, it will include the--frozen-lockfile
flag, which is great! If we decide we want it to run at all, we should probably override to include that flag.Answer 2: there is a problem with webpacker. They don't intend for it to redundantly run
yarn install
. But it is. There are two possible culprits:rails/webpacker@4d06333#diff-e36986293b3ec8ccf91a5c317454efcf, not yet released, changes the logic for detecting whether or not
webpacker:yarn_install
needs to run or not. Hopefully that change will work in our situation.There's also this line: https://github.com/rails/webpacker/blob/master/lib/tasks/webpacker/compile.rake#L49. I've had timing issues when running things like
Rake::Task.task_defined?("assets:precompile")
.... In my experience today, the task isn't always defined at the moment you are querying, but may be defined later!I think it's just 1)... but it could be that 1) and 2) are both sufficient :-)
The
webpacker:yarn_install
task is run before the Railsyarn:install
task.Here's why they can install different packages.
Webpacker's compile command will always run in "production" mode, regardless of how
NODE_ENV
is set.rails/webpacker#1395
rails/webpacker#1558
NODE_ENV
is not explicitly set anywhere in the H2O ecosystem, so far as I know. Instead, it defaults to different values, depending.Somehow or the other, this can result in the first
yarn install
running withNODE_ENV=development
and the second withNODE_ENV=production
. I'll admit I don't totally get it, even though I can watch it happen repeatedly.What do we want to do?
Dunno.
By adding this to our Rakefile, I was able to override both installation tasks:
with the results:
So, we can do whatever we want LOL.
I think we should at least make
wepacker:yarn_install
a no-op. It IS redundant, whyever it's running.I think we should probably explicitly set
NODE_ENV
to production in production. If not in the actual environment (I am in NO position to hazard whether that might break everything), then at least in the asset compilation command, so it becomesRAILS_ENV=production NODE_ENV=production bin/bundle exec rake assets:precompile
. It would be nice if we could do it in the actual shell environment, so that ?? yarn commands work as expected consistently, like yarn check ?? (truth?)I think we should consider not having the asset compilation step do any installation. Or at least add in the frozen lockfile flag.
The text was updated successfully, but these errors were encountered: