Comments (6)
Hi @dzengi, our strong recommendation is that converting a running function to source code, especially in the presence of Babel transformations, is almost never a good idea. You are much better off just copying the function into a string manually.
If you really need to do it, you need to look into how React Native configures Babel plugins in Metro. Unfortunately our team does't have much expertise in either Babel or Metro, so take this with a grain of salt and ideally confirm with someone who understands Babel and Metro:
Hermes does not currently support async arrow functions and for await
. If you need these features, you need to enable Babel plugins to:
- Convert arrow functions to ES5 functions (probably
@babel/plugin-transform-arrow-functions
). - Lower async generators (may be
@babel/plugin-async-generator-functions
).
This has not been tested by us.
The good news is that we will be releasing a beta version of Hermes supporting most ES6+ features in 2024 Q1, so at that time none of these plugins will be necessary.
Hope this helps!
from hermes.
Thanks for the report. Hermes doesn't support async
functions directly. They're being lowered by Babel to either generator functions or plain functions using regenerator by your build. In either case, the function that's being referenced by code outside the async function isn't likely to have the "show source"
directive in it any more.
e.g. if your babel set up lowers to generators, you'd get this output. Notice that "show source"
has been moved to an inner function.
This will be fixed when we add support for async
functions directly, but until then you might be able to work around it by putting the "show source"
directive in an outer non-async function.
EDIT: When I say Hermes doesn't support async
functions above, I mean async
arrow functions specifically.
from hermes.
Reclassifying as enhancement, since technically the solution to this is to implement async arrow functions.
from hermes.
@tmikov When is a fix expected? That is, using async in regular functions (not arrows) will work?
from hermes.
@KonstantinZhukovskij async functions have been supported by Hermes for years. Only async arrow functions are not implemented. However I don't know how React Native configures Babel.
from hermes.
Thanks for your reply @tmikov. Could you please provide an example of how I can use the functions? Because indeed, any functions (both ordinary and arrow) turn into generators and the directive no longer works there.
from hermes.
Related Issues (20)
- simplifySwitchInst in SimplifyCFG ignores negative zero HOT 1
- iOS App submission will require a privacy manifest and signature HOT 12
- Possible memory leak HOT 30
- Compile failure with optimized ASan builds HOT 4
- Thread 6: "Exception NSException * "Unhandled JS Exception: Error: invalid host, js engine: hermes" HOT 32
- Parser: improve error message when await is used in non-async functions or instead of async
- JSRangeErrorException setting maximumFractionDigits to 0 with Intl.NumberFormat currency style HOT 1
- Unreachable in ES6 is reachable. HOT 1
- Update documentation on using custom Hermes builds HOT 3
- Building Static Hermes on Windows HOT 4
- Problems finding libraries with fresh compile under windows HOT 3
- Conversion of large array to a Set seems slow HOT 5
- React Native & Hermes: Is Additional Code Obfuscation Beneficial? HOT 1
- Array.protoype.indexOf() Performance Regression HOT 3
- 'hermes-engine' uses the unencrypted 'http' protocol to transfer the Pod.
- hermes-eslint missing `__defineGeneric` in context `getScope` HOT 1
- Date constructor accept wrong ISO 8601 date HOT 2
- libc.so (SIGABRT, SIGSEGV) HOT 4
- Performance regression traversing large arrays compared to other engines HOT 4
- Hermes 0.7.2 : Max heap size was exceeded HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hermes.