heroku-buildpack-nodejs icon indicating copy to clipboard operation
heroku-buildpack-nodejs copied to clipboard

Do not restore cache when using npm ci

Open danielleadams opened this issue 4 years ago • 3 comments

With the current implementation of npm ci usage too create the build environment and Heroku slug, the buildpack will restore the cache at the beginning of the build and save the cache at the end of the build.

As recommended by the npm docs (https://docs.npmjs.com/cli/v6/commands/npm-ci#description), there should be no node_modules before an npm ci run because the command will delete the node_modules anyways. (The Heroku buildpack will pull node_modules from the previous build and restore them to the node_modules directory if the build is configured to use NODE_MODULES_CACHE.)

danielleadams avatar Jan 12 '21 19:01 danielleadams

This issue has been linked to a new work item: W-8711501

git2gus[bot] avatar Jan 12 '21 19:01 git2gus[bot]

Maybe a good idea instead of just discarding the cache for node_modules would be just adding a --cache option to the npm ci call passing a directory that the buildpack could use for cache (like Gitlab CI suggests, for instance). So we could have some performance improvement by not doing unnecessary network requests while also having the speedup of the npm ci.

I'm not totally sure if this would be good for another issue or if it could be something that could be added as an enhancement in this issue...

fjorgemota avatar Feb 04 '21 23:02 fjorgemota

This issue has been linked to a new work item: W-8870770

git2gus[bot] avatar Feb 09 '21 21:02 git2gus[bot]