Conversation
|
How about Can we bypass cache when a dist-tag is given? Use cache only if no
|
@latest is specified6ecf065 to
66435b0
Compare
|
@devjiwonchoi Since I am not sure what should be the reasonable expectation for dist tags that aren't "latest", I decide to give the user a choice in the form of a flag. |
| list: [ | ||
| { | ||
| description: 'Do not use or save the modules cache', | ||
| name: '--ignore-modules-cache', |
There was a problem hiding this comment.
it is a bit long for a CLI option. Maybe just --no-cache?
There was a problem hiding this comment.
I fear it would confuse the users. Many would think it ignore all the cache (including the store).
| if (!!opts.ignoreModulesCache || pkgs.some(pkg => pkg.endsWith('@latest'))) { | ||
| prepareDir = tempy.directory({ prefix: 'pnpm-dlx-' }) | ||
| } else { | ||
| cache = findCache(pkgs, { | ||
| dlxCacheMaxAge: opts.dlxCacheMaxAge, | ||
| cacheDir: opts.cacheDir, | ||
| registries: opts.registries, | ||
| }) | ||
| prepareDir = cache.dir | ||
| } |
There was a problem hiding this comment.
You probably could just replace the cacheDir with the temp dir. It will do a few redundant filesytem operations but the difference shouldn't be noticeable.
| if (!!opts.ignoreModulesCache || pkgs.some(pkg => pkg.endsWith('@latest'))) { | |
| prepareDir = tempy.directory({ prefix: 'pnpm-dlx-' }) | |
| } else { | |
| cache = findCache(pkgs, { | |
| dlxCacheMaxAge: opts.dlxCacheMaxAge, | |
| cacheDir: opts.cacheDir, | |
| registries: opts.registries, | |
| }) | |
| prepareDir = cache.dir | |
| } | |
| let cacheDir: string | |
| if (!!opts.ignoreModulesCache || pkgs.some(pkg => pkg.endsWith('@latest'))) { | |
| cacheDir = tempy.directory({ prefix: 'pnpm-dlx-' }) | |
| } else { | |
| cacheDir = opts.cacheDir | |
| } | |
| const { cacheLink, cacheExists, cachedDir } = findCache(pkgs, { | |
| dlxCacheMaxAge: opts.dlxCacheMaxAge, | |
| cacheDir, | |
| registries: opts.registries, | |
| }) | |
| if (!cacheExists) { | |
| fs.mkdirSync(cachedDir, { recursive: true }) |
There was a problem hiding this comment.
(I decided to keep cache.dir instead of cachedDir because cachedDir and cacheDir look too similar to each other, which may cause confusion)
|
Even if we ignore cache only when the For instance, you run a command with the We don’t know what most users prefer. We have a discussion with just few user opinions. I am not sure that’s enough to make a decision. There are a couple of alternative solutions:
cc @pnpm/collaborators |
|
My two cents here:
This matches with my mental model. When I run with a specific dist-tag, I expect it to match with the registry. Here's one edge case I can think of: When a user ran The same goes for The options I'd prefer are one of the following:
Both options need an update of the dlx documentation about the caching. |
|
The discussed solution: #8811 |
Resolves https://github.com/orgs/pnpm/discussions/8630