Skip to content

Commit c91e704

Browse files
authored
♻️ Prevent VideoInterface class from being bundled (ampproject#37080)
`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.
1 parent b0dc413 commit c91e704

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Diff for: src/video-interface.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ export const MIN_VISIBILITY_RATIO_FOR_AUTOPLAY = 0.5;
1818
* @interface
1919
*/
2020
export class VideoInterface {
21+
/** @return {!AmpElement} */
22+
get element() {}
23+
24+
/** @return {!Window} */
25+
get win() {}
26+
2127
/**
2228
* See `BaseElement`.
2329
* @return {!./utils/signals.Signals}
@@ -182,12 +188,6 @@ export class VideoInterface {
182188
seekTo(unusedTimeSeconds) {}
183189
}
184190

185-
/** @type {!AmpElement} */
186-
VideoInterface.prototype.element;
187-
188-
/** @type {!Window} */
189-
VideoInterface.prototype.win;
190-
191191
/**
192192
* Attributes
193193
*

0 commit comments

Comments
 (0)