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

Add missing babel-jest dependency to react-native package #46462

Closed
wants to merge 2 commits into from

Conversation

huntie
Copy link
Member

@huntie huntie commented Sep 12, 2024

Summary:
While adding D62583337, I noticed that react-native doesn't specify babel-jest as a dependency, despite referencing it in the included jest-preset.js — instead this would need to be installed by the template/project.

If we want to change this in future, we should consider a separate react-native/jest-preset package. However, I strongly believe this is the right location for this dependency: installing react-native = all parts of it work.

(Note that in the React Native monorepo, we are using dependencies for both dev and runtime deps in packages.)

Changelog: [Internal]

Differential Revision: D62583665

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner labels Sep 12, 2024
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D62583665

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D62583665

huntie added a commit to huntie/react-native that referenced this pull request Sep 12, 2024
…6462)

Summary:
Pull Request resolved: facebook#46462

While adding D62583337, I noticed that `react-native` doesn't specify `babel-jest` as a dependency, despite referencing it in the included `jest-preset.js` — instead this would need to be installed by the template/project.

If we want to change this in future, we should consider a separate `react-native/jest-preset` package. However, I strongly believe this is the right location for this dependency: installing `react-native` = all parts of it work.

(Note that in the React Native monorepo, we are using `dependencies` for both dev and runtime deps in packages.)

Changelog: [Internal]

Reviewed By: robhogan

Differential Revision: D62583665
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D62583665

huntie added a commit to huntie/react-native that referenced this pull request Sep 13, 2024
…6462)

Summary:
Pull Request resolved: facebook#46462

While adding D62583337, I noticed that `react-native` doesn't specify `babel-jest` as a dependency, despite referencing it in the included `jest-preset.js` — instead this would need to be installed by the template/project.

If we want to change this in future, we should consider a separate `react-native/jest-preset` package. However, I strongly believe this is the right location for this dependency: installing `react-native` = all parts of it work.

(Note that in the React Native monorepo, we are using `dependencies` for both dev and runtime deps in packages.)

Changelog: [Internal]

Reviewed By: robhogan

Differential Revision: D62583665
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D62583665

huntie added a commit to huntie/react-native that referenced this pull request Sep 16, 2024
…6462)

Summary:
Pull Request resolved: facebook#46462

While adding D62583337, I noticed that `react-native` doesn't specify `babel-jest` as a dependency, despite referencing it in the included `jest-preset.js` — instead this would need to be installed by the template/project.

If we want to change this in future, we should consider a separate `react-native/jest-preset` package. However, I strongly believe this is the right location for this dependency: installing `react-native` = all parts of it work.

(Note that in the React Native monorepo, we are using `dependencies` for both dev and runtime deps in packages.)

Changelog: [Internal]

Reviewed By: robhogan

Differential Revision: D62583665
Summary:
Pull Request resolved: facebook#46465

Resolves facebook#46355.

Changelog: [Internal]

bypass-github-export-checks

Differential Revision: D62583337

Reviewed By: robhogan
…6462)

Summary:
Pull Request resolved: facebook#46462

While adding D62583337, I noticed that `react-native` doesn't specify `babel-jest` as a dependency, despite referencing it in the included `jest-preset.js` — instead this would need to be installed by the template/project.

If we want to change this in future, we should consider a separate `react-native/jest-preset` package. However, I strongly believe this is the right location for this dependency: installing `react-native` = all parts of it work.

(Note that in the React Native monorepo, we are using `dependencies` for both dev and runtime deps in packages.)

Changelog: [Internal]

Reviewed By: robhogan

Differential Revision: D62583665
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D62583665

@thymikee
Copy link
Contributor

The way it typically is handled in a project is that the Babel configuration (and hence babel-jest @babel/core @babel/preset-env specified in https://jestjs.io/docs/getting-started#using-babel) is handled on the user side. It's some ancient times, but I recall this setup was necessary for Jest to resolve Babel tooling properly especially in monorepo setups. Not sure if anything changed here, but I'd like to make sure this change is not breaking for monorepo setups out there, i.e. if they use a different version of babel-jest in their project, as this may effectively lock-in particular Jest version to a particular React Native version.

@@ -23,7 +23,6 @@
"@react-native/core-cli-utils": "0.77.0-main",
"@react-native/eslint-config": "0.77.0-main",
"@react-native/metro-config": "0.77.0-main",
"babel-jest": "^29.6.3",
Copy link
Contributor

@thymikee thymikee Sep 16, 2024

Choose a reason for hiding this comment

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

I think effectively we need babel-jest both here and in devDependencies of react-native. It's surprising to me that this monorepo setup requires devDependencies to be dependencies. Lots of unnecessary kBs sent to npm registry

@huntie
Copy link
Member Author

huntie commented Sep 16, 2024

@thymikee Oh, interesting! That's a bit awkward and undocumented 😐 I wonder to what extent we can rely on monorepo setups being "power users" and, if they need to override any built-in RN dep/devDep, they can do so with "resolutions"/constraints or equivalent.

From our point of view, shipping this with react-native is the correct setup. (Independently, I understand the frustration with the lack of devDependencies as a whole.)

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Sep 16, 2024
@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 8f1c227.

@facebook-github-bot
Copy link
Contributor

This pull request has been reverted by 259f61a.

@huntie huntie deleted the export-D62583665 branch September 17, 2024 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook Partner Reverted
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants