2016-02-15 37 views
8

我想从requirejs迁移到SystemJS,但是我无法找到requirejs用于模块版本控制的解决方案。 例如,在生产(ASP.Net网站)我已经设置RequireJS这样的:用于生产和缓存管理的SystemJS版本控制(requirejs urlArgs替代)

require.config({ 
      baseUrl: "@Url.Content("~/Scripts/")", 
      urlArgs: "[email protected](File.GetLastWriteTime(ViewContext.Controller.GetType().Assembly.Location).ToBinary().ToString() + typeof(Foundation.MvcApplication).Assembly.GetName().Version)", 
      ... 
}); 

它保证一旦该项目在生产环境中重新发布该文件将被重新加载,并保持这种方式,直到它重新加载。但是,我没有找到任何针对SystemJS的解决方案(作为SystemJS管理更多类型的模块,我想迁移到它)。

有没有人在生产中使用过SystemJS并且有同样的问题,你知道SystemJS中的“urlArgs”参数(或插件)吗?

+0

? --- P.S.我仅使用requireJS并将所有内容缓存至365天。一切运行良好,为什么你首先需要systemJS? –

+0

我编辑过帖子,它只是为了知道是否有人发现参数/插件具有RequireJS的相同urlArgs行为。 SystemJS让我们使用许多类型的模块定义,所以我觉得它更“面向未来”。 –

+0

我现在明白了,看起来你可以在这里找到你的答案。 http://stackoverflow.com/questions/33332911/can-system-js-replace-require-js –

回答

7

长话短说:关于cache bust的github上有问题SystemJS。但事情还没有正式实施。目前有一个自定义的钩子,它可以很容易地添加

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; 
    }); 
} 

我真的不明白你的问题编辑修复错字

+2

事实上,SystemJS的制造者表示它不会在SystemJS上实现,他说“缓存应该在服务器层处理,而不是在装载机层“。 –

+0

自0.20起不起作用:https://github.com/systemjs/systemjs/issues/1616 –