При наборе js-файлов с использованием webpack
библиотека jplayer
также попадает в файл bundle.js
. Но когда веб-страница загружается в браузере, на консоли отображается сообщение об ошибке cannot set property jplayer of undefined
. Я запутался в ошибке, вызванной веб-пакетом, или есть ошибка в jplayer-библиотеке. Помощь супер очень высоко ценится.webpack jplayer: невозможно установить свойство jplayer undefined
jplayer.js
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery'], factory); // jQuery Switch
// define(['zepto'], factory); // Zepto Switch
} else if (typeof exports === 'object') {
// Node/CommonJS
factory(require('jquery')); // jQuery Switch
//factory(require('zepto')); // Zepto Switch
} else {
// Browser globals
if(root.jQuery) { // Use jQuery if available
factory(root.jQuery);
} else { // Otherwise, use Zepto
factory(root.Zepto);
}
}
}(this, function ($, undefined) {
// Adapted from jquery.ui.widget.js (1.8.7): $.widget.bridge - Tweaked $.data(this,XYZ) to $(this).data(XYZ) for Zepto
$.fn.jPlayer = function(options) { //cannot set property jplayer error is mapped here
var name = "jPlayer";
var isMethodCall = typeof options === "string",
args = Array.prototype.slice.call(arguments, 1),
returnValue = this;
// allow multiple hashes to be passed on init
options = !isMethodCall && args.length ?
$.extend.apply(null, [ true, options ].concat(args)) :
options;