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

Use npm instead of Yarn #47

Merged
merged 7 commits into from
Nov 14, 2020
Merged

Use npm instead of Yarn #47

merged 7 commits into from
Nov 14, 2020

Conversation

nickserv
Copy link
Member

No description provided.

@patrickhulce
Copy link
Collaborator

thanks @nickmccurdy! why though? this removes any package lock mechanism 😅

@nickserv
Copy link
Member Author

This organization uses npm without a package lock for libraries, and with a package lock for apps. I'm just making pull requests to keep things consistent for contributors.

@patrickhulce
Copy link
Collaborator

Ah sorry I missed that discussion is there a link anywhere to the rationale? :)

@nickserv
Copy link
Member Author

nickserv commented Sep 10, 2020

In the gitignores of other libraries:

# these cause more harm than good
# when working with contributors
package-lock.json
yarn.lock

https://github.com/testing-library/dom-testing-library/blob/master/.gitignore#L6-L7

I believe Kent has a more in-depth explanation somewhere but I couldn't find it.

@patrickhulce
Copy link
Collaborator

I see, thanks!

I can understand the library dependency angle, but I'm not sure I agree with the rationale when working with devDeps that actually produce distributable assets like pptr-testing-library does though (which is much more similar to the app situation than library dependencies). Removing the lockfile here feels a bit like policy matching for the sake of policy matching rather than actually following the reasoning of the policy :/

How would you feel about replacing with a package lock?

@nickserv
Copy link
Member Author

nickserv commented Nov 9, 2020

Are you referring to how dependent projects would install versions of pptr-testing-library dependencies? If so, it would be the same, as package-lock.json and yarn.lock are not used to install published packages, only local packages. package.json can be used to lock top level dependencies and npm-shrinkwrap.json can be used to lock nested dependencies (npm only).

Personally I usually prefer using lock files, but it's not the preference of the organization it seems, and I think not locking dependencies can help with testing different installations in this situation.

@patrickhulce
Copy link
Collaborator

I'm aware of how lock files work :)

I am not referring to dependent projects. pptr-testing-library in CI builds a bundle of javascript that is distributed as part of our own npm package. The lock file ensures that there are no unexpected changes to this bundle and given that we do string replacement and relatively hacky things to make this work, I am concerned that unexpected transitive dependency changes could result in breakages.

I understand the spirit of the ban on lock files, that a library author should ensure their library can handle unexpected dependency versions that real users might install. This package goes out of its way to ensure we handle different versions, above and beyond what simply removing a lock file would do. Enforcing a lock file ban here would increase the volatility and reproducibility of published versions of this package while not actually reaping any of the stated benefits beyond the steps we've already taken.

I appreciate that you're seeking consistency across the organization, but consistency in reasoning for positive outcomes should prevail over consistency for file existence.

@nickserv
Copy link
Member Author

Alright, I'll add a lock file for npm in this case.

We have two options, what would you prefer?

  1. Use npm 6, which is stable and used by more users, guessing dependency versions from node_modules in a way that may conflict
  2. Use npm 7, which is in preview and requires an explicit install for now, which can accurately import versions from yarn.lock

@patrickhulce
Copy link
Collaborator

Thanks @nickmccurdy!

Use npm 7, which is in preview and requires an explicit install for now, which can accurately import versions from yarn.lock

This sounds great :)

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @nickmccurdy! 🎉

.npmignore Show resolved Hide resolved
@nickserv
Copy link
Member Author

nickserv commented Nov 10, 2020

This should work locally after running npm install --global npm@7 and npm install (or just npx npm@7 install to use it temporarily without upgrading your global npm). At this point I'm waiting to see if CI is using npm 7 yet.

@nickserv
Copy link
Member Author

It seems like npm 7 is successfully installed now. Can we get another review please?

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still LGTM :)

@patrickhulce patrickhulce merged commit 156d45c into master Nov 14, 2020
@patrickhulce patrickhulce deleted the nickmccurdy-patch-1 branch November 14, 2020 17:40
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.

2 participants