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

async/await in examples with live editor doesn't work #3053

Closed
maksnester opened this issue Jul 13, 2020 · 3 comments · Fixed by #3954
Closed

async/await in examples with live editor doesn't work #3053

maksnester opened this issue Jul 13, 2020 · 3 comments · Fixed by #3954
Labels
bug An error in the Docusaurus core causing instability or issues with its execution

Comments

@maksnester
Copy link

🐛 Bug Report

This code put in the live editor

function Clock(props) {
  async function test() {
    alert(1);
  }
  test();

  return <div>Doesn't matter</div>;
}

throws a runtime error in the live editor, but that doesn't happen on react-live demo page

Have you read the Contributing Guidelines on issues?

yep

To Reproduce

  1. Open https://v2.docusaurus.io/docs/markdown-features/#interactive-code-editor
  2. Put the code from above inside editable code block
  3. See runtime error

Expected behavior

It works as that code works on react-live demo page.

Actual Behavior

throws a runtime error in the live editor

CompileError: Transforming async functions is not implemented. Use `transforms: { asyncAwait: false }` to skip transformation and disable this error. (2:2)
1 : return (function Clock(props) {
2 :   async function test() {
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Your Environment

    "@docusaurus/core": "2.0.0-alpha.58",
    "@docusaurus/module-type-aliases": "^2.0.0-alpha.51",
    "@docusaurus/preset-classic": "2.0.0-alpha.58",
    "@docusaurus/theme-live-codeblock": "^2.0.0-alpha.39",

or the same you have on your documentation site.

Reproducible Demo

https://github.com/facebook/docusaurus/tree/master/website

@maksnester maksnester added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Jul 13, 2020
@slorber
Copy link
Collaborator

slorber commented Jul 13, 2020

This asyncAwait thing seems to be an option of Bublé, the live transformer. Not sure where it is activated on the react-live demo.

We also use a fork of Bublé ("@philpl/buble": "^0.19.7",), don't know why exactly, will have to understand why

@slorber
Copy link
Collaborator

slorber commented Jul 13, 2020

@kitten hi, do you think we should still use your buble fork (seems it is not updated, but optimize for bundle size) or maybe use latest from main repo?

Also, I'm not sure to understand how you react-live demo supports async await, I don't see the asyncAwait: false in the Bublé transforms

@9oelM
Copy link
Contributor

9oelM commented Dec 26, 2020

I'm working on this issue.

9oelM added a commit to 9oelM/docusaurus that referenced this issue Dec 26, 2020
* transforming async functions is not implemented by buble, so just bypassing it would relieve the pain for now
@Josh-Cena Josh-Cena removed the status: needs triage This issue has not been triaged by maintainers label May 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants