Skip to content

Commit

Permalink
fix: using tsx loader to parse jsx files
Browse files Browse the repository at this point in the history
  • Loading branch information
fz6m committed Sep 20, 2023
1 parent f8b6f10 commit e6bf273
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions packages/bundler-utils/src/index.ts
Original file line number Diff line number Diff line change
@@ -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'));
Expand All @@ -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) {
Expand Down

0 comments on commit e6bf273

Please sign in to comment.