diff --git a/packages/shared-internals/src/rewritten-package-cache.ts b/packages/shared-internals/src/rewritten-package-cache.ts index cc50b0f9c..d2a4971e2 100644 --- a/packages/shared-internals/src/rewritten-package-cache.ts +++ b/packages/shared-internals/src/rewritten-package-cache.ts @@ -1,6 +1,6 @@ import PackageCache from './package-cache'; import Package from './package'; -import { ensureDirSync, existsSync, readJSONSync, realpathSync } from 'fs-extra'; +import { existsSync, readJSONSync, realpathSync } from 'fs-extra'; import { resolve } from 'path'; import { getOrCreate } from './get-or-create'; import { locateEmbroiderWorkingDir } from './working-dir'; @@ -133,8 +133,8 @@ export class RewrittenPackageCache implements PublicAPI { } private loadIndex(): RewrittenPackageCache['index'] { - let addonsDir = resolve(locateEmbroiderWorkingDir(this.appRoot), 'rewritten-packages'); - let indexFile = resolve(addonsDir, 'index.json'); + let workingDir = locateEmbroiderWorkingDir(this.appRoot); + let indexFile = resolve(workingDir, 'rewritten-packages', 'index.json'); if (!existsSync(indexFile)) { return { oldToNew: new Map(), @@ -143,25 +143,16 @@ export class RewrittenPackageCache implements PublicAPI { }; } - // this directory is a bit special because RewrittenPackageCache needs to - // exist before this dir has been produced. But the dir appears preemptively - // in our index, and we don't want that to blow up during the realpath - // below. - ensureDirSync(resolve(addonsDir, '..', 'rewritten-app')); + workingDir = realpathSync(workingDir); + let addonsDir = resolve(workingDir, 'rewritten-packages'); let { packages, extraResolutions } = readJSONSync(indexFile) as RewrittenPackageIndex; return { oldToNew: new Map( - Object.entries(packages).map(([oldRoot, newRoot]) => [ - realpathSync(resolve(addonsDir, oldRoot)), - realpathSync(resolve(addonsDir, newRoot)), - ]) + Object.entries(packages).map(([oldRoot, newRoot]) => [resolve(addonsDir, oldRoot), resolve(addonsDir, newRoot)]) ), newToOld: new Map( - Object.entries(packages).map(([oldRoot, newRoot]) => [ - realpathSync(resolve(addonsDir, newRoot)), - realpathSync(resolve(addonsDir, oldRoot)), - ]) + Object.entries(packages).map(([oldRoot, newRoot]) => [resolve(addonsDir, newRoot), resolve(addonsDir, oldRoot)]) ), extraResolutions: new Map( Object.entries(extraResolutions).map(([fromRoot, toRoots]) => [