Skip to content

Commit 76f3f17

Browse files
committed
feat: optional usePatchFlag
1 parent 858f39c commit 76f3f17

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export type State = {
1111
interface Opts {
1212
transformOn?: boolean;
1313
compatibleProps?: boolean;
14+
usePatchFlag?: boolean;
1415
}
1516

1617
export type ExcludesBoolean = <T>(x: T | false | true) => x is T;

packages/babel-plugin-jsx/src/transform-vue-jsx.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,15 +398,15 @@ const transformJSXElement = (
398398
.map((n) => PatchFlagNames[n])
399399
.join(', ');
400400

401-
const { compatibleProps } = state.opts;
401+
const { compatibleProps = false, usePatchFlag = true } = state.opts;
402402
if (compatibleProps && !state.get('compatibleProps')) {
403403
state.set('compatibleProps', addDefault(
404404
path, '@ant-design-vue/babel-helper-vue-compatible-props', { nameHint: '_compatibleProps' },
405405
));
406406
}
407407

408408
// @ts-ignore
409-
const createVNode = t.callExpression(createIdentifier(state, 'createVNode'), [
409+
const createVNode = t.callExpression(createIdentifier(state, usePatchFlag ? 'createVNode' : 'h'), [
410410
tag,
411411
// @ts-ignore
412412
compatibleProps ? t.callExpression(state.get('compatibleProps'), [props]) : props,
@@ -425,12 +425,12 @@ const transformJSXElement = (
425425
].filter(Boolean as any as ExcludesBoolean))
426426
: t.arrayExpression(children)
427427
) : t.nullLiteral(),
428-
!!patchFlag && (
428+
!!patchFlag && usePatchFlag && (
429429
useOptimate
430430
? t.addComment(t.numericLiteral(patchFlag), 'trailing', ` ${flagNames} `, false)
431431
: t.numericLiteral(PatchFlags.BAIL)
432432
),
433-
!!dynamicPropNames.size
433+
!!dynamicPropNames.size && usePatchFlag
434434
&& t.arrayExpression([...dynamicPropNames.keys()].map((name) => t.stringLiteral(name as string))),
435435
].filter(Boolean as any as ExcludesBoolean));
436436

0 commit comments

Comments
 (0)