diff --git a/packages/plugin-vue-jsx/src/index.ts b/packages/plugin-vue-jsx/src/index.ts index e5454980ed4d8e..89d5d2aa1bd976 100644 --- a/packages/plugin-vue-jsx/src/index.ts +++ b/packages/plugin-vue-jsx/src/index.ts @@ -8,6 +8,8 @@ import importMeta from '@babel/plugin-syntax-import-meta' import { createFilter, normalizePath } from 'vite' import type { ComponentOptions } from 'vue' import type { Plugin } from 'vite' +// eslint-disable-next-line node/no-extraneous-import +import type { CallExpression, Identifier } from '@babel/types' import type { Options } from './types' export * from './types' @@ -95,6 +97,23 @@ function vueJsxPlugin(options: Options = {}): Plugin { ]) } + if (!ssr && !needHmr) { + plugins.push(() => { + return { + visitor: { + CallExpression: { + enter(_path: babel.NodePath) { + if (isDefineComponentCall(_path.node)) { + const callee = _path.node.callee as Identifier + callee.name = `/* @__PURE__ */ ${callee.name}` + } + } + } + } + } + }) + } + const result = babel.transformSync(code, { babelrc: false, ast: true,