Skip to content

Commit 7ce8b15

Browse files
committed
chore: use __NO_SIDE_EFFECTS__ to replace __PURE__
1 parent 2ffe3d5 commit 7ce8b15

21 files changed

+49
-53
lines changed

packages/compiler-core/src/parse.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -507,9 +507,7 @@ const enum TagType {
507507
End
508508
}
509509

510-
const isSpecialTemplateDirective = /*#__PURE__*/ makeMap(
511-
`if,else,else-if,for,slot`
512-
)
510+
const isSpecialTemplateDirective = makeMap(`if,else,else-if,for,slot`)
513511

514512
/**
515513
* Parse a tag (E.g. `<div id=a>`) with that type (start tag or end tag).

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ import { parse } from '@babel/parser'
4343
import { IS_REF, UNREF } from '../runtimeHelpers'
4444
import { BindingTypes } from '../options'
4545

46-
const isLiteralWhitelisted = /*#__PURE__*/ makeMap('true,false,null,this')
46+
const isLiteralWhitelisted = makeMap('true,false,null,this')
4747

4848
// a heuristic safeguard to bail constant expressions on presence of
4949
// likely function invocation and member access

packages/compiler-dom/src/parserOptions.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ import { TRANSITION, TRANSITION_GROUP } from './runtimeHelpers'
1010
import { decodeHtml } from './decodeHtml'
1111
import { decodeHtmlBrowser } from './decodeHtmlBrowser'
1212

13-
const isRawTextContainer = /*#__PURE__*/ makeMap(
14-
'style,iframe,script,noscript',
15-
true
16-
)
13+
const isRawTextContainer = makeMap('style,iframe,script,noscript', true)
1714

