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

chore(v2): Add E2E test for yarn v2 #3008

Merged
merged 4 commits into from
Jul 1, 2020
Merged

chore(v2): Add E2E test for yarn v2 #3008

merged 4 commits into from
Jul 1, 2020

Conversation

SamChou19815
Copy link
Contributor

Motivation

It's very easy for us to miss some dependencies and not caught by CI, because Yarn workspace is very loose: as long as you define a dependency in package A, you can access it in package B locally since Yarn workspace try to put as many dependencies into the root node_modules as possible. Therefore, we might frequently need bug fixes like #3007 for Yarn v2 when these problems are found after a new release.

This PR tries to solve the undetectable missing dependency problem by setup an E2E test for Yarn v2. Currently, it can only pass in pnp loose mode since some of our dependencies don't properly declare their dependencies. However, we can still see the warnings printed in the log so it can guide us to fix these problems upstream in the future.

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

CI passes.

Related PRs

(If this PR adds or changes functionality, please take some time to update the docs at https://github.com/facebook/docusaurus, and link to your PR here.)

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Jun 28, 2020
@docusaurus-bot
Copy link
Contributor

docusaurus-bot commented Jun 28, 2020

Deploy preview for docusaurus-2 ready!

Built with commit 1fa41be

https://deploy-preview-3008--docusaurus-2.netlify.app

The purpose of e2e test is to ensure that the docusaurus inited website can stand on its own. The root node_modules remain accessible according to how node resolution works and it might interfere with the test. Remove them for safety.
@SamChou19815 SamChou19815 marked this pull request as ready for review June 28, 2020 18:15
yarn config set npmRegistryServer http://localhost:4873
yarn config set unsafeHttpWhitelist --json '["localhost"]'
yarn install
yarn add @mdx-js/react
Copy link
Collaborator

Choose a reason for hiding this comment

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

wonder what's the purpose of adding mdx react here?

Copy link
Contributor Author

@SamChou19815 SamChou19815 Jun 30, 2020

Choose a reason for hiding this comment

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

Some docusaurus client code injects import '@mdx-js/react' on user's behalf, so it appears to yarn that user's project requires this dependency, not docusaurus. Therefore, user's package.json must declare this dependency otherwise yarn v2 cannot resolve it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

wouldn't it be better to include the dependency on the init template directly? because this might affect yarn 2 users using the init template too no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@slorber
Copy link
Collaborator

slorber commented Jun 29, 2020

Not very familar with yarn 2 but LGTM

@slorber
Copy link
Collaborator

slorber commented Jun 29, 2020

Btw, seems related but we should reenable the eslint import/no-extraneous-dependencies once missing deps fixed.

Also, I tried to install this tool that worked great on another monorepo, but my short attempt was not so great (unfortunately, it's not very configurable so you need to conform to all the checks apparently). If you are interested to give it another try: https://github.com/Thinkmill/manypkg

@SamChou19815 SamChou19815 requested a review from yangshun as a code owner July 1, 2020 00:45
@slorber slorber merged commit cf5babd into facebook:master Jul 1, 2020
@slorber
Copy link
Collaborator

slorber commented Jul 1, 2020

LGTM

@slorber slorber added pr: bug fix This PR fixes a bug in a past release. pr: maintenance This PR does not produce any behavior differences to end users when upgrading. labels Jul 1, 2020
@SamChou19815 SamChou19815 deleted the yarn-2-e2e-test branch July 1, 2020 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: bug fix This PR fixes a bug in a past release. pr: maintenance This PR does not produce any behavior differences to end users when upgrading.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants