先说结果 , 可使用以下格式引入了
require('mylib/huanxin/webim.config.js')
require('mylib/huanxin/strophe-1.2.8.js')
require('easemob-websdk')
改动部分:
webim.config.js 改为 如下格式
var WebIM = window.WebIM || {};
WebIM.config = { ... }
window.WebIM = WebIM
strophe-1.2.8.js
第 23行, 添加: if(window.Strophe) return; 防止重复
从 第 5698 行:
改为如下: (即 注释掉requirejs和seajs兼容部分, 并call一下window)
/* jshint ignore:start */
if (callback) {
// if (typeof define === 'function' && define.amd) {
// //For backwards compatability
// var n_callback = callback;
// if (typeof requirejs === 'function') {
// requirejs(["strophe"], function (o) {
// n_callback(o.Strophe, o.$build, o.$msg, o.$iq, o.$pres);
// });
// } else {
// require(["strophe"], function (o) {
// n_callback(o.Strophe, o.$build, o.$msg, o.$iq, o.$pres);
// });
// }
// } else {
return callback(Strophe, $build, $msg, $iq, $pres);
// }
}
}).call(window, function (Strophe, build, msg, iq, pres) {
window.Strophe = Strophe;
window.$build = build;
window.$msg = msg;
window.$iq = iq;
window.$pres = pres;
});