Skip to content

Commit

Permalink
fix(build): make transition tree-shakeable again
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jul 20, 2020
1 parent 6f148d0 commit ad199e1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/runtime-dom/src/components/Transition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 9 additions & 3 deletions packages/runtime-dom/src/components/TransitionGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export type TransitionGroupProps = Omit<TransitionProps, 'mode'> & {
const TransitionGroupImpl = {
name: 'TransitionGroup',

props: extend({}, TransitionPropsValidators, {
props: /*#__PURE__*/ extend({}, TransitionPropsValidators, {
tag: String,
moveClass: String
}),
Expand Down Expand Up @@ -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 (): {
Expand Down

0 comments on commit ad199e1

Please sign in to comment.