From a2a91b7b1ccbf37b694934833aaca955d0ffe41d Mon Sep 17 00:00:00 2001 From: chen fan <1490040662@qq.com> Date: Wed, 6 Sep 2023 12:53:15 +0800 Subject: [PATCH 1/2] perf: add __NO_SIDE_EFFECTS__ comment --- packages/reactivity/src/collectionHandlers.ts | 1 + packages/runtime-core/src/devtools.ts | 1 + packages/server-renderer/src/helpers/ssrRenderAttrs.ts | 2 +- packages/shared/src/makeMap.ts | 2 ++ 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/reactivity/src/collectionHandlers.ts b/packages/reactivity/src/collectionHandlers.ts index 1d07af3be8c..a96cf0db8a9 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 diff --git a/packages/runtime-core/src/devtools.ts b/packages/runtime-core/src/devtools.ts index bf67093f5c3..ba8c40fe012 100644 --- a/packages/runtime-core/src/devtools.ts +++ b/packages/runtime-core/src/devtools.ts @@ -123,6 +123,7 @@ export const devtoolsComponentRemoved = ( } } +/*! #__NO_SIDE_EFFECTS__ */ function createDevtoolsComponentHook(hook: DevtoolsHooks) { return (component: ComponentInternalInstance) => { emit( diff --git a/packages/server-renderer/src/helpers/ssrRenderAttrs.ts b/packages/server-renderer/src/helpers/ssrRenderAttrs.ts index 6bbf83a1eaa..c93efa13608 100644 --- a/packages/server-renderer/src/helpers/ssrRenderAttrs.ts +++ b/packages/server-renderer/src/helpers/ssrRenderAttrs.ts @@ -12,7 +12,7 @@ import { } from '@vue/shared' // leading comma for empty string "" -const shouldIgnoreProp = makeMap( +const shouldIgnoreProp = /*#__PURE__*/ makeMap( `,key,ref,innerHTML,textContent,ref_key,ref_for` ) 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 From 9f1d109ebaffe9ac4f609b696defda7b982312a9 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Wed, 13 Mar 2024 21:41:20 +0800 Subject: [PATCH 2/2] chore: remove `__NO_SIDE_EFFECTS__` comment from createInstrumentationGetter Because: 1. All references to this function have already been annotated with `__PURE__`; 2. It's not exported. Therefore, adding `__NO_SIDE_EFFECTS__` does not reduce the bundle size. Moreover, somehow, when bundling `runtime-dom.global.prod.js`, Rollup does not delete this comment even though it's not exported at all, so it even increases the bundle size a bit. --- packages/reactivity/src/collectionHandlers.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/reactivity/src/collectionHandlers.ts b/packages/reactivity/src/collectionHandlers.ts index 0ced811faa5..2b7785ae7eb 100644 --- a/packages/reactivity/src/collectionHandlers.ts +++ b/packages/reactivity/src/collectionHandlers.ts @@ -341,7 +341,6 @@ const [ shallowReadonlyInstrumentations, ] = /* #__PURE__*/ createInstrumentations() -/*! #__NO_SIDE_EFFECTS__ */ function createInstrumentationGetter(isReadonly: boolean, shallow: boolean) { const instrumentations = shallow ? isReadonly