Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

♻️🚀 Remove side-effect bloat from amp-story bundle #37081

Merged
merged 2 commits into from
Dec 1, 2021

Conversation

alanorozco
Copy link
Member

@alanorozco alanorozco commented Nov 30, 2021

By importing AMP_STORY_PLAYER_EVENT (whose value equals its name), we're accidentally bundling all of @ampproject/toolbox-cache-url. It's equivalent to 2.30 kb compressed (!!!)

Closure knew how to remove this code, but esbuild does not. We move the string to a standalone file.

@amp-owners-bot
Copy link

Hey @gmajoulet, @newmuis! These files were changed:

extensions/amp-story/1.0/amp-story-system-layer.js

@samouri
Copy link
Member

samouri commented Nov 30, 2021

I had already investigated this and believe I solved it via #37052... did I mess something up there? A separate possibility would be to directly import the module build from node_modules instead of relying on automatic package detection

@alanorozco
Copy link
Member Author

(discussed offline):

@samouri I had already investigated this and believe I solved it via #37052... did I mess something up there?

Your change to use module was correct. But it allows part of the import to be tree-shaken, not its entirety.

Copy link
Member

@samouri samouri left a comment

Choose a reason for hiding this comment

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

Thank you for finding this. You deserve a 🎖️

@alanorozco alanorozco merged commit 3c0b66a into ampproject:main Dec 1, 2021
@alanorozco alanorozco deleted the mysterious-bloat branch December 1, 2021 00:17
@gmajoulet
Copy link
Contributor

Thank you Alan! If you ever do a presentation on the tools/process you use to find all of these, that'd be really awesome and useful for a lot of us!

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.

None yet

4 participants