Skip to content

refactor: use lightweight token in CDK drag-drop - #19678

Merged
devversion merged 2 commits into
angular:lightweight-token-optimizationsfrom
devversion:wip/light-weight-tokens-8
Jun 18, 2020
Merged

devversion merged 2 commits into
angular:lightweight-token-optimizationsfrom
devversion:wip/light-weight-tokens-8

Conversation

@devversion

Copy link
Copy Markdown
Member

Currently the CdkDropList directive always retains the CdkDropListGroup
directive. This is not desired as the drop list group is not necessarily
always used in combination with a drop list.

Additionally, the CdkDrag directive always retains the CdkDragHandle,
CdkDragPlaceholder and CdkDragPreview directives. This is neither
desired because a handle, placeholder or preview can be consumed
optionally. We should only bring those directives into applications
when actually needed.

Size measurements show that this saves around ~1.3kb if only a drop
list and cdkDrag is used. The downside is that we add up ~200b if
all directives of the drag-drop module are used. Given the drag-drop
has a compressed size of around 45kb, the 1.3kb size improvement in
the common case should be good enough to move forward (~3% reduction).

@crisbeto Would be interesting to see what you think here. I think it's low-effort to
maintain these tokens here. The individual classes don't seem large in TS source,
but 3% in the common case can quickly cause apps to grow, so I think it would be valuable.

Related to #19576.

Currently the `CdkDropList` directive always retains the
`CdkDropListGroup` directive. This is not desired as the
drop list group is not necessarily always used in combination
with a drop list.

Additionally, the `CdkDrag` directive always retains the
`CdkDragHandle`, `CdkDragPlaceholder` and `CdkDragPreview`
directives. This is neither desired because a handle, placeholder
or preview can be consumed optionally. We should only bring those
directives into applications when actually needed.

Size measurements show that this saves around ~1.3kb if only
a drop list and `cdkDrag` is used. The downside is that we add
up ~200b if _all_ directives of the drag-drop module are used.

Given the drag-drop has a size of around 45kb, the 1.3kb size
improvement in the common case should be good (~3% reduction).

Related to angular#19576.
@devversion devversion added P2 The issue is important to a large percentage of users, with a workaround target: development-branch labels Jun 17, 2020
@devversion
devversion requested a review from a team June 17, 2020 18:24
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jun 17, 2020

@jelbourn jelbourn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jelbourn jelbourn added lgtm action: merge The PR is ready for merge by the caretaker labels Jun 17, 2020

@crisbeto crisbeto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@devversion
devversion merged commit 1f79eef into angular:lightweight-token-optimizations Jun 18, 2020
@angular-automatic-lock-bot

Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Jul 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement P2 The issue is important to a large percentage of users, with a workaround

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants