Search code examples
systemjs

How to configure SystemJS to autoload package dependency?


For example config for rest.js:

var config = {
  map: {
    'app': 'app',
    'rest': 'node_modules/rest.js'
  },
  packages: {
    'app': { main: 'main.js',  defaultExtension: 'js' },
    'rest': { main: 'index.js', defaultExtension: 'js' }
  }
}

SystemJS successful load rest.js, but rest.js have dependency (affirm.js, bluebird, etc). And I have error:

GET http://localhost/request 404 (Not Found)
GET http://localhost/bluebird 404 (Not Found)
GET http://localhost/affirm.js 404 (Not Found)
GET http://localhost/extend 404 (Not Found)

How to configure SystemJS to autoload package dependency from node_modules directory? (node_modules/request/index.js, node_modules/bluebird/zalgo.js, etc)


Solution

  • Solution: use JSPM (jspm is a package manager for the SystemJS universal module loader).