diff --git a/packages/compiler-core/src/transforms/transformExpression.ts b/packages/compiler-core/src/transforms/transformExpression.ts index 10637543..8a8734d5 100644 --- a/packages/compiler-core/src/transforms/transformExpression.ts +++ b/packages/compiler-core/src/transforms/transformExpression.ts @@ -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) { diff --git a/packages/shared/src/element.ts b/packages/shared/src/element.ts index 04d5e9fd..27fd813b 100644 --- a/packages/shared/src/element.ts +++ b/packages/shared/src/element.ts @@ -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) diff --git a/packages/shared/src/globalsWhitelist.ts b/packages/shared/src/globalsWhitelist.ts index 8af8c079..4c0e33a4 100644 --- a/packages/shared/src/globalsWhitelist.ts +++ b/packages/shared/src/globalsWhitelist.ts @@ -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) diff --git a/packages/shared/src/makeMap.ts b/packages/shared/src/makeMap.ts index 87291cdd..be9a258a 100644 --- a/packages/shared/src/makeMap.ts +++ b/packages/shared/src/makeMap.ts @@ -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