Comments (8)
没懂
模块化后,应该比以前更容易定位到问题所在,并快速做出处理。
from aralejs.github.io.
是由发布流程决定的,我们代码上线需要一定的流程才能上线。现在如果代码有问题,通过cms实时发布一段代码暂时解决问题。以后可能会把cms作为正常的修复方式,所以我们要提供一个如何修复的方案,如果有可以给个最佳实践的文档。
from aralejs.github.io.
这个可以,支持等一定阶段的时候,梳理出一份最佳实践
并且有可能在这点上大幅提升体验
from aralejs.github.io.
这个在以前实现自己的那个加载器的时候就想过类似的问题啊, 下面是我的一点想法. 供大家参考
这类问题基本上有两类需求
- 就是上面提到的, 如果我们有一个模块有问题, 但是由于我们的模块基本上对外暴露的都是api, 也可以认为是某个方法有问题, 所以如果我们能把这个方法动态的进行替换, 基本上就能解决上面的这个问题了.
- 另一个和这个类似, 比如有这样一个需求. 如果我们在某一个项目需要对所有的ajax的get请求增加一个参数. 那么这种情况其实也可以认为对这个方法进行增强.
对应这两个方案可以有下面基本的处理方式
- proxy, : 我们可以对指定的模块(这个模块是还没有加载或者加载还没有被执行)中增加代理功能, 这样我们就可以在proxy增加逻辑对模块中的所有方法进行拦截(AOP), 如果没有问题的方法, 我们正常调用原有模块的方法, 但是如果有问题的我们可以把这个方法的请求到代理模块上进行代码修正的方法.
- 装饰 or filter. 我们可以对模块的方法中增加decorate. 我们可以在装饰代码中执行一定的逻辑后, 在继续转调实际的方法即可. 或者我们可以支持对方法增加参数增过滤器等, 经过过滤的参数才能被传递给实际方法.
如何发布呢?
- 简单的方式就可以通过cms. 这样我们在页面的头部, 把我们hack的代码提前加载进来, 这样当实际模块加载和执行的时候这些hack代码就可以生效了.
from aralejs.github.io.
关于如何发布?
我们可以提供一整套cms的修复方案,除了康辉刚才说的还可以控制hack范围,比如只处理某一个页面或一个系统。
这样有助于我们的hack代码的管理
如何处理
我们可以在出口做拦截,require的时候对返回对象进行替换,可以替换对象或者方法。
拦截的代码也可以场景判断,比如要触发这个hack才去load拦截的代码,一般场景是用不到的。
from aralejs.github.io.
恩, 比如可以这样
seajs.proxy('arale.base-2.0-SNAPSHOT', function(exports, module) {
export.get = function() {console.log('禁止使用!');}
});
我们可以给某一个模块绑定一个代理, 然后在这个代理函数中可以在用户使用之前获取exports, module. 然后这个代理就有机会在用户使用这个模块之前, 对模块进行替换或者增强等.
然后类似下面的代码, 我们可以在用户require模块的时候, 在返回exports之前, 去检查代理, 发现有的话, 可以去执行代理.
var proxys = mod.proxys;
var proxy;
while(proxy = proxys.shift()) {
proxy.call(mod, exports, mod);
}
return mod.exports;
from aralejs.github.io.
我期望是通过配置来实现
seajs.config({
bugfix:{
'arale.base-2.0-SNAPSHOT', function(exports, module) {
export.get = function() {console.log('禁止使用!');}
}
}
}
如果require了arale.base,则同时require proxy。在callback执行前调用bugfix里的function,类似一个filter的功能。
这样可以把proxy和其他模块解耦合,还能按需加载,不让proxy影响到其他模块。
from aralejs.github.io.
整理了一下,seajs v1.2 会增加 mock 和 modify 功能。其中 modify 功能可用来快速修复线上 bug:
from aralejs.github.io.
Related Issues (20)
- 关于base里面的destory方法
- concat链接中有回车符,firefox(linux/ff-30)无法加载. HOT 2
- 建议加个bt2.1.3吧 我自己改了一个 HOT 3
- 用spm安装到本地时怎么选择特定版本? HOT 1
- 会不会考虑加入jqGrid或类似组件? HOT 2
- 官网打不开 HOT 2
- 大半年过去了,似乎都没有什么大的更新呢 HOT 3
- 关于 Arale 的过去、现在和未来 HOT 27
- arale calendar dialog confirm-box 初始化第一次偶尔不执行 刷新一次后就好了 HOT 2
- 日历插件有监听选择日期后的事件吗? HOT 1
- aralejs.org 迁移到 spm3
- aralejs 设计的这么优雅,为什么没有火起来? HOT 7
- spm安装的js无法导入 HOT 6
- 部署也太麻烦了吧
- 用aralejs写业务代码有没有什么最佳实践呢?希望可以回复或讨论一下 HOT 1
- 官网首页出问题了?首页的内容不显示 HOT 2
- 按照官网的步骤创建模块报错了 HOT 1
- Calendar在IE8下报错运行不了 HOT 1
- 官网链接失效(docs/attribute.html) HOT 2
- 官网502啦~ HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aralejs.github.io.