You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The reason will be displayed to describe this comment to others. Learn more.
I was hopeful for this originally but based on my testing no, I don't think so.
We need to know relative paths between packages at compile time, prior to running npm publish, to ensure rpath values embedded in binaries are correct.
However yarn "unplugs" npm tarballs into directories where the path contains a content-based hash of the npm-published tarball. You can probably see the catch 22 situation here; a tarball cannot contain its own hash.
We need to know all the possible locations that the @img/sharp-libvips-<platform> packages will be on the filesystem relative to the @img/sharp-<platform> packages.
This allows libvips binaries to be published independently of sharp binaries, which for example allows (for Linux and macOS) new releases of sharp without also downloading all of libvips and its dependencies every time.
My understanding of yarn Plug'n'Play is that it unpacks npm-published tarballs into directories with names that contain a hash e.g. @img-sharp-darwin-x64-npm-0.33.0-91623871fa. yarn exposes this at runtime via require.resolve but we need to know the 91623871fa section of this directory name at build time, before anything is published to npm.
004fff9
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.
Would unplugging be enough for Yarn PnP? https://yarnpkg.com/cli/unplug
004fff9
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 was hopeful for this originally but based on my testing no, I don't think so.
We need to know relative paths between packages at compile time, prior to running
npm publish
, to ensurerpath
values embedded in binaries are correct.However yarn "unplugs" npm tarballs into directories where the path contains a content-based hash of the npm-published tarball. You can probably see the catch 22 situation here; a tarball cannot contain its own hash.
004fff9
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.
Do you have details? Why do you need to hardcode a relative path? Can't
require.resolve
be used to get the path to the package you're looking for?004fff9
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.
At compile time, sharp binaries (essentially shared library files) are built with a series of relative paths to the libvips shared libraries.
Here are the values for Linux (macOS is similar, Windows uses a totally different approach):
sharp/src/binding.gyp
Lines 176 to 179 in 004fff9
We need to know all the possible locations that the
@img/sharp-libvips-<platform>
packages will be on the filesystem relative to the@img/sharp-<platform>
packages.This allows libvips binaries to be published independently of sharp binaries, which for example allows (for Linux and macOS) new releases of sharp without also downloading all of libvips and its dependencies every time.
My understanding of yarn Plug'n'Play is that it unpacks npm-published tarballs into directories with names that contain a hash e.g.
@img-sharp-darwin-x64-npm-0.33.0-91623871fa
. yarn exposes this at runtime viarequire.resolve
but we need to know the91623871fa
section of this directory name at build time, before anything is published to npm.004fff9
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 may be wrong, but I think you may be able to avoid the hardcode by using a gyp variable; similar to what you do here, you should be able to do:
004fff9
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.
Thanks Maël, I've created #3888 to track this.
004fff9
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.
sharp v0.33.1 now provides support for yarn Plug'n'Play.