-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
feat: embedding mount into the cypress binary (real dependency) #20930
feat: embedding mount into the cypress binary (real dependency) #20930
Conversation
Thanks for taking the time to open a PR!
|
Test summaryRun details
View run in Cypress Dashboard ➡️ Flakiness
This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard |
… appropriate paths
It works!!!! Going to remove the circle changes. |
…g-mount-with-real-package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! We can probably look into symlinking the dirs for local development in a follow up PR
"require": "./react/dist/cypress-react.cjs.js" | ||
}, | ||
"./mount-utils": { | ||
"require": "./mount-utils/dist/index.js" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No import entry for mount-utils?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No it wasn't built for ESM.
Because only cypress-react and cypress-vue consume it and they have an esm export it's not (currently) a problem.
We have tech debt to convert all of our npm/* packages to be esm-first and share the same rollup + typescript compilation settings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code seems fine, just have a comment around how we can test this and the end goal (we will migrate to import ... from 'cypress/vue'
internally? How do we QA and verify this works (no tests for it so far).
console.log('Writing to CLI package.json for', exportName) | ||
|
||
fs.writeFileSync(path.join(cliPath, 'package.json'), output, 'utf-8') | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tiniest thing but this seems like pretty important logic to test - do we need some kind of basic test to ensure that the package.json
updates correctly, and that import { mount } from 'cypress/vue
is actually working? We don't have any coverage for this right now, from what I can see.
I wonder if we can update all internal code to use the deep import syntax in the future. Is this something we plan to do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can test it by adding code here cypress-io/cypress-example-kitchensink#528
I'll do that. It'll break all other pipelines until this is merged, maybe I'll create a new branch for it (in kitchensink).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was also wondering if we can convert a couple of the existing system tests to import { mount } from 'cypress/vue'
rather than import { mount } from '@cypress/vue'
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That probably only works in test-binary
, where we have tests that run in a docker container against the compiled binary. But still worth looking into. Just an extremely simple 'can import' test there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah in general I feel uncomfortable that we don't have a lot of post-build infrastructure for testing the output of Circle CI's build scripts. The kitchen sink is the right place. I put a PR up above that will at least fail if those packages aren't declared in the exports map.
@@ -22,6 +22,10 @@ includeTypes.forEach((folder) => { | |||
shell.cp('-R', source, 'build/types') | |||
}) | |||
|
|||
// TODO: Add a typescript or rollup build step |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a github issue for this we can link? Have been trying to do TODO: blah, https://github.com/blahblah
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There isn't right now.
Looks good to me. I'd love to see a binary system test to cover this, but if you want to hold off for a separate PR on that, I'll approve this one as-is. |
Approach
This PR essentially copies the built libraries from npm/vue, npm/react, and npm/mount-utils and keeps the cli/package.json's exports map up to date.
This avoids making changes to specific dev-servers or relying on specific bundler features like
resolve.alias
.Resources
User facing changelog
Cypress users no longer have to install the Vue or React mounting libraries separately when mounting components. If you are using Vue 3 or React, you can remove those dependencies from your
package.json
entirely and replace the imports to the newly supportedcypress/vue
andcypress/react
namespaces.For Vue 2 users, a separate pull request will add support for importing mount from
cypress/vue-2
.Before: Externally Install Mounting Libs
Mounting libraries are always explicitly imported from the Cypress npm organization namespace.
After: Bundling Mounting Libs
Mounting libraries are shipped with Cypress, and are exposed as subpaths form the Cypress namespace. This is done as part of the cli build process.
This API is supported via the
cypress
package'sexports
map as defined in the package.json.