Resolve installed dependency versions from lockfiles instead of node_modules#14703
Resolve installed dependency versions from lockfiles instead of node_modules#14703dario-piotrowicz wants to merge 4 commits into
Conversation
🦋 Changeset detectedLatest commit: be782c6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 8 packages
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 |
|
Per All other reviewed changesets look good:
|
@cloudflare/autoconfig
@cloudflare/config
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: |
|
@dario-piotrowicz Bonk workflow was cancelled. View workflow run · To retry, trigger Bonk again. |
24edfc0 to
2f88b64
Compare
|
Codeowners approval required for this PR:
Show detailed file reviewers
|
2f88b64 to
1d033b4
Compare
1d033b4 to
18f5c12
Compare
18f5c12 to
23ebae8
Compare
…modules `getInstalledPackageVersion` now consults the nearest lockfile (pnpm-lock.yaml, package-lock.json, yarn.lock, or bun.lock) before falling back to resolving from node_modules. The lockfile is parsed once and memoized, making repeated version lookups significantly faster. This also improves the accuracy of the dependency metadata collected during deploys. All four major package managers (npm, pnpm, yarn, and bun) are supported across their lockfile format versions
50849a3 to
9e5beec
Compare
|
I've converted this PR to draft since the main reason for this PR is to implement a more performant solution (that requires fewer fs operations) but by running some benchmarks it does not look like this solution is any better than the current one 😕 : https://github.com/dario-piotrowicz/wrangler-14703-benchmarking/actions/runs/29760120747 So I need to investigate what's going on (and potentially just stick the the current solution) |
getInstalledPackageVersionnow consults the nearest lockfile (pnpm-lock.yaml, package-lock.json, yarn.lock, or bun.lock) before falling back to resolving from node_modules. The lockfile is parsed once and memoized, making repeated version lookups significantly faster. This also improves the accuracy of the dependency metadata collected during deploys. All four major package managers (npm, pnpm, yarn, and bun) are supported across their lockfile format versionsNote
I run some benchmarks on this PR's prerelease and I must say that the perf benefit seems to be quite minimal even when dealing with a good number of dependencies (~130). That however might be because of performance fs operations on my system, maybe the different could be more significative on older less powerful machines (also this definitely scaled batter, so the more the dependencies the more this approach speeds things up).
A picture of a cute animal (not mandatory, but encouraged)