我试图更改名称空间js。包裹(function (undefined) {...}).call(this);
的脚本我可以在调用中传递命名空间,但是这会破坏bower更新兼容性(bower会覆盖我的更改,我可能忘记保持文件同步)。你能建议替代解决方案吗?
文档建议使用require.js传递配置选项。http://momentjs.com/docs/#/use-it/require-js/这是我必须加载的附加脚本。有没有替代require.js?
时刻js有一个makeGlobal函数:
function makeGlobal(shouldDeprecate) {
/*global ender:false */
if (typeof ender !== 'undefined') {
return;
}
oldGlobalMoment = globalScope.moment;
if (shouldDeprecate) {
globalScope.moment = deprecate(
'Accessing Moment through the global scope is ' +
'deprecated, and will be removed in an upcoming ' +
'release.',
moment);
} else {
globalScope.cplex = {};
globalScope.cplex.moment = moment;
}
}
我将js与make结合并缩小。一个不理想的解决方案:
//moment-init.js
var ender = undefined;
if(typeof moment !== 'undefined'){
var existingMomentJs = moment;
}
//load moment script
//moment-overrider.js
//updating namespace for moment js - abc namespace
var abc = {};
var ender = undefined;
abc.moment = moment;
if(typeof existingMomentJs !== 'undefined'){
moment = existingMomentJs;
}