sampotts / plyr

A simple HTML5, YouTube and Vimeo player
https://plyr.io
MIT License
26.64k stars 2.93k forks source link

Tree-Shaking The Library #2239

Open amir-mln opened 3 years ago

amir-mln commented 3 years ago

Hello

I'm trying to remove the unused code of plyr library ( plugins, controls, captions ) to reduce the bundle size.

Untitled

would you add a guide on how to do tree-shaking on the library?

I've tried importing as import {setup} from "plyr" but that did not work. I also tried importing as import Plyr from "plyr/src/js/plyr" but this gives this error:

SyntaxError: C:\VS Code Projects\kasbarg\node_modules\plyr\src\js\plyr.js: Support for the experimental syntax 'classProperties' isn't currently enabled (358:8):

  356 |    * Play the media, or play the advertisement (if they are not blocked)
  357 |    */
> 358 |   play = () => {
      |        ^
  359 |     if (!is.function(this.media.play)) {
  360 |       return null;
  361 |     }

Add @babel/plugin-proposal-class-properties (https://git.io/vb4SL) to the 'plugins' section of your Babel config to enable transformation.
If you want to leave it as-is, add @babel/plugin-syntax-class-properties (https://git.io/vb4yQ) to the 'plugins' section to enable parsing.

Thanks

sampotts commented 3 years ago

Tree-shaking isn't currently supported but will be in the next major version.