Skip to content

Commit a76e58e

Browse files
committed
build: avoid shipping patch flag name strings in prod
1 parent 3bc2914 commit a76e58e

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

packages/compiler-core/src/transforms/transformText.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ export const transformText: NodeTransform = (node, context) => {
8585
getConstantType(child) === ConstantTypes.NOT_CONSTANT
8686
) {
8787
callArgs.push(
88-
`${PatchFlags.TEXT} /* ${PatchFlagNames[PatchFlags.TEXT]} */`
88+
PatchFlags.TEXT +
89+
(__DEV__ ? ` /* ${PatchFlagNames[PatchFlags.TEXT]} */` : ``)
8990
)
9091
}
9192
children[i] = {

packages/compiler-core/src/transforms/vFor.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ export const transformFor = createStructuralDirectiveTransform(
8888
helper(FRAGMENT),
8989
undefined,
9090
renderExp,
91-
`${fragmentFlag} /* ${PatchFlagNames[fragmentFlag]} */`,
91+
fragmentFlag +
92+
(__DEV__ ? ` /* ${PatchFlagNames[fragmentFlag]} */` : ``),
9293
undefined,
9394
undefined,
9495
true /* isBlock */,
@@ -147,9 +148,10 @@ export const transformFor = createStructuralDirectiveTransform(
147148
helper(FRAGMENT),
148149
keyProperty ? createObjectExpression([keyProperty]) : undefined,
149150
node.children,
150-
`${PatchFlags.STABLE_FRAGMENT} /* ${
151-
PatchFlagNames[PatchFlags.STABLE_FRAGMENT]
152-
} */`,
151+
PatchFlags.STABLE_FRAGMENT +
152+
(__DEV__
153+
? ` /* ${PatchFlagNames[PatchFlags.STABLE_FRAGMENT]} */`
154+
: ``),
153155
undefined,
154156
undefined,
155157
true

packages/compiler-core/src/transforms/vIf.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,10 @@ function createChildrenCodegenNode(
251251
helper(FRAGMENT),
252252
createObjectExpression([keyProperty]),
253253
children,
254-
`${PatchFlags.STABLE_FRAGMENT} /* ${
255-
PatchFlagNames[PatchFlags.STABLE_FRAGMENT]
256-
} */`,
254+
PatchFlags.STABLE_FRAGMENT +
255+
(__DEV__
256+
? ` /* ${PatchFlagNames[PatchFlags.STABLE_FRAGMENT]} */`
257+
: ``),
257258
undefined,
258259
undefined,
259260
true,

0 commit comments

Comments
 (0)