0

我在我的网站上使用Plyr.js,我需要删除库的 plugins.js 和 captions.js 以减小包大小,正如您在bundle image中看到的那样。

现在我已经试过了import {setup} from 'plyr',,,import Plyr from "plyr/dist/plyr"import Plyr from "plyr/src/js/plyr";

前两个对包大小没有影响,第三个给出了这个错误:

/node_modules/plyr/src/js/plyr.js
SyntaxError: C:\VSCode 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.

这是plyr文件夹结构:第一 第二 第三

4

0 回答 0