Skip to content

Commit 14b7caf

Browse files
authored
feat(plugin-vue-jsx): add jsx pure flag (#10205)
1 parent dd871af commit 14b7caf

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

packages/plugin-vue-jsx/src/index.ts

+19
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import jsx from '@vue/babel-plugin-jsx'
66
import { createFilter, normalizePath } from 'vite'
77
import type { ComponentOptions } from 'vue'
88
import type { Plugin } from 'vite'
9+
// eslint-disable-next-line node/no-extraneous-import
10+
import type { CallExpression, Identifier } from '@babel/types'
911
import type { Options } from './types'
1012

1113
export * from './types'
@@ -93,6 +95,23 @@ function vueJsxPlugin(options: Options = {}): Plugin {
9395
])
9496
}
9597

98+
if (!ssr && !needHmr) {
99+
plugins.push(() => {
100+
return {
101+
visitor: {
102+
CallExpression: {
103+
enter(_path: babel.NodePath<CallExpression>) {
104+
if (isDefineComponentCall(_path.node)) {
105+
const callee = _path.node.callee as Identifier
106+
callee.name = `/* @__PURE__ */ ${callee.name}`
107+
}
108+
}
109+
}
110+
}
111+
}
112+
})
113+
}
114+
96115
const result = babel.transformSync(code, {
97116
babelrc: false,
98117
ast: true,

0 commit comments

Comments
 (0)