]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
build: avoid shipping patch flag name strings in prod
authorEvan You <yyx990803@gmail.com>
Fri, 27 Nov 2020 23:13:04 +0000 (18:13 -0500)
committerEvan You <yyx990803@gmail.com>
Fri, 27 Nov 2020 23:13:04 +0000 (18:13 -0500)
packages/compiler-core/src/transforms/transformText.ts
packages/compiler-core/src/transforms/vFor.ts
packages/compiler-core/src/transforms/vIf.ts

index 103ceb6fb5c3986fc977816b9f62f6565f0ae481..0c672f9cc8c8faece7748dc27403e670f7e011ea 100644 (file)
@@ -85,7 +85,8 @@ export const transformText: NodeTransform = (node, context) => {
             getConstantType(child) === ConstantTypes.NOT_CONSTANT
           ) {
             callArgs.push(
-              `${PatchFlags.TEXT} /* ${PatchFlagNames[PatchFlags.TEXT]} */`
+              PatchFlags.TEXT +
+                (__DEV__ ? ` /* ${PatchFlagNames[PatchFlags.TEXT]} */` : ``)
             )
           }
           children[i] = {
index 7949c014fb2c76f9b8f1b8107152fa51ec38a8b9..aadb07edac7925bc5b1e05c1886bb9072f005755 100644 (file)
@@ -88,7 +88,8 @@ export const transformFor = createStructuralDirectiveTransform(
         helper(FRAGMENT),
         undefined,
         renderExp,
-        `${fragmentFlag} /* ${PatchFlagNames[fragmentFlag]} */`,
+        fragmentFlag +
+          (__DEV__ ? ` /* ${PatchFlagNames[fragmentFlag]} */` : ``),
         undefined,
         undefined,
         true /* isBlock */,
@@ -147,9 +148,10 @@ export const transformFor = createStructuralDirectiveTransform(
             helper(FRAGMENT),
             keyProperty ? createObjectExpression([keyProperty]) : undefined,
             node.children,
-            `${PatchFlags.STABLE_FRAGMENT} /* ${
-              PatchFlagNames[PatchFlags.STABLE_FRAGMENT]
-            } */`,
+            PatchFlags.STABLE_FRAGMENT +
+              (__DEV__
+                ? ` /* ${PatchFlagNames[PatchFlags.STABLE_FRAGMENT]} */`
+                : ``),
             undefined,
             undefined,
             true
index e98604d037baa05a6c9a72ad5e548492e8255c09..a9ea7acfb470a06b63ee8ed084a75ee6a73e4561 100644 (file)
@@ -251,9 +251,10 @@ function createChildrenCodegenNode(
         helper(FRAGMENT),
         createObjectExpression([keyProperty]),
         children,
-        `${PatchFlags.STABLE_FRAGMENT} /* ${
-          PatchFlagNames[PatchFlags.STABLE_FRAGMENT]
-        } */`,
+        PatchFlags.STABLE_FRAGMENT +
+          (__DEV__
+            ? ` /* ${PatchFlagNames[PatchFlags.STABLE_FRAGMENT]} */`
+            : ``),
         undefined,
         undefined,
         true,