Skip to content

[Feature] Configurable location of node_modules/.store with nodeLinker: pnpm #6623

Closed
@kirill-konshin

Description

@kirill-konshin
  • I'd be willing to implement this feature (contributing guide)
  • This feature is important to have in this repository; a contrib plugin wouldn't do

Describe the user story

It seems that copying directories to node_modules/.store during install takes considerable amount of time, so I was trying to persist this directory between jobs. Obvious solution is to put it in GitLab cache, but zip-unzip and network also takes time.

As a developer it would be convenient to place node_modules/.store somewhere else to be global, especially on CI. The benefit is that on GitLab Runner I can make a mounted volume, put .store there and share it between jobs, thus speeding up the install.

Currently this path

function getStoreLocation(project: Project) {
return ppath.join(getNodeModulesLocation(project), `.store`);
}
is hardcoded.

PNPM itself has global store by default: ~/.pnpm-store and provides config options pnpm config set store-dir /path/to/.pnpm-store to set it.

Compare the install times:

With node_modules/.store placed before install:

$ find node_modules -mindepth 1 -not -name ".cache" -exec rm -rf {} +
$ yarn install
➤ YN0000: ┌ Fetch step
➤ YN0000: └ Completed in 1s 418ms
➤ YN0000: ┌ Link step
➤ YN0000: └ Completed in 7s 889ms (not more than 10-15s, average arond 7-8s)

Vs when no .store (Yarn's own cache is pre-warmed already):

$ rm -rf node_modules
$ yarn install
➤ YN0000: ┌ Fetch step
➤ YN0000: └ Completed in 1s 418ms
➤ YN0000: ┌ Link step
➤ YN0000: └ Completed in 43s 678ms (average around ~45s)

Describe the solution you'd like

A simple config variable similar to cacheFolder would be enough: storeFolder for example.

Describe the drawbacks of your solution

Since I will be able to control the location and the variable, I don't see any drawbacks, just don't use the var if default behavior is OK.

Describe alternatives you've considered

I tried to symlink /cache/.store (where /cache is a mounted volume) to node_modules/.cache, installation was semi-successful: links were created but install failed with:

➤ YN0000: ┌ Link step
➤ YN0001: │ Error: ENOTDIR: not a directory, rmdir '/Users/dis/Sites/CX/frontend/node_modules/.store'

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions