Skip to content

Conversation

@serhalp
Copy link
Member

@serhalp serhalp commented Dec 18, 2025

Summary

@netlify/build-info currently uses two mechanisms for detecting a detected framework's version: a high-fidelity check of the installed package in node_modules and a low-fidelity fallback check based on the version range in package.json dependencies. It does this automatically and opaquely.

Much like the existing framework accuracy, this PR adds a framework version accuracy field on the result, for improved transparency.

Each detection result now has:

package: {
  name?: string
  version: string | 'unknown'
  versionAccuracy?: VersionAccuracy // new!
}

enum VersionAccuracy {
  // High accuracy: read from installed package in node_modules
  NodeModules = 'node_modules',
  // Medium accuracy: exact pinned version from package.json (e.g., "1.2.3")
  PackageJSONPinned = 'package_json_pinned',
  // Low accuracy: parsed from package.json dependency range (e.g., "^1.2.3")
  PackageJSON = 'package_json',
}

private async npmDependenciesUsed(
pkgJSON: Partial<PackageJson>,
): Promise<{ name: string; version?: SemVer } | undefined> {
const allDeps = [...Object.entries(pkgJSON.dependencies || {}), ...Object.entries(pkgJSON.devDependencies || {})]
Copy link
Member Author

@serhalp serhalp Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't help myself here. This was unnecessarily complicated. Instead of just merging two record objects, we were turning them into an array [[k1, v1], [k2, v2], ...] for some reason, which is less readable, more complicated, and presumably less performant (we use .find() on this, twice).

@serhalp serhalp marked this pull request as ready for review December 18, 2025 17:23
@serhalp serhalp requested a review from a team as a code owner December 18, 2025 17:23
@serhalp serhalp requested a review from pieh December 18, 2025 19:44
@serhalp serhalp removed the request for review from pieh December 19, 2025 13:45
@serhalp serhalp enabled auto-merge (squash) December 19, 2025 13:48
@mrstork mrstork disabled auto-merge December 19, 2025 14:06
@mrstork mrstork merged commit 66891ca into main Dec 19, 2025
52 of 55 checks passed
@mrstork mrstork deleted the serhalp/frb-2078-add-framework-version-accuracy-metadata-to-build-info branch December 19, 2025 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants