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: use resolve-package-path to resolve installed dependency versions more reliably #26033

Merged
merged 13 commits into from
Mar 8, 2023

Conversation

astone123
Copy link
Contributor

@astone123 astone123 commented Mar 6, 2023

Additional details

There are some dependencies that we can't resolve with require.resolve, because of one of the following reasons:

  • The package has exports defined, but package.json is not one of the exports
  • Some packages don't have entrypoints (like in the case of react-scripts, there is no entrypoint, just a bin).

We need to find a way around these limitations so that we can figure out if a dependency is installed, and if it is, which version is installed. Lachlan and I found a package called resolve-package-path that does the trick, working around the exports and entrypoint limitations and allowing us to detect dependencies that are installed.

TLDR: It looks like we can't use require.resolve to figure out which dependencies of which packages are installed.

Further reading

Steps to test

  1. yarn create vite my-app --template react
  2. Install dependencies in my-app
  3. cd into node_modules/react, remove package.json from the exports key in package.json
  4. Open Launchpad with my-app and click Component Testing
  5. Verify that the framework and bundler (React and Vite) are automatically detected and are selected in the dropdowns

How has the user experience changed?

There should be no noticeable change for the user

PR Tasks

@astone123 astone123 self-assigned this Mar 6, 2023
@cypress
Copy link

cypress bot commented Mar 7, 2023

3 flaky tests on run #44605 ↗︎

0 5116 74 0 Flakiness 3

Details:

Merge branch 'launchpad-dep-resolution-exports' of github.com:cypress-io/cypress...
Project: cypress Commit: 59f89ca2be
Status: Passed Duration: 14:02 💡
Started: Mar 8, 2023 4:23 PM Ended: Mar 8, 2023 4:37 PM
Flakiness  cypress/e2e/cypress/cypress.cy.js • 3 flaky tests • 5x-driver-electron

View Output Video

Test Artifacts
... > correctly returns currentRetry Output Video
... > correctly returns currentRetry Output Video
... > correctly returns currentRetry Output Video

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings.

@astone123 astone123 requested a review from a team March 7, 2023 03:05
@astone123 astone123 requested a review from a team March 7, 2023 04:59
@astone123 astone123 requested a review from a team March 7, 2023 15:53
@mike-plummer
Copy link
Contributor

@astone123 Still seeing a lot of test failures here, happy to ✅ once those are resolved

@astone123
Copy link
Contributor Author

@mike-plummer okay we should be good now

@astone123 astone123 merged commit 189cd92 into develop Mar 8, 2023
@astone123 astone123 deleted the launchpad-dep-resolution-exports branch March 8, 2023 21:47
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.

Launchpad CT onboarding dependencies screen not always reliable
3 participants