From e6bf273751f75c51c1806cb34c15262d56c32b6c Mon Sep 17 00:00:00 2001 From: fz6m <59400654+fz6m@users.noreply.github.com> Date: Thu, 21 Sep 2023 03:38:33 +0800 Subject: [PATCH] fix: using tsx loader to parse jsx files --- packages/bundler-utils/src/index.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/bundler-utils/src/index.ts b/packages/bundler-utils/src/index.ts index 9315de0d015a..6dfd9667c9fe 100644 --- a/packages/bundler-utils/src/index.ts +++ b/packages/bundler-utils/src/index.ts @@ -1,7 +1,6 @@ import { importLazy, logger, winPath } from '@umijs/utils'; -import { extname } from 'path'; import { init, parse } from '../compiled/es-module-lexer'; -import { Loader, transformSync } from '../compiled/esbuild'; +import { transformSync } from '../compiled/esbuild'; const babelCodeFrame: typeof import('../compiled/babel/code-frame') = importLazy(require.resolve('../compiled/babel/code-frame')); @@ -17,7 +16,7 @@ export function parseModuleSync(opts: { content: string; path: string }) { if (opts.path.endsWith('.tsx') || opts.path.endsWith('.jsx')) { try { content = transformSync(content, { - loader: extname(opts.path).slice(1) as Loader, + loader: 'tsx', format: 'esm', }).code; } catch (e) {