Answer the question
In order to leave comments, you need to log in
Why are there problems loading jquery plugins that have a factory check?
I'm using typescript , modules are commonjs . Uploading files using SystemJS . I needed to screw this plugin , I did it this way:
SystemJS.config({
"defaultJSExtensions": true,
map: {
css: '/js/system-css.js',
},
meta: {
'*.css': { loader: 'css' }
},
baseURL: '/',
paths: {
jquery: 'js/jquery',
scrollbar: 'js/scrollbar',
datepicker: 'js/datepicker'
}
});
var systemLocate = System.locate;
System.locate = function (load) {
var System = this;
return Promise.resolve(systemLocate.call(this, load)).then(function (address) {
return address + System.cacheBust;
});
};
System.cacheBust = '?id=' + CONFIG.version;
System.import('js/bootstrap.js');
SystemJS Multiple anonymous defines in module
(factory) {
if ( typeof define === 'function' && define.amd ) {
// AMD. Register as an anonymous module.
define(['jquery', 'jquery-mousewheel'], factory);
} else if (typeof exports === 'object') {
// Node/CommonJS style for Browserify
module.exports = factory;
} else {
// Browser globals
factory(jQuery);
}
}
Answer the question
In order to leave comments, you need to log in
This is a module in UMD format . Angular2, for example, ships its modules in this format.
Use `map` instead of `path`:
SystemJS.config({
"defaultJSExtensions": true,
map: {
css: '/js/system-css.js',
datepicker: 'js/datepicker.js'
},
meta: {
'*.css': { loader: 'css' }
},
baseURL: '/',
paths: {
jquery: 'js/jquery',
scrollbar: 'js/scrollbar'
}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question