From ad199e1a252f80c85a8e40a4b4539ad27c39505c Mon Sep 17 00:00:00 2001 From: Evan You Date: Mon, 20 Jul 2020 16:13:41 -0400 Subject: [PATCH] fix(build): make transition tree-shakeable again --- packages/runtime-dom/src/components/Transition.ts | 2 +- .../runtime-dom/src/components/TransitionGroup.ts | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/runtime-dom/src/components/Transition.ts b/packages/runtime-dom/src/components/Transition.ts index 2318d19eb9b..6b3ead4c279 100644 --- a/packages/runtime-dom/src/components/Transition.ts +++ b/packages/runtime-dom/src/components/Transition.ts @@ -55,7 +55,7 @@ const DOMTransitionPropsValidators = { leaveToClass: String } -export const TransitionPropsValidators = (Transition.props = extend( +export const TransitionPropsValidators = (Transition.props = /*#__PURE__*/ extend( {}, (BaseTransition as any).props, DOMTransitionPropsValidators diff --git a/packages/runtime-dom/src/components/TransitionGroup.ts b/packages/runtime-dom/src/components/TransitionGroup.ts index 417f0b13eab..e1236cad358 100644 --- a/packages/runtime-dom/src/components/TransitionGroup.ts +++ b/packages/runtime-dom/src/components/TransitionGroup.ts @@ -39,7 +39,7 @@ export type TransitionGroupProps = Omit & { const TransitionGroupImpl = { name: 'TransitionGroup', - props: extend({}, TransitionPropsValidators, { + props: /*#__PURE__*/ extend({}, TransitionPropsValidators, { tag: String, moveClass: String }), @@ -130,8 +130,14 @@ const TransitionGroupImpl = { } } -// remove mode props as TransitionGroup doesn't support it -delete TransitionGroupImpl.props.mode +/** + * TransitionGroup does not support "mode" so we need to remove it from the + * props declarations, but direct delete operation is considered a side effect + * and will make the entire transition feature non-tree-shakeable, so we do it + * in a function and mark the function's invocation as pure. + */ +const removeMode = (props: any) => delete props.mode +/*#__PURE__*/ removeMode(TransitionGroupImpl.props) export const TransitionGroup = (TransitionGroupImpl as unknown) as { new (): {