feat: build codegen on postinstall#46227
Closed
okwasniewski wants to merge 1 commit into
Closed
Conversation
Collaborator
huntie
approved these changes
Aug 27, 2024
Contributor
|
@huntie has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Contributor
Collaborator
|
This pull request was successfully merged by @okwasniewski in 0cb97f0 When will my fix make it into a release? | How to file a pick request? |
Saadnajmi
added a commit
to Saadnajmi/react-native-macos
that referenced
this pull request
Sep 10, 2024
This reverts commit 0cb97f0.
facebook-github-bot
pushed a commit
that referenced
this pull request
Sep 16, 2024
Summary: This reverts commit 0cb97f0. Revert this commit that adds a `post install` script for a couple of reasons: 1. (EDIT: This turns out to be unrelated) The `postinstall` script causes `yarn install` to fail on React Native macOS, where we use Yarn 4. I'm not entirely sure why, but I probably won't debug it for the rest of the reasons. 2. `postinstall` scripts (at least inside Microsoft) are viewed as a security risk. Any package in your dependency tree can get compromised, add the phase, and run arbitrary code. This has happened in the past with React Native past if I recall correctly. As such, we disable `postinstall` scripts in many of our repos (including `rnx-kit` and `react-native-test-app`). 3. The issue this is trying to solve is to help newcomers avoid a stale cache when they switch branches in the React Native monorepo and only run `yarn install`. I think it would be sufficient to add some documentation somewhere that it is expected one runs `yarn && yarn build` to use this repo locally? That's a fairly common practice in monorepos, at least ones inside Microsoft. ## Changelog: [INTERNAL] [SECURITY] - Remove post install script phase in the React Native monorepo Pull Request resolved: #46420 Test Plan: CI should pass Reviewed By: christophpurrer, robhogan, cortinico, rshest Differential Revision: D62755022 Pulled By: huntie fbshipit-source-id: bf94ed33e3e451ea337ef7a6984f7ba964d0b212
blakef
pushed a commit
that referenced
this pull request
Sep 23, 2024
Summary: This reverts commit 0cb97f0. Revert this commit that adds a `post install` script for a couple of reasons: 1. (EDIT: This turns out to be unrelated) The `postinstall` script causes `yarn install` to fail on React Native macOS, where we use Yarn 4. I'm not entirely sure why, but I probably won't debug it for the rest of the reasons. 2. `postinstall` scripts (at least inside Microsoft) are viewed as a security risk. Any package in your dependency tree can get compromised, add the phase, and run arbitrary code. This has happened in the past with React Native past if I recall correctly. As such, we disable `postinstall` scripts in many of our repos (including `rnx-kit` and `react-native-test-app`). 3. The issue this is trying to solve is to help newcomers avoid a stale cache when they switch branches in the React Native monorepo and only run `yarn install`. I think it would be sufficient to add some documentation somewhere that it is expected one runs `yarn && yarn build` to use this repo locally? That's a fairly common practice in monorepos, at least ones inside Microsoft. ## Changelog: [INTERNAL] [SECURITY] - Remove post install script phase in the React Native monorepo Pull Request resolved: #46420 Test Plan: CI should pass Reviewed By: christophpurrer, robhogan, cortinico, rshest Differential Revision: D62755022 Pulled By: huntie fbshipit-source-id: bf94ed33e3e451ea337ef7a6984f7ba964d0b212
This was referenced Apr 1, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
This PR solves a small issue I've encountered when working with the repo.
When changing branches we often run
yarnto reinstall dependencies (let's say we change from 0.74-stable to main).There are lots of changes between those two versions in the
react-native-codegenpackage. This causes an issue when we install pods inpackages/rn-testerthe old version of codegen is used (the one cached from 0.74-stable) leading to a big error that's hard to solve at first.This PR solves this by building codegen on
postinstall. I've seen many newcomers blocked by this issue (and rerunningyarnis the natural thing to do in this situation)Changelog:
[INTERNAL] [ADDED] - Build codegen on postinstall when working with the monorepo
Test Plan:
Run
yarn