Mic*_*lix 9 caching amd requirejs systemjs
我想从requirejs迁移到SystemJS但是我没有找到解决方案,因为requirejs有模块版本控制.例如在生产(ASP.Net网站)中我设置了RequireJS,如下所示:
require.config({
baseUrl: "@Url.Content("~/Scripts/")",
urlArgs: "buildNumber=@(File.GetLastWriteTime(ViewContext.Controller.GetType().Assembly.Location).ToBinary().ToString() + typeof(Foundation.MvcApplication).Assembly.GetName().Version)",
...
});
Run Code Online (Sandbox Code Playgroud)
它保证在生产环境中重新发布项目后重新加载文件,并保持这种方式直到重新加载.
但是,我没有为SystemJS找到任何解决方案(因为SystemJS管理更多类型的模块,我想迁移到它).
有没有人在生产中使用SystemJS并遇到同样的问题,你知道SystemJS中的"urlArgs"参数(或插件)吗?
长话短说:SystemJS关于 缓存破灭的 github上存在问题.但事情还没有正式实施.目前有一个自定义钩子,可以很容易地添加
var buildNumber = 1234, // made your own build number
systemLocate = System.locate;
System.locate = function(load) {
return Promise.resolve(systemLocate.call(this, load)).then(function(address) {
return address + '?build='+buildNumber;
});
}
Run Code Online (Sandbox Code Playgroud)
编辑修复错字