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

Better error message when missing entry file #29012

Closed
wants to merge 2 commits into from

Conversation

petrbela
Copy link
Contributor

Summary

If the entry file has been renamed (e.g., to index.ts), the script currently fails silently and prints out that the bundle file does not exist.

This change will print the correct error message instead.

Changelog

[iOS] [Fixed] - Better error message when missing entry file

Test Plan

N/A

If the entry file has been renamed (e.g., to `index.ts`), the script currently fails silently and prints out that the bundle file does not exist.

This change will print the correct error message instead.
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 31, 2020
@react-native-bot react-native-bot added Bug Platform: iOS iOS applications. labels May 31, 2020
Copy link
Contributor

@thymikee thymikee left a comment

Choose a reason for hiding this comment

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

👍

@petrbela
Copy link
Contributor Author

petrbela commented Jun 2, 2020

The failing tests seem to be unrelated... Is there anything I need to do about them?

@thymikee
Copy link
Contributor

thymikee commented Jun 2, 2020

You can rebase to latest master and see if that helps. But anyway, now is the moment we wait for a Facebook employee to import it and verify

fi

if [[ $DEV != true && ! -f "$ENTRY_FILE" ]]; then
echo "error: Entry file $ENTRY_FILE does not exist. If you use another file as your entry point, pass ENTRY_FILE=myindex.js" >&2
Copy link

Choose a reason for hiding this comment

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

I think it's a typo.
It should have been: "Error: entry file...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure what should be correct but error: File ... case is already used towards the end of this file so I followed the same pattern.

@kiranjd
Copy link

kiranjd commented Jun 17, 2020 via email

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@TheSavior has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Jun 18, 2020
@facebook-github-bot
Copy link
Contributor

@TheSavior merged this pull request in e73208e.

janicduplessis added a commit to janicduplessis/react-native that referenced this pull request Jul 29, 2020
janicduplessis added a commit to janicduplessis/react-native that referenced this pull request Oct 8, 2020
janicduplessis added a commit to janicduplessis/react-native that referenced this pull request Oct 21, 2020
janicduplessis added a commit to janicduplessis/react-native that referenced this pull request Oct 31, 2020
janicduplessis added a commit to janicduplessis/react-native that referenced this pull request Nov 23, 2020
janicduplessis added a commit to janicduplessis/react-native that referenced this pull request Jan 24, 2021
janicduplessis added a commit to janicduplessis/react-native that referenced this pull request Feb 18, 2021
janicduplessis added a commit to janicduplessis/react-native that referenced this pull request Mar 14, 2021
janicduplessis added a commit to janicduplessis/react-native that referenced this pull request Mar 14, 2021
janicduplessis added a commit to janicduplessis/react-native that referenced this pull request Apr 29, 2021
janicduplessis added a commit to janicduplessis/react-native that referenced this pull request May 2, 2021
janicduplessis added a commit to janicduplessis/react-native that referenced this pull request May 12, 2021
janicduplessis added a commit to janicduplessis/react-native that referenced this pull request May 13, 2021
janicduplessis added a commit to janicduplessis/react-native that referenced this pull request Jun 4, 2021
janicduplessis added a commit to janicduplessis/react-native that referenced this pull request Jun 16, 2021
janicduplessis added a commit to janicduplessis/react-native that referenced this pull request Jun 24, 2021
janicduplessis added a commit to janicduplessis/react-native that referenced this pull request Jul 8, 2021
janicduplessis added a commit to janicduplessis/react-native that referenced this pull request Jul 15, 2021
janicduplessis added a commit to janicduplessis/react-native that referenced this pull request Aug 2, 2021
janicduplessis added a commit to janicduplessis/react-native that referenced this pull request Aug 19, 2021
facebook-github-bot pushed a commit that referenced this pull request Sep 1, 2021
Summary:
The original $ENTRY_FILE check was added in #29012 to help catch misconfiguration for the entry JS file. That turned out breaking some RNTester builds/tests, so #29263 was added to accommodate the fact that RNTester .xcodeproj file has its own directory hierarchy.

The 2nd PR had multiple issues:
* It is incorrect to assume that the $ENTRY_FILE always exists in the parent dir of the .xcodeproj location. This caused an issue in RC 0.66: react-native-community/releases#249 (comment)
* RNTester has since moved to packages/rn-tester/ (from RNTester/), hence breaking that assumption

