Async functions are always transformed to regenerator runtime
See original GitHub issue๐ bug report
๐ Configuration (.babelrc, package.json, cli command)
Without config just do
yarn init
yarn add parcel-bundler
create index.js:
(async function () { return await 1 })()
parcel index.js
๐ค Expected Behavior
Without any babel config I would assume no transformation will be made, just bundling into one file.
๐ฏ Current Behavior
Dist file will contain
_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
...
๐ Possible Solution
๐ฆ Context
In specific project async functions are transformed no matter what .babelrc I try. I am trying to migrate from browserify but using
node_modules/.bin/parcel build ./src/client/index.js --out-dir ./public --out-file bundle.js --no-minify
will give me code with async functions transformed, where
node_modules/.bin/browserify ./src/client/index.js -o ./public/bundle.js -t [ babelify ]
will keep async functions unchanged. I would expect these to behave the same in regards to babel transforms.
๐ป Code Sample
๐ Your Environment
| Software | Version(s) |
|---|---|
| Parcel | 1.6.2 |
| Node | v8.1.4 |
| npm/Yarn | 1.3.2 |
| Operating System | Mac |
Issue Analytics
- State:
- Created 6 years ago
- Reactions:34
- Comments:37 (4 by maintainers)
Top Results From Across the Web
regeneratorRuntime when using Sync/Await - Stack Overflow
I'm getting the following error when using Async/Await for functions: Uncaught ReferenceError ...
Read more >How to fix regeneratorRuntime is not defined?
First, I found this solution: add import "babel-polyfill"; at the top of the file that you are using the async function. BUT.
Read more >babel/polyfill
Babel includes a polyfill that includes a custom regenerator runtime and core-js. This will emulate a full ES2015+ environment (no < Stage 4...
Read more >Regenerator Runtime is not defined - Risan Bagja
browserslistrc file finally support this async function. But because we explicitly import the regenerator-runtime , this module will always beย ...
Read more >cypress-io/cypress - Gitter
@go-oleg You've configured the syntax-async-functions and transform-regenerator babel plugins and require('babel-polyfill') in your test code?
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Found this solution:
Create .babelrc file and add:
I was getting this error when using
async/await:ReferenceError: regeneratorRuntime is not definedMy solution was adding:
import "babel-polyfill";Leaving this comment for reference.