Skip to content
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

Does yarn fetch package.json first, for parsing “os” field? #8680

Closed
jjangga0214 opened this issue Aug 27, 2021 · 1 comment
Closed

Does yarn fetch package.json first, for parsing “os” field? #8680

jjangga0214 opened this issue Aug 27, 2021 · 1 comment

Comments

@jjangga0214
Copy link

There is os field in package.json.

So, does yarn(and yarn2/npm/pnpm) fetch dependency's pacakge.json first, then parse the "os" field(if exists), and download the source code only if os matches?

Or, does yarn 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.

@jjangga0214 jjangga0214 changed the title Does yarn fetch package.json first, for parsing “os” field? #3715 Does yarn fetch package.json first, for parsing “os” field? Aug 27, 2021
@merceyz
Copy link
Member

merceyz commented Aug 27, 2021

Duplicate of yarnpkg/berry#3353

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants