Cache package dependency collection results to avoid redundant filesystem walks#14672
Cache package dependency collection results to avoid redundant filesystem walks#14672dario-piotrowicz wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: aab6245 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
UnknownError: ProviderInitError |
|
@dario-piotrowicz Bonk workflow failed. Check the logs for details. View workflow run · To retry, trigger Bonk again. |
|
✅ All changesets look good |
@cloudflare/autoconfig
create-cloudflare
@cloudflare/deploy-helpers
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-auth
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
This comment was marked as resolved.
This comment was marked as resolved.
a212e68 to
809a696
Compare
|
Codeowners approval required for this PR:
Show detailed file reviewers
|
809a696 to
e55a1ea
Compare
e55a1ea to
aab6245
Compare
| for (const name of KNOWN_LOCKFILES) { | ||
| const filePath = find.file(name, { cwd: projectPath }); | ||
| if (filePath) { | ||
| const content = await readFile(filePath); |
There was a problem hiding this comment.
Is it worth wrapping this in a try / catch so we can safely return null with a console warning instead?
| return result.length > 0 ? result : undefined; | ||
| } catch (error) { | ||
| logger.debug( | ||
| logger?.debug( |
There was a problem hiding this comment.
Why is logger now nullish? I assumed it would be a singleton, no?
| "@types/node": "catalog:default", | ||
| "concurrently": "^8.2.2", | ||
| "devtools-protocol": "^0.0.1182435", | ||
| "empathic": "^2.0.0", |
There was a problem hiding this comment.
Is this dependency really needed? Can we not achieve the same functionality as empathic/find with regular Node.js tools?
| const cwd = process.cwd(); | ||
| const cacheDir = path.join(cwd, ".cache"); |
There was a problem hiding this comment.
Would it not be better to use the temp directory helper for this?
| const second = await collectPackageDependencies(cwd, { cacheDir }); | ||
| expect(second).toEqual(first); |
There was a problem hiding this comment.
Would it not be better to use mocks or something similar to check to make sure the cache actually gets hit?
|
Closing in favor of #14703 |
collectPackageDependenciesnow accepts an optionalcacheDirparameter. When provided, collected results are persisted to disk and reused on subsequent calls as long as neitherpackage.jsonnor the project's lockfile have been modified. This speeds up repeated deploys when dependencies haven't changed.Followup for #14591
A picture of a cute animal (not mandatory, but encouraged)