[英]Global libraries with system.js
I've got following set up in my index.html: 我在index.html中设置了以下内容:
...
<script src="components/angular/angular.js"></script>
<script src="components/traceur/traceur.js"></script>
<script src="components/es6-module-loader/dist/es6-module-loader.src.js"></script>
<script src="components/system.js/dist/system.src.js"></script>
<script>
System.baseURL = '/';
</script>
<script type="module">
// Example
import angular from 'angular';
angular.module('myApp', [...]);
</script>
I'd like to load angular.js (and some other common libs) globally via script tag. 我想通过script标签全局加载angular.js(以及其他一些常用的lib)。 But when I'm trying to use it in modules (in my case, es6-modules) system.js tries to load it via URL
http://mysite/angular.js
. 但是,当我尝试在模块中使用它时(在我的情况下,es6-modules),system.js尝试通过URL
http://mysite/angular.js
加载它。 It just doesn't see that I've already included it as global lib. 它只是没有看到我已经将它作为全局库包含在内。 I spent several hours figuring out how can I handle this, read system.js wiki on Github, but I'm still stuck with this.
我花了几个小时搞清楚如何处理这个,在Github上阅读system.js wiki,但我仍然坚持这个。
Can anybody show how to configure system.js to work with global libs? 任何人都可以展示如何配置system.js以使用全局库吗?
System.registerDynamic('angular', [], false, function(require, exports, module) {
module.exports = window.angular;
});
or 要么
System.set('angular', System.newModule({
"default": window.angular
}));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.