Skip to content

How to avoid multiple yarn install commands on Heroku #130

@rsanheim

Description

@rsanheim

Note: This isn't really a jsbundling-rails issue, but I figured this is going to be fairly common issues as more folks are upgrading Rails / Heroku legacy apps from webpack to jsbundling w/ esbuild or alternative tools.

We are working on converting to esbuild away from webpack / rails-webpacker for a large-ish app that is deployed to Heroku.

So far almost everything is working, but we are seeing multiple calls to yarn install in Heroku deploys now in our esbuild branch. I'm wondering if there is a way to avoid this with Heroku when having both the nodejs and ruby buildpacks installed? The double installs aren't really a problem, but they do clutter up our logs and add time to deployments.

I read through #16, and also scanned through the node and ruby buildpack code, but don't see any clear way to tell one or the other to be the 'winner' and the only tool that handles running yarn install.

From what I can tell, the nodejs buildpack sees that we have a a package.json with a build task, so it installs node and yarn and then executes yarn run.

Then the ruby buildpack detects the ruby app, and runs the assets precompile task, which again runs the same steps (which I believe jsbundling-rails wires up).

I suppose we could try to explicitly clear out the precompile task in Rails land, but that feels pretty hacky and not a good long-term solution.

Is there an ENV var or flag we could set to tell the nodejs task to not try to build things, and instead let the ruby build pack be the 'builder' ?

Here are our buildpacks btw:

1. https://github.com/lstoll/heroku-buildpack-monorepo
2. https://github.com/DataDog/heroku-buildpack-datadog.git
3. https://github.com/heroku/heroku-buildpack-nginx
4. heroku/nodejs
5. heroku/ruby

And here is the output of a recent heroku deploy showing the multiple calls to yarn install.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions