Reputation: 1213
I am loading my angular2 file as a System js module from CDN.
I have several files which imports various system js modules of angular2.
Now I want to bundle my local javascript files using JSPM. When I write the command
"jspm bundle app/main build.js"
JSPM fails. As JSPM is trying to find angular2 folder in my project. I know the reason that it checks the map defined in config.js. But I want to know how to overcome this. As I don't want to install angular2 file in my local project, and I definitely don't want to serve angular2 file from my server to client's browser, I want to use CDN.
Please help.
Upvotes: 0
Views: 429
Reputation: 1213
At last I found the answer to do this:
System Js config option also takes a meta info. In this meta info we can write to ignore modules of SystemJs from being bundled. So lets say I am loading all the angular2 modules from cdn, importing them in local modules and then building it with systemJs or JSPM, then I must write the following in config.js(or inside System.config's options object):
meta: {
'angular2/*': {
build: false
},
'rxjs/add/operator/map' : {
build : false
}
}
This should be put in config.js by angular2 developers to explicitly tell systemJs to avoid looking for angular2 modules and rxjs modules while bundling the local modules. This will provide you the opportunity to load angular2 and rxjs from cdn and consequently not include them in the map option of config.js.
Upvotes: 0
Reputation: 3321
If you want to build and use CDN at the same time (because you configured some packages to load from CDN with SystemJS), you can build everything but the CDN packages. For example:
jspm bundle app/main.js - angular2 - whatever + somethingelse main-bundle.js --inject
Otherwise, simplier, you can put the CDN links directly inside you index.html files and use SystemJS for local packages only.
Upvotes: 0