videojs-contrib-ads
videojs-contrib-ads copied to clipboard
Can't use this plugin in require.js
Description
Include a short description of the problem you are seeing here.
Steps to Reproduce
http://jsfiddle.net/uy9680os/1/
Expected Results
"player.ads" should show a function
Actual Results
Error: Script error for "video.js", needed by: add-video-js-in-global-scope
and a failed attempt to load http://fiddle.jshell.net/_display/video.js
Versions
videojs-contrib-ads version: 6.4.1
Video-js version: 7.0.5
Platforms
Browsers: Firefox 60.0.2
OS/Devices: Windows 10
It seems the issue is that early on, the videojs-contrib-ads script contains factory(require('video.js'))
and define(['video.js']
. If that is changed to videojs
, that should fix the issue
I believe you mean Require.js rather than React.js in the title, yes? It appears this issue is inherited from generator-videojs-plugin. I have opened an issue there. When a fix is available upstream we'll update to get it.
Whoops. Fixed the title.
We cannot change the require call on our end from video.js
to videojs
because the module name is actually video.js
on npm, and other bundlers look at that.
I think we need to configure requirejs
to set video.js
as videojs
in the paths
configuration. Then use the map
configuration to map any require of video.js
to configured videojs
module. This is all to work-around the the name since requirejs
thinks that video.js
is a reference to a local javascript file when it is not.
Working example: https://jsfiddle.net/uy9680os/57/ .