videojs-record: Play button doesn't work with video.js 6.2.0 and webpack

Description

Playing the recorded video doesn’t work with video.js 6.0.0 ~6.2.0 When you record a video and then press the play button noting happens.

Steps to reproduce

Install video.js ~6.2.0

Results

Expected

Should play the video.

Error output

Uncaught TypeError: videojs.getComponent is not a function

Additional Information

versions

videojs

what version of videojs does this occur with? video.js 6.2.0 videojs-record 1.6.1

browsers

what browser are affected? Tested in Firefox and Chrome

OSes

what platforms (operating systems and devices) are affected? Linux

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 42 (24 by maintainers)

Commits related to this issue

Most upvoted comments

@gavfu You can alias video.js to use the non-ES6 version.

Use something like this in your webpack config:

  resolve: {
    alias: {
      'video.js': path.resolve(__dirname, '../../node_modules/video.js/dist/video.js')
    }
  }

This is a quick workaround until this issue is resolved.

it’s ok. ESM is short for ES modules or Ecmascript modules. That is the import and export syntax. CJS is commonjs, i.e., what nodejs uses and what bundlers used to use.

A new release of this plugin (in short term) would pin video.js to anything < 6.2.0.

@thijstriemstra I could get down to the root of the problem. The problem is the combination of ES6 exports export default videojs and requirejs imports require('video.js)

video.js switched from module.exports = videojs in 6.1.0 to export default videojs in 6.2.0 And while videojs-record still uses require('video.js) and if you use ES6 stops working.

https://github.com/videojs/video.js/blob/v6.1.0/src/js/video.js#L727 https://github.com/videojs/video.js/blob/v6.2.0/src/js/video.js#L726

So the fix to this is as I understand it to switch to ES6 imports or to change the require to require('video.js).default

But I’m not really an expert regarding this subject.

Explanations of this problem: https://github.com/videojs/video.js/issues/2698#issuecomment-148151327 https://medium.com/@kentcdodds/misunderstanding-es6-modules-upgrading-babel-tears-and-a-solution-ad2d5ab93ce0

Getting same issue with

    "video.js": "^6.1.0",
    "videojs-record": "^1.6.2"

TypeError: videojs.getComponent is not a function

Just tested, it works if I use video.js like: “video.js”: “6.1.0”,

Linux with Firefox 54 and Chromium 58. Maybe it’s an Webpack problem. I’ll investigate in the next days and get back to you.