-
Notifications
You must be signed in to change notification settings - Fork 176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: allow using forks for prebuilt modules #1155
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this is gonna trip false positives, especially on @namespace/prebuilds
. This is a massive edge case I'd rather cause slightly more work for folks doing this than Just Guess And Hope and negatively impact everyone else.
If we can come up with a good heuristic for identifying forks beyond just "is the suffix still the same" I'd be down.
E.g. Maybe we can check other fields in the suspect package.json
such as repo
or something and see if it matches the upstream repo url.
Either that or letting modules provide a field in the package.json that we specifically read and understand. E.g. packageJSON.electronRebuildConfig = { moduleType: 'prebuilds', builderModuleName: '@foo/prebuilds' }
The nice thing about our current architecture is that even making the wrong assumption will fallback gracefully. rebuild/src/module-rebuilder.ts Lines 144 to 155 in 9ebf9bd
In each case, even if rebuild/src/module-rebuilder.ts Lines 66 to 78 in 9ebf9bd
Looking through the public packages for node-pre-gyp, prebuildify, and prebuild-install I see no false positives that would cause any fatal error.
I was considering this when looking through node-pre-gyp forks sorted by popularity on npmjs. Enough forks change the repo URL to point to their own fork where this probably wouldn't be reliable enough. Using the rebuild/src/module-type/node-pre-gyp.ts Lines 14 to 21 in f182a4f
rebuild/src/module-type/node-pre-gyp.ts Lines 44 to 46 in f182a4f
This is a good way to eliminate the possibility of false positives, but requires more work for folks which I'd hopefully like to avoid. In summary, I'm less concerned by false positives since
The motivation behind this PR is to use a fork of node-pre-gyp. If we're concerned about a particular prebuild module, I'd be open to reducing the scope of this change to only support forks of node-pre-gyp. That'd at least reduce the blast radius of potential false positives. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed that given other code stars would have to align to false-positive. CI is still broken, but approving the concept
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1155 +/- ##
==========================================
- Coverage 76.99% 76.80% -0.19%
==========================================
Files 21 21
Lines 765 776 +11
Branches 144 150 +6
==========================================
+ Hits 589 596 +7
- Misses 122 124 +2
- Partials 54 56 +2 ☔ View full report in Codecov by Sentry. |
🎉 This PR is included in version 3.6.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
It may sometimes be necessary to fork a prebuilt module package to fix an issue. In such cases, the rebuilder can miss prebuilt modules, forcing them to be built from source.
To avoid this, the module rebuilders will now also search for possible forked packages.
@mapbox/node-pre-gyp
may instead benode-pre-gyp
or@namespace/node-pre-gyp
prebuild-install
may instead be@namespace/prebuild-install
prebuilds
may instead be@namespace/prebuilds