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

fix(nm): declare @yarnpkg/pnp as a dependency #4958

Merged
merged 1 commit into from
Oct 13, 2022

Conversation

zkochan
Copy link
Contributor

@zkochan zkochan commented Oct 13, 2022

What's the problem this PR addresses?

Currently when using the nm package directly, there is compilation error because pnp is not in the deps:

image

How did you fix it?

...

Checklist

  • I have set the packages that need to be released for my changes to be effective.
  • I will check that all automated PR checks pass before the PR gets reviewed.

@RDIL RDIL merged commit 589e231 into yarnpkg:master Oct 13, 2022
@larixer
Copy link
Member

larixer commented Oct 13, 2022

Stop, guys @zkochan and @RDIL , it doesn't make sense. @yarnpkg/nm doesn't use anything from @yarnpkg/pnp except types. Have you tried to figure out deeper before just adding @yarnpkg/pnp as a prod dependency?

@larixer
Copy link
Member

larixer commented Oct 13, 2022

In other words the compiled code of @yarnpkg/nm has no imports from @yarnpkg/pnp at all, it does not makes sense to me, that @yanrpkg/pnp is a production dependency in this case, what do you think?

@arcanis
Copy link
Member

arcanis commented Oct 13, 2022

Fwiw I personally have no qualms with it being a regular dependency, my thinking being that regular deps are meant to be all the deps required for a package to work properly once installed by users, whether it's at runtime or typecheck.

Anecdotically, it's the same interpretation we follow in @yarnpkg/extensions:

Peer deps also don't seem a right fit to me, because they delegate the responsibility of installing packages to the users, which goes against what Yarn is for (managing packages / versions). The only reason we'd do this would be for what essentially amounts to optional size optimization, and I admit I'm not a fan of this tradeoff.

Ideally it'd be nice to support a typesDependencies field, but that would require cooperation between all package managers to be useful, and perhaps we should wait to see what happens of the TC39 proposal regarding types.

@larixer
Copy link
Member

larixer commented Oct 13, 2022

Fwiw I personally have no qualms with it being a regular dependency, my thinking being that regular deps are meant to be all the deps required for a package to work properly once installed by users, whether it's at runtime or typecheck.

What is your objective point here, except your sole opinion?

Anecdotically, it's the same interpretation we follow in @yarnpkg/extensions:

We could have used devDependencies in this case as well, so I don't see how this can be considered as a counterpoint at all.

Let's discuss seriously.

@zkochan zkochan deleted the fix-nm-deps branch October 13, 2022 09:34
@larixer
Copy link
Member

larixer commented Oct 13, 2022

I think in this case the @yarnpkg/pnp should be declared in peerDependencies instead. I cannot find a better specification for package.json fields then from here:
https://docs.npmjs.com/cli/v8/configuring-npm/package-json#peerdependencies
and assume the majority of the people rely on the meanings documented there.

Read the section about peerDependencies and compare with this case. @yarnpkg/nm does not require @yarnpkg/pnp it just expresses compatibility on the interface level, that's why @yarnpkg/pnp should be a peer dependency.

@zkochan
Copy link
Contributor Author

zkochan commented Oct 13, 2022

Compatibility is already guaranteed by the types. Not compatible code will not compile. I have not yet seen any types declared as peer dependencies. It would worsen the DX. Especially as Yarn doesn't automatically install the peer deps.

@larixer
Copy link
Member

larixer commented Oct 13, 2022

Compatibility is already guaranteed by the types. Not compatible code will not compile.

Of course not compatible code will not compile, but you don't know with which version of the package it is compatible. That's why peer dependency expresses the version of the package it is compatible with.

I have not yet seen any types declared as peer dependencies.

Can't be a point in discussion.

It would worsen the DX. Especially as Yarn doesn't automatically install the peer deps.

It depends on the tools you use and how you use them. Having dependencies declared as production that are really not production can worsen your DX too, think of extra install time and extra disk space consumed by an application in the cloud.

@zkochan
Copy link
Contributor Author

zkochan commented Oct 13, 2022

The file that I need doesn't use pnp at all, so if you choose to make it a peer, it would be nice to move the hoist function to a separate package.

@merceyz merceyz changed the title fix(nm): pnp should be a prod dep of nm fix(nm): declare @yarnpkg/pnp as a dependency Oct 13, 2022
merceyz pushed a commit that referenced this pull request Nov 3, 2022
merceyz pushed a commit that referenced this pull request Nov 3, 2022
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

Successfully merging this pull request may close these issues.

4 participants