我们使用SystemJS加载两个包:aurelia.js和app-build.js。SystemJ正在一个接一个地加载它们。我们如何让SystemJ同时加载它们?

我们的config.js (为了清晰起见省略了详细信息)如下所示:
System.config({
defaultJSExtensions: true,
transpiler: "none",
paths: {
// omitted
},
meta: {
// omitted
},
map: {
// omitted
},
bundles: {
"app-build.js": [
"about.html!github:systemjs/plugin-text@0.0.3.js",
"about.js",
"admin.html!github:systemjs/plugin-text@0.0.3.js",
"admin.js",
// et cetera
],
"aurelia.js": [
"github:HubSpot/tether@1.3.2.js",
"github:HubSpot/tether@1.3.2/js/tether.js",
"github:Leaflet/Leaflet@0.7.7.js",
"github:Leaflet/Leaflet@0.7.7/dist/leaflet-src.js",
// et cetera
]
},
depCache: {
// omitted
}
});发布于 2016-06-16 01:36:39
config.js告诉SystemJS加载程序,每个模块位于哪个包中。然后,SystemJS会在需要模块时加载捆绑包。您之所以看到上面的内容,是因为依赖性层次结构是线性的。您的index.html可能有如下一行:
System.import('aurelia-bootstrapper');因此,SystemJS查找‘’模型,并加载所需的包。引导程序开始时,根据您的配置加载您的main.js或app.js文件。
最佳解决方案
请不要,而不是,将您的包分开。如果您正在捆绑,您可能也是GZipping,因为这两者都是生产环境的标准,并且应该总是一起发生。如果将所有文件打包到一个文件中,GZip将实现更高的压缩比。除非您没有自己创建捆绑包,否则几乎没有理由分离您的包。
另一个解决方案
在您的index.html中添加另一个包的手动导入和‘aurelia’导入。
<script>
System.import('my-module/main');
System.import('aurelia-bootstrapper');
</script>https://stackoverflow.com/questions/37796623
复制相似问题