prebuild-install
prebuild-install copied to clipboard
Mirroring with custom host much harder compared with node-pre-gyp
Context
- Hosting of binary on custom host
- Package with working mirroring migrated from node-pre-gyp to prebuild-install
- Migration did not change host
- https://github.com/prebuild/prebuild-install/blob/8250adf958fcec6fb3ddfcd7dd5ceb0e0e29e419/util.js#L46-L60
Issue
Even though prebuild-install seems to have a similar option set compared to node-pre-gyp, mirroring is much harder to achieve and requires proper planning from the package maintainer.
Requirements for mirroring a binary that relies on node-pre-gyp:
- (consumer) Mirror the
<package.json>.binary.host - (consumer) Configure the npm
<package>_binary_host_mirrorvariable to point to the mirror
Requirements for mirroring a binary that relies on prebuild-install with a custom host:
- (package maintainer) Need to make sure that
<package.json>.binary.remote_pathends with the hardcoded/{tag_prefix}{version}/pattern. In caseremote_pathdoes not already include{tag_prefix}, prebuild-install must be invoked with--tag-prefix= - (consumer) Mirror the
<package.json>.binary.host - (consumer) In case interoperability with node-pre-gyp is needed (e.g. case of realm library)
- use the
<package>_binary_hostnpm variable, and keep<package>_binary_host_mirrorunchanged - configure
<package>_binary_hostnpm variable to include whatever is needed so that the concatenation of<package>_binary_host+/{tag_prefix}{version}/(taking into consideration that{tag_prefix}is controlled by package maintainer) matches the HTTP mirror
- use the
An example of such difficulty can be seen at https://github.com/realm/realm-js/issues/4667#issuecomment-1163201076
Is there a chance to simplify binary mirroring?