Skip to content

Commit

Permalink
♻️ Prevent VideoInterface class from being bundled (#37080)
Browse files Browse the repository at this point in the history
`esbuild` lacks the `@interface` concept from Closure. As a result, it believes that `VideoInterface.prototype.element;` could have side effects, and preserves the empty class. Bundles that import utilities from `src/video-interface.js` include this useless class.

We avoid this issue by defining dynamic getters instead.
  • Loading branch information
alanorozco committed Nov 30, 2021
1 parent b0dc413 commit c91e704
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/video-interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ export const MIN_VISIBILITY_RATIO_FOR_AUTOPLAY = 0.5;
* @interface
*/
export class VideoInterface {
/** @return {!AmpElement} */
get element() {}

/** @return {!Window} */
get win() {}

/**
* See `BaseElement`.
* @return {!./utils/signals.Signals}
Expand Down Expand Up @@ -182,12 +188,6 @@ export class VideoInterface {
seekTo(unusedTimeSeconds) {}
}

/** @type {!AmpElement} */
VideoInterface.prototype.element;

/** @type {!Window} */
VideoInterface.prototype.win;

/**
* Attributes
*
Expand Down

0 comments on commit c91e704

Please sign in to comment.