5

I'm trying to use require.ensure in my react component:

componentDidMount() {
    require.ensure([], () => {
        require('public/jscripts/brightcove/index.js');
    });
}

but keep getting an error: Cannot set property 'default' of undefined

It happens at this point in the brightcove videojs script:

// At this point, `window.videojs` will be the earliest-defined copy of this
// version of videojs.
var videojs = window.videojs;

// https://github.com/videojs/video.js/issues/2698
videojs['default'] = videojs;

Does anyone know why this might be happening?

The full script is here btw, I saved it as a local file hence the path public/jscripts/brightcove/index.js: https://players.brightcove.net/1752604059001/B1xXFuBodW_default/index.js

AnilRedshift
  • 7,937
  • 7
  • 35
  • 59
MarksCode
  • 8,074
  • 15
  • 64
  • 133
  • Isnt this just about missing of videojs dependency? Try `require.ensure(['video.js'], () => { require('public/jscripts/brightcove/index.js'); });` – bigless Jul 16 '18 at 19:56
  • Are you including `video.js` before? Also, in video.js documentation, it is stated the following: `Next, using Video.js is as simple as creating a – Rodrigo Mata Jul 18 '18 at 03:15

0 Answers0