Skip to content

Conversation

@processprocess
Copy link
Contributor

@processprocess processprocess commented Nov 18, 2021

Refactor to use an element child instead of class inheritance.
This reduces bundle size by removing the import of AmpStoryPageAttachent as well as potential technical debt from a third level of inheritance.
(draggable-drawer > page-attachment > shopping-attachment).

@amp-owners-bot
Copy link

amp-owners-bot bot commented Nov 18, 2021

Hey @gmajoulet! These files were changed:

extensions/amp-story-shopping/0.1/amp-story-shopping-attachment.css
extensions/amp-story-shopping/0.1/amp-story-shopping-attachment.js
extensions/amp-story-shopping/0.1/test/test-amp-story-shopping-attachment.js
extensions/amp-story/1.0/amp-story-draggable-drawer.js

Hey @newmuis! These files were changed:

extensions/amp-story/1.0/amp-story-draggable-drawer.js

@coreymasanto
Copy link
Contributor

Out of curiosity, how does this refactor reduce the bundle size?

Also, is there a technical concern about using inheritance here? This PR takes the existing structure of
BaseElement > draggable-drawer > page-attachment > shopping-attachment
and updates it to
BaseElement > draggable-drawer > page-attachment
BaseElement > shopping-attachment.
The updated structure seems like it may be more difficult to reason about during implementation

@processprocess
Copy link
Contributor Author

processprocess commented Nov 18, 2021

It reduces the bundle size by removing the import of AmpStoryPageAttachent.

It can be implemented either way but the idea behind this approach is to favor composition over inheritance.
The only function we need to override is open. Other than that we will be switching out content within the attachment and editing the header.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants