I've got following set up in my index.html:
...
<script src="ponents/angular/angular.js"></script>
<script src="ponents/traceur/traceur.js"></script>
<script src="ponents/es6-module-loader/dist/es6-module-loader.src.js"></script>
<script src="ponents/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 mon libs) globally via script tag. 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
. 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.
Can anybody show how to configure system.js to work with global libs?
I've got following set up in my index.html:
...
<script src="ponents/angular/angular.js"></script>
<script src="ponents/traceur/traceur.js"></script>
<script src="ponents/es6-module-loader/dist/es6-module-loader.src.js"></script>
<script src="ponents/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 mon libs) globally via script tag. 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
. 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.
Can anybody show how to configure system.js to work with global libs?
Share Improve this question asked Dec 30, 2014 at 19:07 coquincoquin 1,3861 gold badge13 silver badges22 bronze badges 3- that goes against the whole point of using a module loader like System. If you really want to do this anyway, see: groups.google./forum/#!topic/systemjs/0_tuZW5s-JY – user2943490 Commented Dec 31, 2014 at 0:03
- What about big ones where you want to include them outside your SystemJS build: a) for build performance reasons, b) because other things rely on them being global. For example I want to use Three.js and also the Three.js 'extra' ColladaLoader which attaches itself to the global THREE object... Browserify-shim, for example, remends doing that by including them with separate script tags. – poshaughnessy Commented Apr 25, 2015 at 10:51
- The SystemJS docs remend adapter modules for globals via separate script includes (github./systemjs/builder#adapter-modules). However, this doesn't help if you're using a library that require()'s it via its npm name... :( – poshaughnessy Commented Apr 25, 2015 at 14:27
1 Answer
Reset to default 7System.registerDynamic('angular', [], false, function(require, exports, module) {
module.exports = window.angular;
});
or
System.set('angular', System.newModule({
"default": window.angular
}));
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744402248a4572448.html
评论列表(0条)