Skip to content

Commit

Permalink
fix(plugin-jsx): interop default
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz committed Jan 12, 2024
1 parent baf3792 commit 9dccd01
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "vue-jsx-monorepo",
"private": true,
"packageManager": "pnpm@8.14.1",
"type": "module",
"scripts": {
"build": "pnpm run -r build",
"test": "vitest",
Expand Down
14 changes: 11 additions & 3 deletions packages/babel-plugin-jsx/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as t from '@babel/types';
import type * as BabelCore from '@babel/core';
import template from '@babel/template';
import _template from '@babel/template';
// @ts-expect-error
import syntaxJsx from '@babel/plugin-syntax-jsx';
import _syntaxJsx from '@babel/plugin-syntax-jsx';
// @ts-expect-error
import { addNamed, addNamespace, isModule } from '@babel/helper-module-imports';
import { type NodePath } from '@babel/traverse';
Expand Down Expand Up @@ -31,9 +31,17 @@ const hasJSX = (parentPath: NodePath<t.Program>) => {

const JSX_ANNOTATION_REGEX = /\*?\s*@jsx\s+([^\s]+)/;

/* #__NO_SIDE_EFFECTS__ */
function interopDefault(m: any) {
return m.default || m;
}

const syntaxJsx = /*#__PURE__*/ interopDefault(_syntaxJsx);
const template = /*#__PURE__*/ interopDefault(_template);

export default ({ types }: typeof BabelCore): BabelCore.PluginObj<State> => ({
name: 'babel-plugin-jsx',
inherits: syntaxJsx,
inherits: /*#__PURE__*/ interopDefault(syntaxJsx),
visitor: {
...transformVueJSX,
...sugarFragment,
Expand Down

0 comments on commit 9dccd01

Please sign in to comment.