fix(plugin-jsx): interop default

This commit is contained in:
三咲智子 Kevin Deng 2024-01-13 02:52:35 +08:00
parent baf379274a
commit 9dccd01438
No known key found for this signature in database
GPG Key ID: 69992F2250DFD93E
2 changed files with 12 additions and 3 deletions

View File

@ -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",

View File

@ -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';
@ -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,