Skip to content

Commit 00744bc

Browse files
committed
fix(babel): compatibility with CommonJS
1 parent 1d08537 commit 00744bc

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

packages/babel/src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @ts-ignore
2-
import SyntaxJSX from '@babel/plugin-syntax-jsx'
2+
import _SyntaxJSX from '@babel/plugin-syntax-jsx'
33
import { parse } from '@babel/parser'
44
import { transformJSX } from './transform'
55
import { isConditionalExpression, isJSXElement } from './utils'
@@ -8,6 +8,8 @@ import type { JSXElement, JSXFragment, Node } from '@babel/types'
88
import type { CompilerOptions } from '@vue-jsx-vapor/compiler'
99
import type { Visitor } from '@babel/core'
1010

11+
const SyntaxJSX = _SyntaxJSX.default || _SyntaxJSX
12+
1113
export type Options = {
1214
filename: string
1315
importSet: Set<string>

packages/babel/src/transform.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import { compile } from '@vue-jsx-vapor/compiler'
22
import { parse } from '@babel/parser'
33
import { SourceMapConsumer } from 'source-map-js'
4-
import traverse, { type VisitNodeFunction } from '@babel/traverse'
4+
import _traverse, { type VisitNodeFunction } from '@babel/traverse'
55
import { isJSXElement } from './utils'
66
import type { Options } from '.'
77
import type { JSXElement, JSXFragment } from '@babel/types'
88

9+
// @ts-ignore
10+
const traverse = (_traverse.default || _traverse) as typeof _traverse
11+
912
export const transformJSX: VisitNodeFunction<
1013
Options,
1114
JSXElement | JSXFragment

0 commit comments

Comments
 (0)