Skip to content

Commit 22e265f

Browse files
committed
Improve check on shouldTranspile
1 parent ca77ca4 commit 22e265f

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import isESModule from '../../utils/is-es-module';
22

3-
const JSXSyntax = /(.*)<\w(.|\n)*?\/?>/;
3+
const JSXSyntax = /\n(.*?)<\w(.|\n)*?\/?>/;
44

55
export function shouldTranspile(code: string, path: string) {
66
if (isESModule(code)) {

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ import { shouldTranspile } from './check';
22

33
describe('shouldTranspile', () => {
44
it('does have to transpile clear jsx', () => {
5-
const code = '<div></div>';
5+
const code = `
6+
<div></div>`;
67

78
expect(shouldTranspile(code, '')).toBe(true);
89
});
910

1011
it("doesn't have to transpile comments with jsx", () => {
11-
const code = ' // Setting .type throws on non-<input> tags';
12+
const code = `
13+
// Setting .type throws on non-<input> tags`;
1214

1315
expect(shouldTranspile(code, '')).toBe(false);
1416
});

0 commit comments

Comments
 (0)