mirror of
https://github.com/vuejs/babel-plugin-jsx.git
synced 2024-11-10 09:39:14 +08:00
feat: optional usePatchFlag
This commit is contained in:
parent
858f39cea2
commit
76f3f17602
@ -11,6 +11,7 @@ export type State = {
|
||||
interface Opts {
|
||||
transformOn?: boolean;
|
||||
compatibleProps?: boolean;
|
||||
usePatchFlag?: boolean;
|
||||
}
|
||||
|
||||
export type ExcludesBoolean = <T>(x: T | false | true) => x is T;
|
||||
|
@ -398,7 +398,7 @@ const transformJSXElement = (
|
||||
.map((n) => PatchFlagNames[n])
|
||||
.join(', ');
|
||||
|
||||
const { compatibleProps } = state.opts;
|
||||
const { compatibleProps = false, usePatchFlag = true } = state.opts;
|
||||
if (compatibleProps && !state.get('compatibleProps')) {
|
||||
state.set('compatibleProps', addDefault(
|
||||
path, '@ant-design-vue/babel-helper-vue-compatible-props', { nameHint: '_compatibleProps' },
|
||||
@ -406,7 +406,7 @@ const transformJSXElement = (
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
const createVNode = t.callExpression(createIdentifier(state, 'createVNode'), [
|
||||
const createVNode = t.callExpression(createIdentifier(state, usePatchFlag ? 'createVNode' : 'h'), [
|
||||
tag,
|
||||
// @ts-ignore
|
||||
compatibleProps ? t.callExpression(state.get('compatibleProps'), [props]) : props,
|
||||
@ -425,12 +425,12 @@ const transformJSXElement = (
|
||||
].filter(Boolean as any as ExcludesBoolean))
|
||||
: t.arrayExpression(children)
|
||||
) : t.nullLiteral(),
|
||||
!!patchFlag && (
|
||||
!!patchFlag && usePatchFlag && (
|
||||
useOptimate
|
||||
? t.addComment(t.numericLiteral(patchFlag), 'trailing', ` ${flagNames} `, false)
|
||||
: t.numericLiteral(PatchFlags.BAIL)
|
||||
),
|
||||
!!dynamicPropNames.size
|
||||
!!dynamicPropNames.size && usePatchFlag
|
||||
&& t.arrayExpression([...dynamicPropNames.keys()].map((name) => t.stringLiteral(name as string))),
|
||||
].filter(Boolean as any as ExcludesBoolean));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user