如何配置 SystemJS 以自动加载包依赖项?
How to configure SystemJS to autoload package dependency?
例如 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 成功加载 rest.js,但 rest.js 具有依赖性(affirm.js、bluebird 等)。我有错误:
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)
如何配置 SystemJS 以从 node_modules 目录自动加载包依赖项? (node_modules/request/index.js, node_modules/bluebird/zalgo.js, 等)
解决方案:使用 JSPM(jspm 是 SystemJS 通用模块加载器的包管理器)。
例如 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 成功加载 rest.js,但 rest.js 具有依赖性(affirm.js、bluebird 等)。我有错误:
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)
如何配置 SystemJS 以从 node_modules 目录自动加载包依赖项? (node_modules/request/index.js, node_modules/bluebird/zalgo.js, 等)
解决方案:使用 JSPM(jspm 是 SystemJS 通用模块加载器的包管理器)。