refactor: legacy side-effects cache cleanup

ref #2562
This commit is contained in:
Zoltan Kochan
2020-05-20 03:28:56 +03:00
parent 54676eae07
commit 16d1ac0fd1
8 changed files with 12 additions and 14 deletions

View File

@@ -0,0 +1,6 @@
---
"@pnpm/package-requester": major
"@pnpm/store-controller-types": major
---
`body.cacheByEngine` removed from `PackageResponse`.

View File

@@ -0,0 +1,5 @@
---
"@pnpm/resolve-dependencies": major
---
`engineCache` is removed from `ResolvedPackage`. `sideEffectsCache` removed from input options.

View File

@@ -197,7 +197,6 @@ async function resolveAndFetch (
if (options.skipFetch && manifest) {
return {
body: {
cacheByEngine: options.sideEffectsCache ? await getCacheByEngine(ctx.storeDir, id) : new Map(),
id,
inStoreLocation: path.join(ctx.storeDir, pkgIdToFilename(id, options.lockfileDir)),
isLocal: false as const,
@@ -221,7 +220,6 @@ async function resolveAndFetch (
return {
body: {
cacheByEngine: options.sideEffectsCache ? await getCacheByEngine(ctx.storeDir, id) : new Map(),
id,
inStoreLocation: fetchResult.inStoreLocation,
isLocal: false as const,

View File

@@ -57,7 +57,6 @@ export default async function (
registries: Registries,
resolutionStrategy?: 'fast' | 'fewer-dependencies',
pnpmVersion: string,
sideEffectsCache: boolean,
linkWorkspacePackagesDepth?: number,
lockfileDir: string,
storeController: StoreController,
@@ -88,7 +87,6 @@ export default async function (
readPackageHook: opts.hooks.readPackage,
registries: opts.registries,
resolvedPackagesByPackageId: {} as ResolvedPackagesByPackageId,
sideEffectsCache: opts.sideEffectsCache,
skipped: wantedToBeSkippedPackageIds,
storeController: opts.storeController,
updateLockfile: opts.updateLockfile,

View File

@@ -130,7 +130,6 @@ export interface ResolutionContext {
currentLockfile: Lockfile,
linkWorkspacePackagesDepth: number,
lockfileDir: string,
sideEffectsCache: boolean,
storeController: StoreController,
// the IDs of packages that are not installable
skipped: Set<string>,
@@ -147,8 +146,6 @@ export interface ResolutionContext {
resolutionStrategy: 'fast' | 'fewer-dependencies',
}
const ENGINE_NAME = `${process.platform}-${process.arch}-node-${process.version.split('.')[0]}`
export type PkgAddress = {
alias: string,
depIsLinked: boolean,
@@ -203,7 +200,6 @@ export interface ResolvedPackage {
cpu?: string[],
os?: string[],
},
engineCache?: string,
}
export default async function resolveDependencies (
@@ -555,7 +551,6 @@ async function resolveDependency (
preferredVersions: options.preferredVersions,
projectDir: options.currentDepth > 0 ? ctx.lockfileDir : ctx.prefix,
registry: wantedDependency.alias && pickRegistryForPackage(ctx.registries, wantedDependency.alias) || ctx.registries.default,
sideEffectsCache: ctx.sideEffectsCache,
// Unfortunately, even when run with --lockfile-only, we need the *real* package.json
// so fetching of the tarball cannot be ever avoided. Related issue: https://github.com/pnpm/pnpm/issues/1176
skipFetch: false,
@@ -785,7 +780,6 @@ function getResolvedPackage (
},
depPath: options.depPath,
dev: options.wantedDependency.dev,
engineCache: !options.force && options.pkgResponse.body.cacheByEngine?.[ENGINE_NAME],
fetchingBundledManifest: options.pkgResponse.bundledManifest,
fetchingFiles: options.pkgResponse.files!,
filesIndexFile: options.pkgResponse.filesIndexFile!,

View File

@@ -119,7 +119,6 @@ export type PackageResponse = {
updated: boolean,
resolvedVia?: string,
inStoreLocation?: string,
cacheByEngine?: Map<string, string>,
// This is useful for recommending updates.
// If latest does not equal the version of the
// resolved package, it is out-of-date.

View File

@@ -632,7 +632,6 @@ async function installInContext (
pnpmVersion: opts.packageManager.name === 'pnpm' ? opts.packageManager.version : '',
registries: opts.registries,
resolutionStrategy: opts.resolutionStrategy,
sideEffectsCache: opts.sideEffectsCacheRead,
storeController: opts.storeController,
tag: opts.tag,
updateLockfile: ctx.wantedLockfile.lockfileVersion !== LOCKFILE_VERSION || !opts.currentLockfileIsUpToDate,

View File

@@ -217,7 +217,7 @@ function resolvePeersOfNode (
ctx.pathsByNodeId[nodeId] = depPath
if (!ctx.depGraph[depPath] || ctx.depGraph[depPath].depth > node.depth) {
const independent = ctx.independentLeaves && resolvedPackage.independent
const centralLocation = resolvedPackage.engineCache || path.join(resolvedPackage.path, 'node_modules', resolvedPackage.name)
const centralLocation = path.join(resolvedPackage.path, 'node_modules', resolvedPackage.name)
const peripheralLocation = !independent
? path.join(modules, resolvedPackage.name)
: centralLocation
@@ -246,7 +246,6 @@ function resolvePeersOfNode (
hasBundledDependencies: resolvedPackage.hasBundledDependencies,
independent,
installable: node.installable,
isBuilt: !!resolvedPackage.engineCache,
isPure,
modules,
name: resolvedPackage.name,