Skip to content

Commit ae99c3f

Browse files
committed
Revert "Make JSX check for shouldTranspile far more aggressive"
This reverts commit 47419bc.
1 parent e6092e0 commit ae99c3f

File tree

4 files changed

+7
-48
lines changed

4 files changed

+7
-48
lines changed

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,7 @@ export default function initialize() {
2525
configurations &&
2626
configurations.package &&
2727
configurations.package.parsed &&
28-
configurations.package.parsed.dependencies,
29-
30-
configurations &&
31-
configurations.package &&
32-
configurations.package.parsed &&
33-
configurations.package.parsed.devDependencies
28+
configurations.package.parsed.dependencies
3429
) &&
3530
!v2Initialized
3631
) {
Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,7 @@
11
import isESModule from '../../utils/is-es-module';
22

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

55
export function shouldTranspile(code: string, path: string) {
6-
if (isESModule(code)) {
7-
return true;
8-
}
9-
10-
const match = code.match(JSXSyntax);
11-
if (match) {
12-
const startOfLine = match[1];
13-
14-
// If it's in a comment or string, we're extremely aggressive here because
15-
// transpiling is absolutely our last resort.
16-
if (
17-
startOfLine.indexOf('//') > -1 ||
18-
startOfLine.indexOf('*') > -1 ||
19-
startOfLine.indexOf("'") > -1 ||
20-
startOfLine.indexOf('"') > -1 ||
21-
startOfLine.indexOf('`') > -1
22-
) {
23-
return false;
24-
}
25-
26-
return true;
27-
}
28-
return false;
6+
return isESModule(code) || JSXSyntax.test(code);
297
}

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

Lines changed: 0 additions & 15 deletions
This file was deleted.

packages/common/utils/is-babel-7.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import semver from 'semver';
22

33
function isCRAVersion2(dependencies, devDependencies) {
4-
const reactScriptsVersion =
5-
dependencies['react-scripts'] || devDependencies['react-scripts'];
6-
if (reactScriptsVersion) {
4+
const usedDeps = { ...dependencies, ...devDependencies };
5+
if (usedDeps['react-scripts']) {
6+
const reactScriptsVersion = usedDeps['react-scripts'];
7+
78
return (
89
/^[a-z]/.test(reactScriptsVersion) ||
910
semver.intersects(reactScriptsVersion, '^2.0.0')

0 commit comments

Comments
 (0)