1815
export const enum DOMNamespaces {
1916
HTML = 0 /* Namespaces.HTML */,

packages/compiler-dom/src/transforms/stringifyStatic.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ const replaceHoist = (
167167
context.hoists[context.hoists.indexOf(hoistToReplace)] = replacement
168168
}
169169

170-
const isNonStringifiable = /*#__PURE__*/ makeMap(
170+
const isNonStringifiable = makeMap(
171171
`caption,thead,tr,th,tbody,td,tfoot,colgroup,col`
172172
)
173173

packages/compiler-dom/src/transforms/vOn.ts

+4-7
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ import {
1717
import { V_ON_WITH_MODIFIERS, V_ON_WITH_KEYS } from '../runtimeHelpers'
1818
import { makeMap, capitalize } from '@vue/shared'
1919

20-
const isEventOptionModifier = /*#__PURE__*/ makeMap(`passive,once,capture`)
21-
const isNonKeyModifier = /*#__PURE__*/ makeMap(
20+
const isEventOptionModifier = makeMap(`passive,once,capture`)
21+
const isNonKeyModifier = makeMap(
2222
// event propagation management
2323
`stop,prevent,self,` +
2424
// system modifiers + exact
@@ -27,11 +27,8 @@ const isNonKeyModifier = /*#__PURE__*/ makeMap(
2727
`middle`
2828
)
2929
// left & right could be mouse or key modifiers based on event type
30-
const maybeKeyModifier = /*#__PURE__*/ makeMap('left,right')
31-
const isKeyboardEvent = /*#__PURE__*/ makeMap(
32-
`onkeyup,onkeydown,onkeypress`,
33-
true
34-
)
30+
const maybeKeyModifier = makeMap('left,right')
31+
const isKeyboardEvent = makeMap(`onkeyup,onkeydown,onkeypress`, true)
3532

3633
const resolveModifiers = (
3734
key: ExpressionNode,

packages/reactivity/src/baseHandlers.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import {
3131
import { isRef } from './ref'
3232
import { warn } from './warning'
3333

34-
const isNonTrackableKeys = /*#__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`)
34+
const isNonTrackableKeys = makeMap(`__proto__,__v_isRef,__isVue`)
3535

3636
const builtInSymbols = new Set(
3737
/*#__PURE__*/

packages/reactivity/src/collectionHandlers.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ const [
331331
shallowReadonlyInstrumentations
332332
] = /* #__PURE__*/ createInstrumentations()
333333

334+
/*! #__NO_SIDE_EFFECTS__ */
334335
function createInstrumentationGetter(isReadonly: boolean, shallow: boolean) {
335336
const instrumentations = shallow
336337
? isReadonly
@@ -364,20 +365,20 @@ function createInstrumentationGetter(isReadonly: boolean, shallow: boolean) {
364365
}
365366

366367
export const mutableCollectionHandlers: ProxyHandler<CollectionTypes> = {
367-
get: /*#__PURE__*/ createInstrumentationGetter(false, false)
368+
get: createInstrumentationGetter(false, false)
368369
}
369370

370371
export const shallowCollectionHandlers: ProxyHandler<CollectionTypes> = {
371-
get: /*#__PURE__*/ createInstrumentationGetter(false, true)
372+
get: createInstrumentationGetter(false, true)
372373
}
373374

374375
export const readonlyCollectionHandlers: ProxyHandler<CollectionTypes> = {
375-
get: /*#__PURE__*/ createInstrumentationGetter(true, false)
376+
get: createInstrumentationGetter(true, false)
376377
}
377378

378379
export const shallowReadonlyCollectionHandlers: ProxyHandler<CollectionTypes> =
379380
{
380-
get: /*#__PURE__*/ createInstrumentationGetter(true, true)
381+
get: createInstrumentationGetter(true, true)
381382
}
382383

383384
function checkIdentityKeys(

packages/runtime-core/src/compat/renderFn.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export function compatH(
170170
}
171171
}
172172

173-
const skipLegacyRootLevelProps = /*#__PURE__*/ makeMap(
173+
const skipLegacyRootLevelProps = makeMap(
174174
'staticStyle,staticClass,directives,model,hook'
175175
)
176176

packages/runtime-core/src/component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ export const unsetCurrentInstance = () => {
638638
internalSetCurrentInstance(null)
639639
}
640640

641-
const isBuiltInTag = /*#__PURE__*/ makeMap('slot,component')
641+
const isBuiltInTag = makeMap('slot,component')
642642

643643
export function validateComponentName(name: string, config: AppConfig) {
644644
const appIsNativeTag = config.isNativeTag || NO

packages/runtime-core/src/componentProps.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -680,9 +680,7 @@ function validateProp(
680680
}
681681
}
682682

683-
const isSimpleType = /*#__PURE__*/ makeMap(
684-
'String,Number,Boolean,Function,Symbol,BigInt'
685-
)
683+
const isSimpleType = makeMap('String,Number,Boolean,Function,Symbol,BigInt')
686684

687685
type AssertionResult = {
688686
valid: boolean

packages/runtime-core/src/componentPublicInstance.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ const getPublicInstance = (
257257
export const publicPropertiesMap: PublicPropertiesMap =
258258
// Move PURE marker to new line to workaround compiler discarding it
259259
// due to type annotation
260-
/*#__PURE__*/ extend(Object.create(null), {
260+
extend(Object.create(null), {
261261
$: i => i,
262262
$el: i => i.vnode.el,
263263
$data: i => i.data,
@@ -499,7 +499,7 @@ if (__DEV__ && !__TEST__) {
499499
}
500500
}
501501

502-
export const RuntimeCompiledPublicInstanceProxyHandlers = /*#__PURE__*/ extend(
502+
export const RuntimeCompiledPublicInstanceProxyHandlers = extend(
503503
{},
504504
PublicInstanceProxyHandlers,
505505
{

packages/runtime-core/src/devtools.ts

+9-6
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,15 @@ export function devtoolsUnmountApp(app: App) {
9999
emit(DevtoolsHooks.APP_UNMOUNT, app)
100100
}
101101

102-
export const devtoolsComponentAdded = /*#__PURE__*/ createDevtoolsComponentHook(
102+
export const devtoolsComponentAdded = createDevtoolsComponentHook(
103103
DevtoolsHooks.COMPONENT_ADDED
104104
)
105105

106-
export const devtoolsComponentUpdated =
107-
/*#__PURE__*/ createDevtoolsComponentHook(DevtoolsHooks.COMPONENT_UPDATED)
106+
export const devtoolsComponentUpdated = createDevtoolsComponentHook(
107+
DevtoolsHooks.COMPONENT_UPDATED
108+
)
108109

109-
const _devtoolsComponentRemoved = /*#__PURE__*/ createDevtoolsComponentHook(
110+
const _devtoolsComponentRemoved = createDevtoolsComponentHook(
110111
DevtoolsHooks.COMPONENT_REMOVED
111112
)
112113

@@ -123,6 +124,7 @@ export const devtoolsComponentRemoved = (
123124
}
124125
}
125126

127+
/*! #__NO_SIDE_EFFECTS__ */
126128
function createDevtoolsComponentHook(hook: DevtoolsHooks) {
127129
return (component: ComponentInternalInstance) => {
128130
emit(
@@ -135,14 +137,15 @@ function createDevtoolsComponentHook(hook: DevtoolsHooks) {
135137
}
136138
}
137139

138-
export const devtoolsPerfStart = /*#__PURE__*/ createDevtoolsPerformanceHook(
140+
export const devtoolsPerfStart = createDevtoolsPerformanceHook(
139141
DevtoolsHooks.PERFORMANCE_START
140142
)
141143

142-
export const devtoolsPerfEnd = /*#__PURE__*/ createDevtoolsPerformanceHook(
144+
export const devtoolsPerfEnd = createDevtoolsPerformanceHook(
143145
DevtoolsHooks.PERFORMANCE_END
144146
)
145147

148+
/*! #__NO_SIDE_EFFECTS__ */
146149
function createDevtoolsPerformanceHook(hook: DevtoolsHooks) {
147150
return (component: ComponentInternalInstance, type: string, time: number) => {
148151
emit(hook, component.appContext.app, component.uid, component, type, time)

packages/runtime-dom/src/components/Transition.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,11 @@ const DOMTransitionPropsValidators = {
7474
leaveToClass: String
7575
}
7676

77-
export const TransitionPropsValidators = (Transition.props =
78-
/*#__PURE__*/ extend(
79-
{},
80-
BaseTransitionPropsValidators as any,
81-
DOMTransitionPropsValidators
82-
))
77+
export const TransitionPropsValidators = (Transition.props = extend(
78+
{},
79+
BaseTransitionPropsValidators as any,
80+
DOMTransitionPropsValidators
81+
))
8382

8483
/**
8584
* #3227 Incoming hooks may be merged into arrays when wrapping Transition

packages/runtime-dom/src/components/TransitionGroup.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export type TransitionGroupProps = Omit<TransitionProps, 'mode'> & {
4040
const TransitionGroupImpl: ComponentOptions = {
4141
name: 'TransitionGroup',
4242

43-
props: /*#__PURE__*/ extend({}, TransitionPropsValidators, {
43+
props: extend({}, TransitionPropsValidators, {
4444
tag: String,
4545
moveClass: String
4646
}),

packages/runtime-dom/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ declare module '@vue/reactivity' {
3030
}
3131
}
3232

33-
const rendererOptions = /*#__PURE__*/ extend({ patchProp }, nodeOps)
33+
const rendererOptions = extend({ patchProp }, nodeOps)
3434

3535
// lazy create the renderer - this makes core renderer logic tree-shakable
3636
// in case the user only imports reactivity utilities from Vue.

packages/runtime-dom/src/modules/attrs.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export function patchAttr(
4343

4444
// 2.x compat
4545
const isEnumeratedAttr = __COMPAT__
46-
? /*#__PURE__*/ makeMap('contenteditable,draggable,spellcheck')
46+
? makeMap('contenteditable,draggable,spellcheck')
4747
: NOOP
4848

4949
export function compatCoerceAttr(

packages/shared/src/domAttrConfig.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ import { makeMap } from './makeMap'
1212
* - readonly -> readOnly
1313
*/
1414
const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`
15-
export const isSpecialBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs)
15+
export const isSpecialBooleanAttr = makeMap(specialBooleanAttrs)
1616

1717
/**
1818
* The full list is needed during SSR to produce the correct initial markup.
1919
*/
20-
export const isBooleanAttr = /*#__PURE__*/ makeMap(
20+
export const isBooleanAttr = makeMap(
2121
specialBooleanAttrs +
2222
`,async,autofocus,autoplay,controls,default,defer,disabled,hidden,` +
2323
`inert,loop,open,required,reversed,scoped,seamless,` +
@@ -59,7 +59,7 @@ export const propsToAttrMap: Record<string, string | undefined> = {
5959
* Don't also forget to allow `data-*` and `aria-*`!
6060
* Generated from https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes
6161
*/
62-
export const isKnownHtmlAttr = /*#__PURE__*/ makeMap(
62+
export const isKnownHtmlAttr = makeMap(
6363
`accept,accept-charset,accesskey,action,align,allow,alt,async,` +
6464
`autocapitalize,autocomplete,autofocus,autoplay,background,bgcolor,` +
6565
`border,buffered,capture,challenge,charset,checked,cite,class,code,` +
@@ -80,7 +80,7 @@ export const isKnownHtmlAttr = /*#__PURE__*/ makeMap(
8080
/**
8181
* Generated from https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute
8282
*/
83-
export const isKnownSvgAttr = /*#__PURE__*/ makeMap(
83+
export const isKnownSvgAttr = makeMap(
8484
`xmlns,accent-height,accumulate,additive,alignment-baseline,alphabetic,amplitude,` +
8585
`arabic-form,ascent,attributeName,attributeType,azimuth,baseFrequency,` +
8686
`baseline-shift,baseProfile,bbox,begin,bias,by,calcMode,cap-height,class,` +

packages/shared/src/domTagConfig.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ const VOID_TAGS =
3434
* Compiler only.
3535
* Do NOT use in runtime code paths unless behind `__DEV__` flag.
3636
*/
37-
export const isHTMLTag = /*#__PURE__*/ makeMap(HTML_TAGS)
37+
export const isHTMLTag = makeMap(HTML_TAGS)
3838
/**
3939
* Compiler only.
4040
* Do NOT use in runtime code paths unless behind `__DEV__` flag.
4141
*/
42-
export const isSVGTag = /*#__PURE__*/ makeMap(SVG_TAGS)
42+
export const isSVGTag = makeMap(SVG_TAGS)
4343
/**
4444
* Compiler only.
4545
* Do NOT use in runtime code paths unless behind `__DEV__` flag.
4646
*/
47-
export const isVoidTag = /*#__PURE__*/ makeMap(VOID_TAGS)
47+
export const isVoidTag = makeMap(VOID_TAGS)

packages/shared/src/general.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export const isOn = (key: string) => onRE.test(key)
1717

1818
export const isModelListener = (key: string) => key.startsWith('onUpdate:')
1919

20+
/*! #__NO_SIDE_EFFECTS__ */
2021
export const extend = Object.assign
2122

2223
export const remove = <T>(arr: T[], el: T) => {
@@ -75,15 +76,15 @@ export const isIntegerKey = (key: unknown) =>
7576
key[0] !== '-' &&
7677
'' + parseInt(key, 10) === key
7778

78-
export const isReservedProp = /*#__PURE__*/ makeMap(
79+
export const isReservedProp = makeMap(
7980
// the leading comma is intentional so empty string "" is also included
8081
',key,ref,ref_for,ref_key,' +
8182
'onVnodeBeforeMount,onVnodeMounted,' +
8283
'onVnodeBeforeUpdate,onVnodeUpdated,' +
8384
'onVnodeBeforeUnmount,onVnodeUnmounted'
8485
)
8586

86-
export const isBuiltInDirective = /*#__PURE__*/ makeMap(
87+
export const isBuiltInDirective = makeMap(
8788
'bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo'
8889
)
8990

packages/shared/src/globalsAllowList.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const GLOBALS_ALLOWED =
55
'decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,' +
66
'Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,console'
77

8-
export const isGloballyAllowed = /*#__PURE__*/ makeMap(GLOBALS_ALLOWED)
8+
export const isGloballyAllowed = makeMap(GLOBALS_ALLOWED)
99

1010
/** @deprecated use `isGloballyAllowed` instead */
1111
export const isGloballyWhitelisted = isGloballyAllowed

packages/shared/src/makeMap.ts

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* \/\*#\_\_PURE\_\_\*\/
66
* So that rollup can tree-shake them if necessary.
77
*/
8+
9+
/*! #__NO_SIDE_EFFECTS__ */
810
export function makeMap(
911
str: string,
1012
expectsLowerCase?: boolean

0 commit comments

Comments
 (0)