From a62d1df17eb31a03636eea6079cbc44905f07f58 Mon Sep 17 00:00:00 2001 From: Ryan Christian Date: Sat, 8 Nov 2025 01:16:12 -0600 Subject: [PATCH] fix: Don't enable Babel's TS syntax plugin if user adds own Babel config --- src/index.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index b4ec5db..71b79a1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -210,7 +210,10 @@ function preactPlugin({ "classPrivateProperties", "classPrivateMethods", !/\.[cm]?ts$/.test(id) && "jsx", - /\.[cm]?tsx?$/.test(id) && "typescript", + // Babel doesn't support many transforms without also transforming TS. + // Whilst our limited transforms (JSX & hook names) are fine, if users + // add their own, they may run into unhelpful errors. See #170 + /\.[cm]?tsx?$/.test(id) && typeof babel !== "undefined" && "typescript", ].filter(Boolean) as ParserPlugin[]; const result = await transformAsync(code, { @@ -263,7 +266,7 @@ function preactPlugin({ alias: { "react-dom/test-utils": "preact/test-utils", "react-dom": "preact/compat", - "react/jsx-runtime": "preact/jsx-runtime", + "react/jsx-runtime": "preact/jsx-runtime", react: "preact/compat", }, }, @@ -275,7 +278,7 @@ function preactPlugin({ jsxPlugin, preactDevtoolsPlugin({ devToolsEnabled, - shouldTransform + shouldTransform, }), ...(prefreshEnabled ? [prefresh({ include, exclude, parserPlugins: baseParserOptions })]