ima is not a function when i trying to use ima plugin with webpack project
See original GitHub issueHi all, a have big problem with using this plugin in my project. Libs:
video.js: v7.1.0
videojs-ima: v1.5.1
Code:
import videojs from 'videojs';
import 'videojs-ima';
class TestIMA {
constructor() {}
test() {
const player = videojs(document.querySelector('.videojs-test'));
player.ready(() => {
player.ima({
id: 'video_story_item',
adTagUrl: '...'
});
});
}
}
const testIMA = new TestIMA();
testIMA.test();
And i’m getting error
ima is not a function
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Bundle videojs with videojs-ima plugin - Stack Overflow
I am trying (already few days) to achieve very simple task: build one javascript file that bundle all necessarily parts to play video...
Read more >Videojs ads demo - Caritas Castellaneta
Defaults to false videojs-contrib-ads + ima VideoJS websites that are also using Ads. Past the shortcode in post, page, widget areas To publish...
Read more >Watch and WatchOptions | webpack
Webpack can watch files and recompile whenever they change. This page explains how to enable this and a couple of tweaks you can...
Read more >TypeScript - webpack
const path = require('path'); module.exports = { entry: './src/index.ts', module: { rules: [ { test: /\.tsx?$/, use: 'ts-loader', exclude: /node_modules/, }, ], } ......
Read more >Step-by-Step: Video.js Plugin Generator
In this topic, you will learn how to use the video.js plugin generator to create and test plugins for the Brightcove Player.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
After many late night hours I as finally able to configure webpack to import the dang module and expose the init method of the ImaPlugin. It’s a shim that forces the module to call
registerPlugin
against a temp var that holds the ImaPlugin init function. The exports loader exposes the temp var as a module default so we can snag the init method and register the plugin against the proper videojs instance.webpack.config
my_code_file.js
I believe the issue is how webpack isolates each module. If you perform a standard import of the videojs-ima plugin all appears to be okay but the videojs instance the plugin initializes against is different than the one you’re working on.
Dear hard working Google devs, for the love of god, export the ImaPlugin. It would be even cooler if you could update your bundle process to create a true ES6 module in the dist 😃
Hi all,
It looks as though the issue has been resolved. Please see our import guide if you are using webpack for your app.