You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Which installs the `tgz` file we have just built from folder `Users/jane-lane/{your-dirs}/cypress/cli/build`.
62
62
63
+
#### Sub-package API
64
+
65
+
> How do deep imports from cypress/* get resolved?
66
+
67
+
The cypress npm package comes pre-assembled with mounting libraries for major front-end frameworks. These mounting libraries are the first examples of Cypress providing re-exported sub-packages. These sub-packages follow the same naming convention they do when they're published on **npm**, but without a leading **`@`** sign. For example:
68
+
69
+
##### An example of a sub-package: @cypress/vue, @cypress/react, @cypress/mount-utils
70
+
71
+
**Let's discuss the Vue mounting library that Cypress ships.**
72
+
73
+
If you'd installed the `@cypress/vue` package from NPM, you could write the following code.
74
+
75
+
This would be necessary when trying to use a version of Vue, React, or other library that may be newer or older than the current version of cypress itself.
76
+
77
+
```js
78
+
import { mount } from'@cypress/vue'
79
+
```
80
+
81
+
Now, with the sub-package API, you're able to import the latest APIs directly from Cypress without needing to install a separate dependency.
82
+
83
+
```js
84
+
import { mount } from'cypress/vue'
85
+
```
86
+
87
+
The only difference is the import name, and if you still need to use a specific version of one of our external sub-packages, you may install it and import it directly.
88
+
89
+
##### Adding a new sub-package
90
+
91
+
There are a few steps when adding a new sub-package.
92
+
93
+
1. Make sure the sub-package's rollup build is _self-contained_ or that any dependencies are also declared in the CLI's **`package.json`**.
94
+
2. Now, in the **`postbuild`** script for the sub-package you'd like to embed, invoke `node ./scripts/sync-exported-npm-with-cli.js` (relative to the sub-package, see **`npm/vue`** for an example).
95
+
3. Add the sub-package's name to the following locations:
96
+
-**`cli/.gitignore`**
97
+
-**`cli/scripts/post-build.js`**
98
+
-**`.eslintignore`** (under cli/sub-package)
99
+
4. DO NOT manually update the **package.json** file. Running `yarn build` will automate this process.
100
+
5. Commit the changed files.
101
+
102
+
[Here is an example Pull Request](https://github.com/cypress-io/cypress/pull/20930/files#diff-21b1fe66043572c76c549a4fc5f186e9a69c330b186fc91116b9b70a4d047902)
103
+
63
104
#### Module API
64
105
65
106
The module API can be tested locally using something like:
0 commit comments