fix(v2): allow async/await in live code editor #3954
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
So.. as proposed by #3053, we are using a live code editor using
react-live
, and since transpiling javascript on the fly could easily turned into a heavy job, this library useshttps://github.com/bublejs/buble
for it, which relatively has a bundle size as mentioned in https://github.com/FormidableLabs/react-live#what-bundle-size-can-i-expect.However, to further reduce the bundle size, @endiliey decided to use @philpl/buble which discards some codes on ESNext transpilation, resulting in a notably smaller bundle size.
However this introduced some problem, which I encountered while using docusaurus@v2 and is well-explained by #3053: the live code editor cannot run the code that contains
async
orawait
keywords.Therefore, the simplest fix would be still using @philpl/buble, but applying a custom option to bypass transpiling
async
andawait
keywords, which would still work in most up-to-date modern browsers.Have you read the Contributing Guidelines on pull requests?
Yes.
Test Plan
Launched Docusaurus locally and tested it.
closes #3053 if merged