Does pnpm fetch package.json first, for parsing “os” field? #3715
Unanswered
jjangga0214
asked this question in
Q&A
Replies: 1 comment
-
If you put these platform specific packages into optional dependencies, then it will work as you want it to work in pnpm and npm. But Yarn will still download all the package archives. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
There is
os
field in package.json.So, does pnpm(and npm/yarn/yarn2) fetch dependency's pacakge.json first, then parse the "os" field(if exists), and download the source code only if os matches?
Or, does pnpm just download every content (package.json+source) just all at once?
Context I am planning to publish a package that includes some os-specific code(compiled by go). So I have 3 compiled binaries (for windows, linux, macOS). However, each of them has a large size. Thus I want to avoid naively include them all in one package. Hence, I am thinking of separating them like @foo/win32, @foo/linux, @foo/darwin. Then letting a package named foo depend on all of them. And eventually, users install npm install foo without caring about their os. Will this separation avoid installing unnecessary dependency? For example, when npm install foo on linux, I want npm not to install @foo/win32, @foo/darwin under the hood.
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions