File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
packages/runtime/plugin-testing/src/base/config/transformer Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @modern-js/plugin-testing ' : patch
3
+ ---
4
+
5
+ fix(testing): transform jsx failed when use React 18
6
+
7
+ fix(testing): 修复使用 React 18 时 JSX 编译错误的问题
Original file line number Diff line number Diff line change 1
1
import babelJest from 'babel-jest' ;
2
+ import { isBeyondReact17 } from '@modern-js/utils' ;
3
+
4
+ const isNewJsx = isBeyondReact17 ( process . cwd ( ) ) ;
2
5
3
6
const babelTransformer = ( babelJest . createTransformer as any ) ?.( {
4
7
presets : [
@@ -10,7 +13,12 @@ const babelTransformer = (babelJest.createTransformer as any)?.({
10
13
} ,
11
14
} ,
12
15
] ,
13
- require . resolve ( '@babel/preset-react' ) ,
16
+ [
17
+ require . resolve ( '@babel/preset-react' ) ,
18
+ {
19
+ runtime : isNewJsx ? 'automatic' : 'classic' ,
20
+ } ,
21
+ ] ,
14
22
] ,
15
23
configFile : false ,
16
24
babelrc : false ,
You can’t perform that action at this time.
0 commit comments