mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-09 23:27:28 +02:00
fix(v2): allow async/await in live code editor (#3954)
* transforming async functions is not implemented by buble, so just bypassing it would relieve the pain for now
This commit is contained in:
parent
6ce1230c1e
commit
41ac4468de
2 changed files with 21 additions and 4 deletions
20
packages/docusaurus-theme-live-codeblock/src/custom-buble.js
Normal file
20
packages/docusaurus-theme-live-codeblock/src/custom-buble.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// fork of Buble which removes Buble's large dependency and weighs in
|
||||
// at a smaller size of ~51kB
|
||||
// https://github.com/FormidableLabs/react-live#what-bundle-size-can-i-expect
|
||||
const {transform, features: bubleFeatures} = require('@philpl/buble');
|
||||
|
||||
// This file is designed to mimic what's written in
|
||||
// https://github.com/kitten/buble/blob/mini/src/index.js, with custom transforms options,
|
||||
// so that webpack can consume it correctly.
|
||||
exports.features = bubleFeatures;
|
||||
|
||||
exports.transform = function customTransform(source, options) {
|
||||
return transform(source, {...options, transforms: {asyncAwait: false}});
|
||||
};
|
|
@ -19,10 +19,7 @@ module.exports = function () {
|
|||
return {
|
||||
resolve: {
|
||||
alias: {
|
||||
// fork of Buble which removes Buble's large dependency and weighs in
|
||||
// at a smaller size of ~51kB
|
||||
// https://github.com/FormidableLabs/react-live#what-bundle-size-can-i-expect
|
||||
buble: '@philpl/buble',
|
||||
buble: path.resolve(__dirname, './custom-buble.js'),
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue