Skip to content

fix: remove get-package-info and resolve dependencies#1906

Merged
MarshallOfSound merged 1 commit intomainfrom
sam/inline-infer-deps
Apr 22, 2026
Merged

fix: remove get-package-info and resolve dependencies#1906
MarshallOfSound merged 1 commit intomainfrom
sam/inline-infer-deps

Conversation

@MarshallOfSound
Copy link
Copy Markdown
Member

@MarshallOfSound MarshallOfSound commented Apr 19, 2026

Replaces get-package-info with a small async generator in infer.ts that walks up the directory tree yielding parsed package.json files. getMetadataFromPackageJSON reads the needed fields (productName/name, version, author, dependencies.electron/devDependencies.electron/*-nightly) directly with optional chaining — no more dot-path-string lookup, no intermediate result.values['dependencies.electron'] indirection, and no catch-and-reinterpret of a custom error type.

Also replaces the resolve package with createRequire(src).resolve() for locating the electron / electron-nightly package.json during version inference.

Drops ~35 transitive packages from the production install tree (roughly 27%), including bluebird, lodash.get, debug@2, read-pkg-up, normalize-package-data, hosted-git-info, semver@5, and the spdx-* / validate-npm-package-license chain.

Notes

  • import.meta.resolve was not used because its two-argument parent form is still behind --experimental-import-meta-resolve; without the flag the second argument is silently ignored, which would resolve from the wrong directory. createRequire().resolve() is the stable equivalent.
  • Node's require.resolve honors the exports field while the resolve package did not. electron and electron-nightly have no exports field, so this has no effect today.
  • BOM stripping on package.json reads is retained for parity with the old load-json-file dependency.

Also removes the now-unused src/ambient.d.ts and the stale get-package-info DEBUG namespace reference from CONTRIBUTING.md.

@MarshallOfSound MarshallOfSound requested a review from a team as a code owner April 19, 2026 10:45
Replaces get-package-info with a small async generator that walks up the
directory tree yielding parsed package.json files, and reads the needed
fields (productName/name, version, author, electron dep) directly with
optional chaining instead of dot-path string lookup. Replaces the
resolve package with createRequire().resolve() for locating the electron
package.json during version inference.

Drops ~35 transitive production dependencies including bluebird,
lodash.get, read-pkg-up, normalize-package-data, and the spdx-* tree.
Copy link
Copy Markdown
Member

@erickzhao erickzhao left a comment

Choose a reason for hiding this comment

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

Neat, enjoying the new control flow on this one!

@MarshallOfSound MarshallOfSound changed the title build: remove get-package-info and resolve dependencies fix: remove get-package-info and resolve dependencies Apr 22, 2026
@MarshallOfSound MarshallOfSound merged commit 48584a5 into main Apr 22, 2026
8 checks passed
@MarshallOfSound MarshallOfSound deleted the sam/inline-infer-deps branch April 22, 2026 00:56
@electron-npm-package-publisher
Copy link
Copy Markdown

🎉 This PR is included in version 19.1.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants