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

lazily import metro-hermes-compiler #856

Closed

Conversation

EvanBacon
Copy link
Contributor

Summary

  • There are general performance improvements from conditionally importing Hermes.
  • metro-hermes-compiler is doing some gnarly error handling that makes debugging Metro quite painful.

If you get an error in Metro after metro-hermes-compiler has been loaded, it will look something like:

Screen Shot 2022-08-23 at 1 28 43 PM

This PR doesn't fix the core issue but it does alleviate Metro web and JSC development where Hermes is not used:

TypeError [ERR_INVALID_ARG_TYPE]: The "to" argument must be of type string. Received undefined
    at new NodeError (node:internal/errors:371:5)
    at validateString (node:internal/validators:119:11)
    at Object.relative (node:path:1192:5)
    at MetroTerminalReporter._getBundleStatusMessage (/Users/evanbacon/Documents/GitHub/expo/packages/@expo/cli/build/src/start/server/metro/MetroTerminalReporter.js:44:41)
    at /Users/evanbacon/Documents/GitHub/expo/node_modules/metro/src/lib/TerminalReporter.js:393:14
    at Array.map (<anonymous>)
    at MetroTerminalReporter._getStatusMessage (/Users/evanbacon/Documents/GitHub/expo/node_modules/metro/src/lib/TerminalReporter.js:392:8)
    at MetroTerminalReporter.update (/Users/evanbacon/Documents/GitHub/expo/node_modules/metro/src/lib/TerminalReporter.js:423:31)
    at Object.update (/Users/evanbacon/Documents/GitHub/expo/packages/@expo/cli/build/src/start/server/metro/instantiateMetro.js:21:30)
    at Server.requestProcessor [as _processBundleRequest] (/Users/evanbacon/Documents/GitHub/metro/packages/metro/src/Server.js:653:22)
    at async Server._processRequest (/Users/evanbacon/Documents/GitHub/metro/packages/metro/src/Server.js:504:9)

Test plan

Throw an error somewhere in the resolver, Metro will throw a reasonable Node error instead of the Hermes error.

@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. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Aug 23, 2022
@facebook-github-bot
Copy link
Contributor

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

@robhogan
Copy link
Contributor

Incidentally, the root cause of the gnarly error handling is the arguments we (used to) pass to Emscripten - we fixed that over in facebook/hermes#698 but haven't actually updated Metro's Hermes build since.

For the moment it's mostly unused even internally, and requiring it lazily is the best option.

@EvanBacon
Copy link
Contributor Author

Interesting, thanks for the additional info @robhogan!

EvanBacon added a commit to expo/expo that referenced this pull request Oct 19, 2023
# Why

Most of the [Exotic
mode](https://blog.expo.dev/drastically-faster-bundling-in-react-native-a54f268e0ed1)
performance benefits have been integrated in the default Expo CLI
bundling pipeline (e.g. [less AST
cloning](facebook/metro#854), [faster worker
creation](facebook/metro#856)), and as such, the
feature no longer needs to be enabled/disabled. Setting `mode: "exotic"`
will no longer have any additional effects over the default.

# Checklist

<!--
Please check the appropriate items below if they apply to your diff.
This is required for changes to Expo modules.
-->

- [ ] Documentation is up to date to reflect these changes (eg:
https://docs.expo.dev and README.md).
- [ ] Conforms with the [Documentation Writing Style
Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)
- [ ] This diff will work correctly for `npx expo prebuild` & EAS Build
(eg: updated a module plugin).

---------

Co-authored-by: Expo Bot <34669131+expo-bot@users.noreply.github.com>
marklawlor pushed a commit to expo/expo that referenced this pull request Oct 30, 2023
# Why

Most of the [Exotic
mode](https://blog.expo.dev/drastically-faster-bundling-in-react-native-a54f268e0ed1)
performance benefits have been integrated in the default Expo CLI
bundling pipeline (e.g. [less AST
cloning](facebook/metro#854), [faster worker
creation](facebook/metro#856)), and as such, the
feature no longer needs to be enabled/disabled. Setting `mode: "exotic"`
will no longer have any additional effects over the default.

# Checklist

<!--
Please check the appropriate items below if they apply to your diff.
This is required for changes to Expo modules.
-->

- [ ] Documentation is up to date to reflect these changes (eg:
https://docs.expo.dev and README.md).
- [ ] Conforms with the [Documentation Writing Style
Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)
- [ ] This diff will work correctly for `npx expo prebuild` & EAS Build
(eg: updated a module plugin).

---------

Co-authored-by: Expo Bot <34669131+expo-bot@users.noreply.github.com>
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. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants