Man*_*uel 1 node.js npm node-modules angular-cli angular
在Angular 2中加载单个节点模块,在wiki中很好地描述了一个angular-cli bootstraped项目.只是好奇,如何在一个用angular-cli引导的项目中很好地加载一个更复杂的节点模块?
例如angular2-apollo依赖于几个子依赖,如apollo-client,graphql,lodash,......
我添加了节点模块 angular-cli-build.js
var Angular2App = require('angular-cli/lib/broccoli/angular2-app');
module.exports = function(defaults) {
return new Angular2App(defaults, {
vendorNpmFiles: [
'...',
'angular2-apollo/**'
]
});
};
Run Code Online (Sandbox Code Playgroud)
并注册了节点模块插件system-config.js与
const barrels: string[] = [
// ...
// Thirdparty barrels.
'rxjs',
'angular2-apollo',
// App specific barrels.
// ...
];
// ...
// Apply the CLI SystemJS configuration.
System.config({
map: {
'@angular': 'vendor/@angular',
'rxjs': 'vendor/rxjs',
'angular2-apollo':'vendor/angular2-apollo/build/src',
'main': 'main.js',
},
packages: cliSystemConfigPackages
});
Run Code Online (Sandbox Code Playgroud)
然而,这只是加载angular2-apollo.angular2-apollo的子依赖性没有得到加载.如何在angular-cli bootstraped项目中加载system.js的子依赖项?
所以,你在System.js面临一个非常恼人的问题,在Angular CLI上有一个关于它的公开问题:https://github.com/angular/angular-cli/issues/882
它基本上意味着你必须指定system.config.ts文件中的所有依赖项并将它们全部加载到angular-cli-build.js文件中....可怕我知道...
也许将来会发生:https://github.com/angular/angular-cli/issues/909
但是,在Angular CLI变得更好之前,这里有一个入门应用程序,包括Angular 2.0及其angular2-apollo所有依赖项(甚至使用模拟GraphQL服务器......) - https://github.com/Urigo/apollo-ship
您可以检查出system.config.ts和角CLI-build.js在那里看到如何包括依赖关系angular2-apollo,apollo-client,lodash(和所有想要的它依赖),redux和许多许多(太多... .)
| 归档时间: |
|
| 查看次数: |
2789 次 |
| 最近记录: |