It turns out RNTester .xcodeproj has incorrectly misconfigured this JS bundling step (not sure since when). The original script invocation passed in the correct path for `RNTesterApp.ios.js`, but as an arg to the `react-native-xcode.sh` instead of by setting `ENTRY_FILE` env var.

So this diff does 2 things:
* Undid #29263
* Fix RNTester JS bundling invocation to set the ENTRY_FILE correctly

{F659123377}

Changelog: [iOS][Fixed] Unbreak $ENTRY_FILE handling for JS bundling

Reviewed By: lunaleaps

Differential Revision: D30690900

fbshipit-source-id: 7c5802b3eac56c0456edcd4b7478bfa4af48fc27
lunaleaps pushed a commit that referenced this pull request Sep 1, 2021
Summary:
The original $ENTRY_FILE check was added in #29012 to help catch misconfiguration for the entry JS file. That turned out breaking some RNTester builds/tests, so #29263 was added to accommodate the fact that RNTester .xcodeproj file has its own directory hierarchy.

The 2nd PR had multiple issues:
* It is incorrect to assume that the $ENTRY_FILE always exists in the parent dir of the .xcodeproj location. This caused an issue in RC 0.66: react-native-community/releases#249 (comment)
* RNTester has since moved to packages/rn-tester/ (from RNTester/), hence breaking that assumption

It turns out RNTester .xcodeproj has incorrectly misconfigured this JS bundling step (not sure since when). The original script invocation passed in the correct path for `RNTesterApp.ios.js`, but as an arg to the `react-native-xcode.sh` instead of by setting `ENTRY_FILE` env var.

So this diff does 2 things:
* Undid #29263
* Fix RNTester JS bundling invocation to set the ENTRY_FILE correctly

{F659123377}

Changelog: [iOS][Fixed] Unbreak $ENTRY_FILE handling for JS bundling

Reviewed By: lunaleaps

Differential Revision: D30690900

fbshipit-source-id: 7c5802b3eac56c0456edcd4b7478bfa4af48fc27
janicduplessis added a commit to janicduplessis/react-native that referenced this pull request Sep 9, 2021
janicduplessis added a commit to janicduplessis/react-native that referenced this pull request Sep 9, 2021
janicduplessis added a commit to janicduplessis/react-native that referenced this pull request Sep 30, 2021
janicduplessis added a commit to janicduplessis/react-native that referenced this pull request Oct 19, 2021
janicduplessis added a commit to janicduplessis/react-native that referenced this pull request Oct 21, 2021
janicduplessis added a commit to janicduplessis/react-native that referenced this pull request Nov 8, 2021
janicduplessis added a commit to janicduplessis/react-native that referenced this pull request Nov 15, 2021
janicduplessis added a commit to janicduplessis/react-native that referenced this pull request Nov 25, 2021
janicduplessis added a commit to janicduplessis/react-native that referenced this pull request Nov 30, 2021
facebook-github-bot pushed a commit that referenced this pull request Jun 10, 2022
Summary:
Reverts #29012

It is not really possible to properly validate if ENTRY_FILE exists since it is resolved by metro, and the server is not always running from the app root, like in a monorepo with multiple RN apps running on the same metro server.

In my case I run metro on the repo root and entry file will be something like `apps/app/index.js`. `-f "$ENTRY_FILE"` will fail since the script is run from the project folder (`PROJECT_ROOT`, in my case the `apps/app` folder, so it tries to resolve `apps/app/apps/app/index.js`).

I don't think this check is actually useful since metro will report the error if the entry file is invalid (fixed in #30150). The error is not as user friendly, but I think it is still fine. Maybe it could be improved in metro.

## Changelog

[iOS] [Fixed] - Don't validate ENTRY_FILE in react-native-xcode.sh

Pull Request resolved: #32762

Test Plan:
Before

<img width="854" alt="image" src="https://user-images.githubusercontent.com/2677334/146100834-39310c9f-1767-496a-8698-1026726a1120.png">

After if file is actually missing

<img width="987" alt="image" src="https://user-images.githubusercontent.com/2677334/146100893-d01e2247-c787-4174-ac60-2f308c338c8f.png">

After if file exists, builds successfully.

Reviewed By: cortinico

Differential Revision: D37066073

Pulled By: cipolleschi

fbshipit-source-id: 8f6b149099a39d9179996bb965daa6cd9e06feac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. Platform: iOS iOS applications.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants