]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix: ensure makeMap calls are tree-shakable
authorEvan You <yyx990803@gmail.com>
Tue, 15 Oct 2019 16:19:46 +0000 (12:19 -0400)
committerEvan You <yyx990803@gmail.com>
Tue, 15 Oct 2019 16:19:46 +0000 (12:19 -0400)
packages/compiler-core/src/transforms/transformExpression.ts
packages/shared/src/element.ts
packages/shared/src/globalsWhitelist.ts
packages/shared/src/makeMap.ts

index 10637543fd4fc7e595eabb7ec0ec88d942557557..8a8734d5f93821dd5db6fb6f32cf1e6411a8645a 100644 (file)
@@ -25,7 +25,7 @@ import {
 } from '../utils'
 import { isGloballyWhitelisted, makeMap } from '@vue/shared'
 
-const isLiteralWhitelisted = makeMap('true,false,null,this')
+const isLiteralWhitelisted = /*@__PURE__*/ makeMap('true,false,null,this')
 
 export const transformExpression: NodeTransform = (node, context) => {
   if (node.type === NodeTypes.INTERPOLATION) {
index 04d5e9fd91d7cc95445b32f5f6e07a27df8a7d26..27fd813bd5ac9d8d8a573daf4194c1092f57775c 100644 (file)
@@ -23,6 +23,6 @@ const SVG_TAGS =
 const VOID_TAGS =
   'area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr'
 
-export const isHTMLTag = makeMap(HTML_TAGS)
-export const isSVGTag = makeMap(SVG_TAGS)
-export const isVoidTag = makeMap(VOID_TAGS)
+export const isHTMLTag = /*@__PURE__*/ makeMap(HTML_TAGS)
+export const isSVGTag = /*@__PURE__*/ makeMap(SVG_TAGS)
+export const isVoidTag = /*@__PURE__*/ makeMap(VOID_TAGS)
index 8af8c079773f4217243568e543bca1de14082e5e..4c0e33a425f7402a8d10e77d229fcd69f5635626 100644 (file)
@@ -5,4 +5,4 @@ const GLOBALS_WHITE_LISTED =
   'decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,' +
   'Object,Boolean,String,RegExp,Map,Set,JSON,Intl'
 
-export const isGloballyWhitelisted = makeMap(GLOBALS_WHITE_LISTED)
+export const isGloballyWhitelisted = /*@__PURE__*/ makeMap(GLOBALS_WHITE_LISTED)
index 87291cddc2719ff0644d6019c799bf57d09b57e4..be9a258a87b21206f85bb1cab914a9312291e1e6 100644 (file)
@@ -1,7 +1,8 @@
-/**
- * Make a map and return a function for checking if a key
- * is in that map.
- */
+// Make a map and return a function for checking if a key
+// is in that map.
+//
+// IMPORTANT: all calls of this function must be prefixed with /*@__PURE__*/
+// So that rollup can tree-shake them if necessary.
 export function makeMap(
   str: string,
   expectsLowerCase?: boolean