How can I specify library dependencies using SystemJS?

Using SystemJS , how can I indicate that one library depends on another? For example, the Bootstrap JavaScript library is dependent on jQuery . Based on the SytemJS docs , I assumed that I would indicate this dependency using the System.config.meta property:

 System.config({ baseUrl: './scripts', defaultJSExtensions: true, map: { jquery: './lib/jquery-2.2.0.min.js', bootstrap: './lib/bootstrap.min.js' }, meta: { bootstrap: { deps: ['jquery'] } } }); System.import('./scripts/app.js'); 

But this does not seem to have any effect. When I launch my application, the Bootstrap library throws a Bootstrap JavaScript requires jQuery error - this means that Bootstrap loads before jQuery.

How can I guarantee that jQuery always loads before loading?

+6
source share
1 answer

After blindly changing things, I came across a configuration that seems to work. Here is my configuration:

 System.config({ defaultJSExtensions: true, paths: { jquery: './scripts/lib/jquery-2.2.0.min.js', bootstrap: './scripts/lib/bootstrap.min.js' }, meta: { bootstrap: { deps: ['jquery'] } } }); System.import('./scripts/app.js'); 

I think the key has changed from map to paths .

EDIT

Side note: learning a bit more about SystemJS, I found it much easier for jspm to do the hard work of managing my SystemJS configuration.

+4
source

All Articles