redxtech / vue-plyr

A Vue component for the plyr (https://github.com/sampotts/plyr) video & audio player.
Other
770 stars 136 forks source link

You may need an appropriate loader to handle this file type. #198

Closed Olis-HL closed 3 years ago

Olis-HL commented 4 years ago

ERROR in ./node_modules/vue-plyr/dist/vue-plyr.mjs Module parse failed: Unexpected token (234:53) You may need an appropriate loader to handle this file type. | VuePlyr.install = (Vue, options = {}) => { | if (options.plyr) { | VuePlyr.props.options.default = () => { return { ...options.plyr } }; | }

lianwf commented 4 years ago

How did you solve it in the end

Arxi commented 4 years ago

@Olis-HL @lianwf also stuck on this, did you find any solution?

The problem seems to be the spread operator (...), so I tried updating my babel libs and including babel plugins: "@babel/plugin-transform-spread" "@babel/plugin-proposal-object-rest-spread"

but doesn't help

dcastrili commented 4 years ago

Hello,

Try to install the babel loader


npm install -D babel-loader @babel/core @babel/preset-env webpack

and add the rules to your webpack config file

module: {
  rules: [
    {
      test: /\.m?js$/,
      exclude: /(node_modules|bower_components)/,
      use: {
        loader: 'babel-loader',
        options: {
          presets: ['@babel/preset-env']
        }
      }
    }
  ]
}
skjnldsv commented 3 years ago

Yes, this is unrelated to this library, this is because you're not using the appropriate loaders https://github.com/nextcloud/viewer/blob/master/webpack.js#L11-L26

You also need to include it in the babel transpilling process

{
    module: {
        rules: [
            ...
            {
                // vue-plyr uses .mjs file
                test: /\.m?js$/,
                loader: 'babel-loader',
                exclude: BabelLoaderExcludeNodeModulesExcept([
                    'vue-plyr',
                ]),
            },
            ...
        ],
    },
}
PeiDeng commented 3 years ago

finally I solved this problem depends on the solution from @dcastrili @skjnldsv, with a little modification. { test: /\.mjs$/, loader: 'babel-loader', } put this into the webpack rules instead of above if you are still struggling

redxtech commented 3 years ago

As the others have stated above, this is an issue with your tooling, so I'll close this.