diff --git a/packages/compiler-core/src/parse.ts b/packages/compiler-core/src/parse.ts index b72ad028b4b..f290f1b0261 100644 --- a/packages/compiler-core/src/parse.ts +++ b/packages/compiler-core/src/parse.ts @@ -507,9 +507,7 @@ const enum TagType { End } -const isSpecialTemplateDirective = /*#__PURE__*/ makeMap( - `if,else,else-if,for,slot` -) +const isSpecialTemplateDirective = makeMap(`if,else,else-if,for,slot`) /** * Parse a tag (E.g. `
`) with that type (start tag or end tag). diff --git a/packages/compiler-core/src/transforms/transformExpression.ts b/packages/compiler-core/src/transforms/transformExpression.ts index eab6b237f13..958bff19078 100644 --- a/packages/compiler-core/src/transforms/transformExpression.ts +++ b/packages/compiler-core/src/transforms/transformExpression.ts @@ -43,7 +43,7 @@ import { parse } from '@babel/parser' import { IS_REF, UNREF } from '../runtimeHelpers' import { BindingTypes } from '../options' -const isLiteralWhitelisted = /*#__PURE__*/ makeMap('true,false,null,this') +const isLiteralWhitelisted = makeMap('true,false,null,this') // a heuristic safeguard to bail constant expressions on presence of // likely function invocation and member access diff --git a/packages/compiler-dom/src/parserOptions.ts b/packages/compiler-dom/src/parserOptions.ts index 4d06a776b7a..e8c6f4281b2 100644 --- a/packages/compiler-dom/src/parserOptions.ts +++ b/packages/compiler-dom/src/parserOptions.ts @@ -10,10 +10,7 @@ import { TRANSITION, TRANSITION_GROUP } from './runtimeHelpers' import { decodeHtml } from './decodeHtml' import { decodeHtmlBrowser } from './decodeHtmlBrowser' -const isRawTextContainer = /*#__PURE__*/ makeMap( - 'style,iframe,script,noscript', - true -) +const isRawTextContainer = makeMap('style,iframe,script,noscript', true) export const enum DOMNamespaces { HTML = 0 /* Namespaces.HTML */, diff --git a/packages/compiler-dom/src/transforms/stringifyStatic.ts b/packages/compiler-dom/src/transforms/stringifyStatic.ts index 0b47cb435b0..b0258bf588d 100644 --- a/packages/compiler-dom/src/transforms/stringifyStatic.ts +++ b/packages/compiler-dom/src/transforms/stringifyStatic.ts @@ -167,7 +167,7 @@ const replaceHoist = ( context.hoists[context.hoists.indexOf(hoistToReplace)] = replacement } -const isNonStringifiable = /*#__PURE__*/ makeMap( +const isNonStringifiable = makeMap( `caption,thead,tr,th,tbody,td,tfoot,colgroup,col` ) diff --git a/packages/compiler-dom/src/transforms/vOn.ts b/packages/compiler-dom/src/transforms/vOn.ts index 660003b4839..f5aaa432f8b 100644 --- a/packages/compiler-dom/src/transforms/vOn.ts +++ b/packages/compiler-dom/src/transforms/vOn.ts @@ -17,8 +17,8 @@ import { import { V_ON_WITH_MODIFIERS, V_ON_WITH_KEYS } from '../runtimeHelpers' import { makeMap, capitalize } from '@vue/shared' -const isEventOptionModifier = /*#__PURE__*/ makeMap(`passive,once,capture`) -const isNonKeyModifier = /*#__PURE__*/ makeMap( +const isEventOptionModifier = makeMap(`passive,once,capture`) +const isNonKeyModifier = makeMap( // event propagation management `stop,prevent,self,` + // system modifiers + exact @@ -27,11 +27,8 @@ const isNonKeyModifier = /*#__PURE__*/ makeMap( `middle` ) // left & right could be mouse or key modifiers based on event type -const maybeKeyModifier = /*#__PURE__*/ makeMap('left,right') -const isKeyboardEvent = /*#__PURE__*/ makeMap( - `onkeyup,onkeydown,onkeypress`, - true -) +const maybeKeyModifier = makeMap('left,right') +const isKeyboardEvent = makeMap(`onkeyup,onkeydown,onkeypress`, true) const resolveModifiers = ( key: ExpressionNode, diff --git a/packages/reactivity/src/baseHandlers.ts b/packages/reactivity/src/baseHandlers.ts index 259b44a1edc..92caad1bd2b 100644 --- a/packages/reactivity/src/baseHandlers.ts +++ b/packages/reactivity/src/baseHandlers.ts @@ -31,7 +31,7 @@ import { import { isRef } from './ref' import { warn } from './warning' -const isNonTrackableKeys = /*#__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`) +const isNonTrackableKeys = makeMap(`__proto__,__v_isRef,__isVue`) const builtInSymbols = new Set( /*#__PURE__*/ diff --git a/packages/reactivity/src/collectionHandlers.ts b/packages/reactivity/src/collectionHandlers.ts index 1d07af3be8c..633aef322b6 100644 --- a/packages/reactivity/src/collectionHandlers.ts +++ b/packages/reactivity/src/collectionHandlers.ts @@ -331,6 +331,7 @@ const [ shallowReadonlyInstrumentations ] = /* #__PURE__*/ createInstrumentations() +/*! #__NO_SIDE_EFFECTS__ */ function createInstrumentationGetter(isReadonly: boolean, shallow: boolean) { const instrumentations = shallow ? isReadonly @@ -364,20 +365,20 @@ function createInstrumentationGetter(isReadonly: boolean, shallow: boolean) { } export const mutableCollectionHandlers: ProxyHandler = { - get: /*#__PURE__*/ createInstrumentationGetter(false, false) + get: createInstrumentationGetter(false, false) } export const shallowCollectionHandlers: ProxyHandler = { - get: /*#__PURE__*/ createInstrumentationGetter(false, true) + get: createInstrumentationGetter(false, true) } export const readonlyCollectionHandlers: ProxyHandler = { - get: /*#__PURE__*/ createInstrumentationGetter(true, false) + get: createInstrumentationGetter(true, false) } export const shallowReadonlyCollectionHandlers: ProxyHandler = { - get: /*#__PURE__*/ createInstrumentationGetter(true, true) + get: createInstrumentationGetter(true, true) } function checkIdentityKeys( diff --git a/packages/runtime-core/src/compat/renderFn.ts b/packages/runtime-core/src/compat/renderFn.ts index 4cf2fc226cf..d90c882b66f 100644 --- a/packages/runtime-core/src/compat/renderFn.ts +++ b/packages/runtime-core/src/compat/renderFn.ts @@ -170,7 +170,7 @@ export function compatH( } } -const skipLegacyRootLevelProps = /*#__PURE__*/ makeMap( +const skipLegacyRootLevelProps = makeMap( 'staticStyle,staticClass,directives,model,hook' ) diff --git a/packages/runtime-core/src/component.ts b/packages/runtime-core/src/component.ts index 57a53a39b76..6e45dde62b0 100644 --- a/packages/runtime-core/src/component.ts +++ b/packages/runtime-core/src/component.ts @@ -638,7 +638,7 @@ export const unsetCurrentInstance = () => { internalSetCurrentInstance(null) } -const isBuiltInTag = /*#__PURE__*/ makeMap('slot,component') +const isBuiltInTag = makeMap('slot,component') export function validateComponentName(name: string, config: AppConfig) { const appIsNativeTag = config.isNativeTag || NO diff --git a/packages/runtime-core/src/componentProps.ts b/packages/runtime-core/src/componentProps.ts index 4d402789555..004b341e5e6 100644 --- a/packages/runtime-core/src/componentProps.ts +++ b/packages/runtime-core/src/componentProps.ts @@ -680,9 +680,7 @@ function validateProp( } } -const isSimpleType = /*#__PURE__*/ makeMap( - 'String,Number,Boolean,Function,Symbol,BigInt' -) +const isSimpleType = makeMap('String,Number,Boolean,Function,Symbol,BigInt') type AssertionResult = { valid: boolean diff --git a/packages/runtime-core/src/componentPublicInstance.ts b/packages/runtime-core/src/componentPublicInstance.ts index dc575aafff9..e571e399d42 100644 --- a/packages/runtime-core/src/componentPublicInstance.ts +++ b/packages/runtime-core/src/componentPublicInstance.ts @@ -257,7 +257,7 @@ const getPublicInstance = ( export const publicPropertiesMap: PublicPropertiesMap = // Move PURE marker to new line to workaround compiler discarding it // due to type annotation - /*#__PURE__*/ extend(Object.create(null), { + extend(Object.create(null), { $: i => i, $el: i => i.vnode.el, $data: i => i.data, @@ -499,7 +499,7 @@ if (__DEV__ && !__TEST__) { } } -export const RuntimeCompiledPublicInstanceProxyHandlers = /*#__PURE__*/ extend( +export const RuntimeCompiledPublicInstanceProxyHandlers = extend( {}, PublicInstanceProxyHandlers, { diff --git a/packages/runtime-core/src/devtools.ts b/packages/runtime-core/src/devtools.ts index bf67093f5c3..f1ebbe3c814 100644 --- a/packages/runtime-core/src/devtools.ts +++ b/packages/runtime-core/src/devtools.ts @@ -99,14 +99,15 @@ export function devtoolsUnmountApp(app: App) { emit(DevtoolsHooks.APP_UNMOUNT, app) } -export const devtoolsComponentAdded = /*#__PURE__*/ createDevtoolsComponentHook( +export const devtoolsComponentAdded = createDevtoolsComponentHook( DevtoolsHooks.COMPONENT_ADDED ) -export const devtoolsComponentUpdated = - /*#__PURE__*/ createDevtoolsComponentHook(DevtoolsHooks.COMPONENT_UPDATED) +export const devtoolsComponentUpdated = createDevtoolsComponentHook( + DevtoolsHooks.COMPONENT_UPDATED +) -const _devtoolsComponentRemoved = /*#__PURE__*/ createDevtoolsComponentHook( +const _devtoolsComponentRemoved = createDevtoolsComponentHook( DevtoolsHooks.COMPONENT_REMOVED ) @@ -123,6 +124,7 @@ export const devtoolsComponentRemoved = ( } } +/*! #__NO_SIDE_EFFECTS__ */ function createDevtoolsComponentHook(hook: DevtoolsHooks) { return (component: ComponentInternalInstance) => { emit( @@ -135,14 +137,15 @@ function createDevtoolsComponentHook(hook: DevtoolsHooks) { } } -export const devtoolsPerfStart = /*#__PURE__*/ createDevtoolsPerformanceHook( +export const devtoolsPerfStart = createDevtoolsPerformanceHook( DevtoolsHooks.PERFORMANCE_START ) -export const devtoolsPerfEnd = /*#__PURE__*/ createDevtoolsPerformanceHook( +export const devtoolsPerfEnd = createDevtoolsPerformanceHook( DevtoolsHooks.PERFORMANCE_END ) +/*! #__NO_SIDE_EFFECTS__ */ function createDevtoolsPerformanceHook(hook: DevtoolsHooks) { return (component: ComponentInternalInstance, type: string, time: number) => { emit(hook, component.appContext.app, component.uid, component, type, time) diff --git a/packages/runtime-dom/src/components/Transition.ts b/packages/runtime-dom/src/components/Transition.ts index b0675213298..48379adcfa2 100644 --- a/packages/runtime-dom/src/components/Transition.ts +++ b/packages/runtime-dom/src/components/Transition.ts @@ -74,12 +74,11 @@ const DOMTransitionPropsValidators = { leaveToClass: String } -export const TransitionPropsValidators = (Transition.props = - /*#__PURE__*/ extend( - {}, - BaseTransitionPropsValidators as any, - DOMTransitionPropsValidators - )) +export const TransitionPropsValidators = (Transition.props = extend( + {}, + BaseTransitionPropsValidators as any, + DOMTransitionPropsValidators +)) /** * #3227 Incoming hooks may be merged into arrays when wrapping Transition diff --git a/packages/runtime-dom/src/components/TransitionGroup.ts b/packages/runtime-dom/src/components/TransitionGroup.ts index fc5d260b91e..d27a3df55a3 100644 --- a/packages/runtime-dom/src/components/TransitionGroup.ts +++ b/packages/runtime-dom/src/components/TransitionGroup.ts @@ -40,7 +40,7 @@ export type TransitionGroupProps = Omit & { const TransitionGroupImpl: ComponentOptions = { name: 'TransitionGroup', - props: /*#__PURE__*/ extend({}, TransitionPropsValidators, { + props: extend({}, TransitionPropsValidators, { tag: String, moveClass: String }), diff --git a/packages/runtime-dom/src/index.ts b/packages/runtime-dom/src/index.ts index ad818a34bb7..a97cac22a6a 100644 --- a/packages/runtime-dom/src/index.ts +++ b/packages/runtime-dom/src/index.ts @@ -30,7 +30,7 @@ declare module '@vue/reactivity' { } } -const rendererOptions = /*#__PURE__*/ extend({ patchProp }, nodeOps) +const rendererOptions = extend({ patchProp }, nodeOps) // lazy create the renderer - this makes core renderer logic tree-shakable // in case the user only imports reactivity utilities from Vue. diff --git a/packages/runtime-dom/src/modules/attrs.ts b/packages/runtime-dom/src/modules/attrs.ts index 41648ed50dc..147e1c17916 100644 --- a/packages/runtime-dom/src/modules/attrs.ts +++ b/packages/runtime-dom/src/modules/attrs.ts @@ -43,7 +43,7 @@ export function patchAttr( // 2.x compat const isEnumeratedAttr = __COMPAT__ - ? /*#__PURE__*/ makeMap('contenteditable,draggable,spellcheck') + ? makeMap('contenteditable,draggable,spellcheck') : NOOP export function compatCoerceAttr( diff --git a/packages/shared/src/domAttrConfig.ts b/packages/shared/src/domAttrConfig.ts index 5f7f851b0df..f1c7e39e81a 100644 --- a/packages/shared/src/domAttrConfig.ts +++ b/packages/shared/src/domAttrConfig.ts @@ -12,12 +12,12 @@ import { makeMap } from './makeMap' * - readonly -> readOnly */ const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly` -export const isSpecialBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs) +export const isSpecialBooleanAttr = makeMap(specialBooleanAttrs) /** * The full list is needed during SSR to produce the correct initial markup. */ -export const isBooleanAttr = /*#__PURE__*/ makeMap( +export const isBooleanAttr = makeMap( specialBooleanAttrs + `,async,autofocus,autoplay,controls,default,defer,disabled,hidden,` + `inert,loop,open,required,reversed,scoped,seamless,` + @@ -59,7 +59,7 @@ export const propsToAttrMap: Record = { * Don't also forget to allow `data-*` and `aria-*`! * Generated from https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes */ -export const isKnownHtmlAttr = /*#__PURE__*/ makeMap( +export const isKnownHtmlAttr = makeMap( `accept,accept-charset,accesskey,action,align,allow,alt,async,` + `autocapitalize,autocomplete,autofocus,autoplay,background,bgcolor,` + `border,buffered,capture,challenge,charset,checked,cite,class,code,` + @@ -80,7 +80,7 @@ export const isKnownHtmlAttr = /*#__PURE__*/ makeMap( /** * Generated from https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute */ -export const isKnownSvgAttr = /*#__PURE__*/ makeMap( +export const isKnownSvgAttr = makeMap( `xmlns,accent-height,accumulate,additive,alignment-baseline,alphabetic,amplitude,` + `arabic-form,ascent,attributeName,attributeType,azimuth,baseFrequency,` + `baseline-shift,baseProfile,bbox,begin,bias,by,calcMode,cap-height,class,` + diff --git a/packages/shared/src/domTagConfig.ts b/packages/shared/src/domTagConfig.ts index 535aa6be718..ef48ddc2c9d 100644 --- a/packages/shared/src/domTagConfig.ts +++ b/packages/shared/src/domTagConfig.ts @@ -34,14 +34,14 @@ const VOID_TAGS = * Compiler only. * Do NOT use in runtime code paths unless behind `__DEV__` flag. */ -export const isHTMLTag = /*#__PURE__*/ makeMap(HTML_TAGS) +export const isHTMLTag = makeMap(HTML_TAGS) /** * Compiler only. * Do NOT use in runtime code paths unless behind `__DEV__` flag. */ -export const isSVGTag = /*#__PURE__*/ makeMap(SVG_TAGS) +export const isSVGTag = makeMap(SVG_TAGS) /** * Compiler only. * Do NOT use in runtime code paths unless behind `__DEV__` flag. */ -export const isVoidTag = /*#__PURE__*/ makeMap(VOID_TAGS) +export const isVoidTag = makeMap(VOID_TAGS) diff --git a/packages/shared/src/general.ts b/packages/shared/src/general.ts index 0117e67000d..5833be98e27 100644 --- a/packages/shared/src/general.ts +++ b/packages/shared/src/general.ts @@ -17,6 +17,7 @@ export const isOn = (key: string) => onRE.test(key) export const isModelListener = (key: string) => key.startsWith('onUpdate:') +/*! #__NO_SIDE_EFFECTS__ */ export const extend = Object.assign export const remove = (arr: T[], el: T) => { @@ -75,7 +76,7 @@ export const isIntegerKey = (key: unknown) => key[0] !== '-' && '' + parseInt(key, 10) === key -export const isReservedProp = /*#__PURE__*/ makeMap( +export const isReservedProp = makeMap( // the leading comma is intentional so empty string "" is also included ',key,ref,ref_for,ref_key,' + 'onVnodeBeforeMount,onVnodeMounted,' + @@ -83,7 +84,7 @@ export const isReservedProp = /*#__PURE__*/ makeMap( 'onVnodeBeforeUnmount,onVnodeUnmounted' ) -export const isBuiltInDirective = /*#__PURE__*/ makeMap( +export const isBuiltInDirective = makeMap( 'bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo' ) diff --git a/packages/shared/src/globalsAllowList.ts b/packages/shared/src/globalsAllowList.ts index 4af518c22f1..08ae4f6c38a 100644 --- a/packages/shared/src/globalsAllowList.ts +++ b/packages/shared/src/globalsAllowList.ts @@ -5,7 +5,7 @@ const GLOBALS_ALLOWED = 'decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,' + 'Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,console' -export const isGloballyAllowed = /*#__PURE__*/ makeMap(GLOBALS_ALLOWED) +export const isGloballyAllowed = makeMap(GLOBALS_ALLOWED) /** @deprecated use `isGloballyAllowed` instead */ export const isGloballyWhitelisted = isGloballyAllowed diff --git a/packages/shared/src/makeMap.ts b/packages/shared/src/makeMap.ts index b598704c673..e49b1bf3d36 100644 --- a/packages/shared/src/makeMap.ts +++ b/packages/shared/src/makeMap.ts @@ -5,6 +5,8 @@ * \/\*#\_\_PURE\_\_\*\/ * So that rollup can tree-shake them if necessary. */ + +/*! #__NO_SIDE_EFFECTS__ */ export function makeMap( str: string, expectsLowerCase?: boolean