-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Async functions are always transformed to regenerator runtime #871
Comments
Seems like it could be related to #509 somehow, but |
Parcel automatically applies babel-preset-env to some default engines (> 1% marketshare). You can change your app's browser targets by adding a |
@devongovett Thanks for quick reply. As you say using |
@aocenas That’s a good point. If you want, feel free to open up an issue in the website repo so it get’s added to the docs 👍 |
I was getting this error when using My solution was adding: Leaving this comment for reference. |
Here my solution: |
Found this solution: npm install --save-dev babel-plugin-transform-runtime babel-runtime Create .babelrc file and add: {
"plugins": [
["transform-runtime",
{
"polyfill": false,
"regenerator": true
}]
]
} |
@brandiqa that solutions looks like very similar to mine but more complete. That is nice!! |
@brandiqa this doesn't seem to work when typescript is involved. tsconfig.json
I get this error:
|
I had accidentally set the config value to:
Changing it to the following worked for me:
|
Perhaps the runtime transform should be default? |
I run into this all the time with demos - so if you want to just ignore this error and use the browsers built in async/await I use this for a quick fix without having to install any babel plugins:
|
Is this supposed to work somehow without babel-polyfill? I tried all the .babelrc plugin settings to no avail.. babel-polyfill did it, but it's a pretty heavy dependency to make something work that actually works natively in all evergreen browsers now |
Just an update to @brandiqa solution for those with a babel version of 7^. |
@gcv.. yeah that would work for a lot of users.. i think i just wish there was a way to use async/await simply and still support IE11.. kinda the point of babel.. but without needing the babel-polyfill on all sites because it's like 300k and that's nuts. currently i can't make it work in Chrome without babel-polyfill and that actually makes no sense because it shouldn't be necessary because it shouldn't have anything to polyfill. but this applies to babel moreso than parcel so i'll stick a lid on it 😋 |
I am getting the same error and this solution works for me. |
@thedamon Does adding |
Limiting to recent browsers because of: parcel-bundler/parcel#871
I love how after one year and a half we still don't have a definitive answer to this question. Every solution here includes adding a bunch of dependencies to your project and stopping doing that when the issue actually ceases or seems to be solved. Gotta love modern JS tooling. It's 2019 and we are struggling to do a simple HTTP request. On the web. <3 |
@mischnic Thanks for re-opening! Hope we can come to a solution to improve UX for Parcel users everywhere :) |
Just want to leave a note and say that my code worked with this fix now. Running Babel core 7.7.5. Here is my .babelrc:
|
Premise: typescript and no babel I was also getting this error when using async/await: My solution is to change tsconfig // tsconifg.json
{
"compilerOptions": {
"target": "es5",
...
},
...
} For reference |
This works, but we shouldn't need to do this in 2019. |
what other options do we have? |
All major browsers and Node.js have had async/await support for about two years now. |
Rollup requires additional configuration for electron to work. I'm not sure this is the best way of doing it, but it at least works now. For reference, here are the relevant resources: - https://github.com/rollup/rollup-plugin-babel#helpers - https://babeljs.io/docs/en/babel-plugin-transform-runtime#regenerator - parcel-bundler/parcel#871 (comment) - babel/babel#8829 (comment) - rollup/rollup#3160 - rollup/rollup-plugin-babel#209 (comment)
* Extend schema for project creation * Keep GraphQL schema in sync with mock implementation * Extract layouts in preparation for modal implementation * Add create project modal * Add help page and keyboard shortcuts to access design system * Tweak design system * Fix spec * Use library for hotkeys This lib gracefully handles ignoring hotkeys while focusing on inputs. * Add disabled dropdown variant * Add CheckboxInput * Disable default branch dropdown by default * Use electron's open dialog for directory input This allows us to select empty directories, which is not possible with a plain input with type "file" in a regular browser environment, as it doesn't fire any events when empty directories are chosen. * Fixup for directory input Rollup requires additional configuration for electron to work. I'm not sure this is the best way of doing it, but it at least works now. For reference, here are the relevant resources: - https://github.com/rollup/rollup-plugin-babel#helpers - https://babeljs.io/docs/en/babel-plugin-transform-runtime#regenerator - parcel-bundler/parcel#871 (comment) - babel/babel#8829 (comment) - rollup/rollup#3160 - rollup/rollup-plugin-babel#209 (comment) * Improve css class naming * Show placeholder if path is not present * Make localBranches query consistent with the branches query * Add validations Disable button if form is not complete (name or path missing) and show validation messages for name. * Remove unneeded attribute * Add librad dependency * Set up mutation testing scaffold * Add missing gql queries * Create temp dir for project init test * Make focussed input outline color customisable * Make focussed select outline color customisable * Wire up repo and rad project creation * Port old design system page layout over from Reason prototype * Init repo in create project mutation * Isolate paths dir per environment * Remove test flag from proxy start * Modularise schema * Complete create project mutation * Use actual ID scalar for project id * Move repo init helper to git module * Remove source from context * Show notification after creating project * Add project avatar input * Start project query rewrite to librad * Complete project list testing * Add publish field to project creation * Bring back project query * Test project endpoint * Replace IdInput with ID for all queries * Revert back to using id instead of name/domain pair * Reintroduce test projects when flag is passed * Implement local branches query * Attach open dialog to the main window So it doesn't go to background after creating a new folder. * Fix create mutation * Keep temp dir in scope for proxy test mode * Fix navigation spec It was broken because we changed the page layout. * Fix source browsing tests The breakage was related switching to a hash address as opposed to domain/name. * Fix relative time tests The clock has to be frozen before the test setup is run. * Add missing hotkey description * Use the correct query for local branch fetching * Show notifications longer * Reset local branch dropdown and message on failure * Update fixture repo * Fix active selection border * Address clippy feedback * Install clippy for nightly toolchain * Please the clippy * Animate choosing an option * Use more concise find_map * Add documentation about why we use electron open dialog * Add more descriptive section name for notifications * Use routing strings from path.js * Use more appropriate variable type * Use only one modifier key for now * Unbreak my build Co-authored-by: Alexander Simmerl <a.simmerl@gmail.com>
I have tried every single solution (and many combinations of those) in this whole thread and none seems to work for me (except the ones related to TypeScript, as it's not my case) 😞 I can supply more information if needed, just ask it to me and I'll be able to do so. |
@danielfilho Are you using the latest version of |
these are the versions I'm using:
Locally, I was trying to update all dependencies to the latest but the problem was still there. Even cleaning node_modules and npm cache. I solved this giving up on doing locally and moving the development to codesandbox.io, which is far from ideal. But at least I could move on with the project. I know how weird it sounds, but I tried everything, and then gave up to this solution. Thanks for asking, @corwin-of-amber. |
@danielfilho I am attaching a minimal code example that shows the problem so that you and other users visiting this issue could perhaps use to troubleshoot. Notice how removing |
Thought I'd throw this in, as this seems like the most "correct" way (serious air quotes here) based on what seems like best practice in Babel and what actually ended up working for me: Install the plugin transform runtime
Add this to your {
"plugins": ["@babel/plugin-transform-runtime"]
} I didn't include the runtime or configure any options. Parcel must do this magic? I'm using a Chromium-based browser so I don't know how this works on older browsers, but it fixed this immediate issue for me. Followed the instructions outlined here: https://babeljs.io/docs/en/babel-plugin-transform-runtime#with-a-configuration-file-recommended |
This was originally added to resolve issues with Parcel's default handling of async functions: parcel-bundler/parcel#871 There's no usage of `async` in this codebase anymore, so it's not necessary to have it (removing it will allow babel to polyfill some ES6 functionality for old browsers).
This may be helpful for those that need to make it work with old browsers (e.g.: with the default (or no) The issue is that the dependency |
Seems like this is not fixed (as the workaround from 11/8/2020 shows?), is it no longer an issue in Parcel 2.0.0? |
|
Great! Thanks for adding this reference for anyone who encounters this error in the future. |
🐛 bug report
🎛 Configuration (.babelrc, package.json, cli command)
Without config just do
create 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
💁 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
will give me code with async functions transformed, where
will keep async functions unchanged. I would expect these to behave the same in regards to babel transforms.
💻 Code Sample
🌍 Your Environment
The text was updated successfully, but these errors were encountered: