Skip to content

Commit e9bdb99

Browse files
committed
Check for regneratorRuntime when transpiling modules
1 parent fb9e625 commit e9bdb99

File tree

2 files changed

+13
-1
lines changed
  • packages/app/src/sandbox/eval

2 files changed

+13
-1
lines changed

packages/app/src/sandbox/eval/presets/create-react-app/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,14 @@ export default function initialize() {
4444
'babel-plugin-macros',
4545
['proposal-class-properties', { loose: true }],
4646
['proposal-object-rest-spread', { useBuiltIns: true }],
47-
'transform-runtime',
47+
[
48+
'transform-runtime',
49+
{
50+
corejs: false,
51+
helpers: true,
52+
regenerator: true,
53+
},
54+
],
4855
'syntax-dynamic-import',
4956
],
5057
presets: [

packages/app/src/sandbox/eval/transpilers/babel/check.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
import isESModule from '../../utils/is-es-module';
22

33
const JSXSyntax = /\n(.*?)<[A-z](.|\n)*?\/?>/;
4+
const regeneratorSyntax = /(\s|^)regeneratorRuntime\./;
45

56
export function shouldTranspile(code: string, path: string) {
67
if (isESModule(code)) {
78
return true;
89
}
910

11+
if (regeneratorSyntax.test(code)) {
12+
return true;
13+
}
14+
1015
const match = code.match(JSXSyntax);
1116
if (match) {
1217
const startOfLine = match[1];

0 commit comments

Comments
 (0)