MailOnline / videojs-vast-vpaid

video.js vast plugin
MIT License
296 stars 232 forks source link

Cannot load the plugin using browserify #220

Open TablesawTablesawsen opened 8 years ago

TablesawTablesawsen commented 8 years ago

Similar to the issues in #91, I am getting a variety of errors when I attempt to load this plugin using browserify. Specifically, I am using browserify 13.0.1 with babelify 7.3.0. My video.js is at 5.10.4 and my videojs-vast-vpaid is at 2.0.1 (all installed via npm). I have tried a number of different inclusions and gotten different errors, and I cannot be sure where the problem is.

When attempting to import/require 'videojs-vast-vpaid', I get the error, "Error: Cannot find module 'videojs-vast-vpaid/videojs_5.vast.vpaid.js' from '/home/tablesaw/dev/player/src'", during browserifying.

When attempting to import/require 'videojs-vast-vpaid/bin/videojs_5.vast.vpaid.js', I get the error, "Error: Cannot find module './IVPAIDAdUnit' from '/home/tablesaw/dev/player/node_modules/videojs-vast-vpaid/bin'", during browserifying.

When attempting to import/require 'videojs-vast-vpaid/bin/videojs_5.vast.vpaid.min.js', the build succeeds, and I runtime I get an error:

videojs_5.vast.vpaid.min.js:3Uncaught ReferenceError: videojs is not defined
r.36../ads-label    @   videojs_5.vast.vpaid.min.js:3
o   @   videojs_5.vast.vpaid.min.js:1
(anonymous function)    @   videojs_5.vast.vpaid.min.js:1
r.49../plugin/components/ads-label_5    @   videojs_5.vast.vpaid.min.js:4
o   @   videojs_5.vast.vpaid.min.js:1
i   @   videojs_5.vast.vpaid.min.js:1
r.95    @   videojs_5.vast.vpaid.min.js:1
i   @   _prelude.js:1
(anonymous function)    @   _prelude.js:1
...

When attempting to import/require 'videojs-vast-vpaid/src/scripts/videojs_5.vast.vpaid.js', I get the error, "Error: Cannot find module 'VPAIDFLASHClient/js/VPAIDFLASHClient' from '/home/tablesaw/dev/player/node_modules/videojs-vast-vpaid/src/scripts/ads/vast'" during browserifying. [This is the same result as #91]

The following attempts involve using broswerify-shim (3.8.12) to incorporate the file.

Using the shim setup:

  "browser": {
   "videojs-vast-vpaid": "./node_modules/videojs-vast-vpaid/bin/videojs_5.vast.vpaid.js"
  },
  "browserify-shim": {
    "videojs-vast-vpaid": "videoJsVAST"
  }

The build succeeds, but at runtime, I get the error:

Uncaught Error: Cannot find module './plugin/components/ads-label_5'
i @ _prelude.js:1
(anonymous function) @ _prelude.js:1
r.49../plugin/components/ads-label_5 @ videojs_5.vast.vpaid.js:4
i @ IVPAIDAdUnit.js:1
a @ IVPAIDAdUnit.js:1
n.call.e.exports @ IVPAIDAdUnit.js:1
(anonymous function) @ airtv-2.0.js:47269
r.95 @ airtv-2.0.js:47271
i @ _prelude.js:1
(anonymous function) @ _prelude.js:1
...

If I shim the minified script, the build succeeds and I get the error:

Uncaught ReferenceError: videojs is not defined
r.36../ads-label @ videojs_5.vast.vpaid.min.js:4
i @ videojs_5.vast.vpaid.min.js:2
(anonymous function) @ videojs_5.vast.vpaid.min.js:2
r.49../plugin/components/ads-label_5 @ videojs_5.vast.vpaid.min.js:5
i @ videojs_5.vast.vpaid.min.js:2
o @ videojs_5.vast.vpaid.min.js:2
t.call.e.exports @ videojs_5.vast.vpaid.min.js:2
(anonymous function) @ videojs_5.vast.vpaid.min.js:10
...

If I shim "/node_modules/videojs-vast-vpaid/src/scripts/videojs_5.vast.vpaid.js", I get a similar error to the first shim: _prelude.js:1 Uncaught Error: Cannot find module './plugin/components/ads-label_5'

With the various builds, it's hard for me to to tell which if any of these methods of incorporating the plugin should work with browserify. Can someone confirm what is the intended method, so that we can possibly investigate whether there is an underlying bug?

TablesawTablesawsen commented 8 years ago

For any who come after, I got this working with browserify-shim:

  "browser": {
    "videojs-vast-vpaid": "./node_modules/videojs-vast-vpaid/bin/videojs_5.vast.vpaid.min.js"
  },
  "browserify-shim": {
    "videojs-vast-vpaid": {
      "depends": [
        "video.js:videojs"
      ]
    }
  }