Uh oh!
There was an error while loading. Please reload this page.
feat: Move @testing-library/dom and @types/react-dom to peer dependencies - #1305
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 7bb03cc:
|
MatanBobi
left a comment
There was a problem hiding this comment.
Thanks.
Just a thought since we're doing this and bumping a major - lately we're having many issues with DTL version mismatches in RTL and user-event, do we maybe want to think about also move DTL to peerDeps?
eps1lon
commented
Apr 23, 2024
I think so. Since DTL is stateful due to the config object, having multiple versions is problematic. Ideally we wouldn't have the stateful config object to begin with but that requires a large refactor that needs coordination. We don't need to rush this in this PR though. Could you help out and prepare docs and a commit making that change? |
MatanBobi
commented
Apr 23, 2024
Sure thing, I'll get to it later this week. |
eps1lon
commented
Apr 24, 2024
Just push this commit to this branch. I don't want to go through the alpha branch shenanigans and just ship the major with one PR. |
MatanBobi
commented
Apr 25, 2024
Done. I haven't fixed the conflicts though as we have more changes coming to that file. |
Type dependencies need to match their runtime counterpart. If `foo` is a dependency, `@types/foo` needs to be one as well. If `foo` is a peer dependency, `@types/foo` needs to be one as well. This is especially apparent if the constraint on `foo` spans multiple major versions. If we'd make `@types/foo` a direct dependency, users couldn't control which major version they get. Package managers would pick the highest. By moving `@types/foo` to peer dependencies, users can control which version of `foo` and `@types/foo` they have.
MatanBobi
commented
May 28, 2024
@eps1lon Do we want to push this one forwards after seeing that the latest major release looks ok? |
eps1lon
commented
May 28, 2024
We haven't got any reports recently so this seems safe now. I don't expect bugs that require big changes i.e. if something comes up it's likely small enough to warrant a backport. Thank you for pushing this @MatanBobi |
MatanBobi
commented
Jun 1, 2024
Thanks @eps1lon. I've merged from |
@testing-library/dom and @types/react-dom to peer dependencieseps1lon
commented
Jun 3, 2024
Does |
MatanBobi
commented
Jun 3, 2024
AFAIU no, it only uses the You can feel free to remove it if you want. |
@testing-library/dom and @types/react-dom to peer dependencies@testing-library/dom and @types/react-dom to peer dependencieseps1lon
commented
Jun 3, 2024
We're using semantic-release so we have to stick with what that tool understands. |
ph-fritsche
commented
Jun 3, 2024
If you like to switch to conventional commit, it's the default config here: - name: 🚀 Releaseuses: ph-fritsche/action-release@v2env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
eps1lon
commented
Jun 3, 2024
Existing setup works for us so I'd rather not experiment. |
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [@testing-library/react](https://github.com/testing-library/react-testing-library) | devDependencies | major | [`^15.0.0` -> `^16.0.0`](https://renovatebot.com/diffs/npm/@testing-library%2freact/15.0.7/16.0.0) | --- ### Release Notes <details> <summary>testing-library/react-testing-library (@​testing-library/react)</summary> ### [`v16.0.0`](https://github.com/testing-library/react-testing-library/releases/tag/v16.0.0) [Compare Source](testing-library/react-testing-library@v15.0.7...v16.0.0) ##### Features - Move `@testing-library/dom` and `@types/react-dom` to peer dependencies ([#​1305](testing-library/react-testing-library#1305)) ([a4744fa](testing-library/react-testing-library@a4744fa)) ##### BREAKING CHANGES - `@testing-library/dom` was moved to a peer dependency and needs to be explicitly installed. This reduces the chance of having conflicting versions of `@testing-library/dom` installed that frequently caused bugs when used with `@testing-library/user-event`. We will also be able to allow new versions of `@testing-library/dom` being used without a SemVer major release of `@testing-library/react` by just widening the peer dependency. `@types/react-dom` needs to be installed if you're typechecking files using `@testing-library/react`. </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR is behind base branch, or rename PR to start with "rebase!". 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
Closes#1184
Docs: testing-library/testing-library-docs#1384
BREAKING CHANGE:
@testing-library/domwas moved to a peer dependency and needs to be explicitly installed. This reduces the chance of having conflicting versions of@testing-library/dominstalled that frequently caused bugs when used with@testing-library/user-event. We will also be able to allow new versions of@testing-library/dombeing used without a SemVer major release of@testing-library/reactby just widening the peer dependency.@types/react-domneeds to be installed if you're typechecking files using@testing-library/react.Type dependencies need to match their runtime counterpart.
If
foois a dependency,@types/fooneeds to be one as well.If
foois a peer dependency,@types/fooneeds to be one as well.This is especially apparent if the constraint on
foospans multiple major versions.If we'd make
@types/fooa direct dependency, users couldn't control which major version they get.Package managers would pick the highest.
By moving
@types/footo peer dependencies, users can control which version of@types/foothey have.In our case specifically, you'd get type mismatches of
@types/react-domif we just widen the peer dependency constraint from^18to^18 | ^19. Currently, we're already compatible with the planned React 19 features so all we'd have to do is widen the constraint on release.