Skip to content

Commit 810cd36

Browse files
committed
also compile CJS
1 parent 35b875c commit 810cd36

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

config/babel.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,31 @@ export const babelTransform: BuildStep = async (options) => {
2727
],
2828
plugins:
2929
(
30-
// compiler will insert `"import"` statements, so it's not CJS compatible
31-
options.type === "esm" &&
3230
// apply the compiler only to the react hooks, not test helper components etc.
3331
relativeSourcePath.match(/react\/hooks/)
3432
) ?
35-
[
33+
// compiler will insert `"import"` statements, so it's not CJS compatible
34+
options.type === "esm" ?
3635
[
37-
"babel-plugin-react-compiler",
38-
{
39-
target: "17",
40-
},
41-
],
42-
]
36+
[
37+
"babel-plugin-react-compiler",
38+
{
39+
target: "17",
40+
},
41+
],
42+
]
43+
: [
44+
[
45+
"babel-plugin-react-compiler",
46+
{
47+
target: "17",
48+
},
49+
],
50+
[
51+
"@babel/plugin-transform-modules-commonjs",
52+
{ importInterop: "none" },
53+
],
54+
]
4355
: [],
4456
});
4557
return { ast: result.ast!, map: result.map };

0 commit comments

Comments
 (0)