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

✨[amp-story-player] Upgrading amp-story-player to CE #27320

Merged
merged 12 commits into from
Apr 6, 2020

Conversation

Enriqe
Copy link
Contributor

@Enriqe Enriqe commented Mar 19, 2020

Changing the player to use CustomElements. This will help us open up an API for the player.

  • Also now listens to the load event listener in the window to initialize the player, instead of overriding the onload function.

Tracker #26308

To be merged after #27324

@Enriqe Enriqe changed the title [wip] Upgrading amp-story-player to use CE ✨[amp-story-player] Upgrading amp-story-player to CE Mar 19, 2020
@Enriqe Enriqe marked this pull request as ready for review March 19, 2020 22:43
Copy link
Contributor

@gmajoulet gmajoulet left a comment

Choose a reason for hiding this comment

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

Asking questions because I don't know much about CustomElements! :(

src/amp-story-player-manager.js Outdated Show resolved Hide resolved
src/amp-story-player-impl.js Show resolved Hide resolved
test/unit/test-amp-story-player.js Outdated Show resolved Hide resolved
@Enriqe
Copy link
Contributor Author

Enriqe commented Mar 26, 2020

@jridgewell could you please help reviewing this PR, since I don't have much experience using CEs and I'm not sure if I'm doing something wrong 😄

src/amp-story-player-impl.js Outdated Show resolved Hide resolved
src/amp-story-player-impl.js Outdated Show resolved Hide resolved
src/amp-story-player-manager.js Outdated Show resolved Hide resolved
src/amp-story-player.js Outdated Show resolved Hide resolved
Copy link
Contributor

@newmuis newmuis left a comment

Choose a reason for hiding this comment

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

Whoops, didn't mean to approve

Copy link
Contributor Author

@Enriqe Enriqe left a comment

Choose a reason for hiding this comment

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

PTAL

@Enriqe
Copy link
Contributor Author

Enriqe commented Apr 1, 2020

Friendly ping @gmajoulet @jridgewell

@gmajoulet
Copy link
Contributor

This LGTM, but I'll let @jridgewell give the approval as he understands this code a lot better than I do :)

@Enriqe
Copy link
Contributor Author

Enriqe commented Apr 2, 2020

@jridgewell friendly ping :)

@Enriqe
Copy link
Contributor Author

Enriqe commented Apr 3, 2020

bumping this up for @jridgewell

@jridgewell
Copy link
Contributor

I've been OOO. Sorry for the delay.

@Enriqe
Copy link
Contributor Author

Enriqe commented Apr 6, 2020

No worries @jridgewell, thanks for taking a look!

@newmuis could you PTAL?

Copy link
Contributor

@newmuis newmuis left a comment

Choose a reason for hiding this comment

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

This mostly LGTM. Approving to unblock.

Quick question @jridgewell: does Closure compiler not do anything to wrap private methods in a closure or something? Also, won't these member and function names all be minified? If so, should we keep the _ as a trailing suffix to match the Prettier rules and the rest of the repository?

@jridgewell
Copy link
Contributor

does Closure compiler not do anything to wrap private methods in a closure or something?

This isn't possible for objects without considerable memory increases (every object must close over its functions and variables). This is generally frowned upon.

Also, won't these member and function names all be minified?

They should. We should check.

If so, should we keep the _ as a trailing suffix to match the Prettier rules and the rest of the repository?

Oh, in that case, yah, why not just use trailing and let the mangler make them "private"?

@Enriqe
Copy link
Contributor Author

Enriqe commented Apr 6, 2020

Reverted the commit that changed the trailing underscore to a suffix for private properties (we'll use the trailing _ like the rest of the repo), and let Closure compiler mangle the private property names (e.g. obj.foobar_ becomes obj.A). Thanks @jridgewell !

@cramforce
Copy link
Member

Could/should we move the source into its own directory? I find it a bit weird to see it mixed with core AMP.

@Enriqe
Copy link
Contributor Author

Enriqe commented Apr 15, 2020

On the original design and at the time of launch we thought it was appropriate for it to live in the AMPHTL repo, especially since we plan on developing an AMP version of it as well. This way we could leverage the existing tools and infra of the repo, while potentially sharing tests between the two versions since the goal is to have an identical API.

Recently, it has been brought to us that users could potentially benefit from this becoming a standalone package that could be installed via npm. This would require moving this to its own repo, I have filed #27615 to track this and tackle it when appropriate.

@cramforce
Copy link
Member

Does it really have to be its own repo? Wouldn't a directory with its own package.json work?

I was simply making a point about code-organization and not having a single mega-directory here.

@Enriqe
Copy link
Contributor Author

Enriqe commented Apr 15, 2020

Oh, my bad. Yes we should be able to move it to its own directory.

danielrozenberg pushed a commit that referenced this pull request Apr 16, 2020
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.

7 participants