将rxjs添加到Angular2 Quick Start和System.js包中?

时间:2016-08-07 17:25:41

标签: angular rxjs systemjs

我正在尝试扩展angular2快速启动框架(https://angular.io/guide/quickstart)以包含rxjs,并且还要让System.js从包中加载rxjs代码,而不是加载100个单独的.js文件。

System.js config.map:

{
  "@app": "app/@app",
  "@angular": "node_modules/@angular",
  "angular2-in-memory-web-api": "node_modules/angular2-in-memory-web-api",
  "rxjs": "node_modules/rxjs"
}

System.js config.packages:

{
  "@app": {
    "defaultExtension": "js"
  },
  "rxjs": {
    "main": "/bundles/Rx.umd.js",
    "defaultExtension": "js"
  },
  "angular2-in-memory-web-api": {
    "main": "index.js",
    "defaultExtension": "js"
  },
  "@angular/common": {
    "main": "/bundles/common.umd.min.js",
    "defaultExtension": "js"
  },
  "@angular/compiler": {
    "main": "/bundles/compiler.umd.min.js",
    "defaultExtension": "js"
  },
  "@angular/core": {
    "main": "/bundles/core.umd.min.js",
    "defaultExtension": "js"
  },
  "@angular/forms": {
    "main": "/bundles/forms.umd.min.js",
    "defaultExtension": "js"
  },
  "@angular/http": {
    "main": "/bundles/http.umd.min.js",
    "defaultExtension": "js"
  },
  "@angular/platform-browser": {
    "main": "/bundles/platform-browser.umd.min.js",
    "defaultExtension": "js"
  },
  "@angular/platform-browser-dynamic": {
    "main": "/bundles/platform-browser-dynamic.umd.min.js",
    "defaultExtension": "js"
  },
  "@angular/router": {
    "main": "/bundles/router.umd.min.js",
    "defaultExtension": "js"
  },
  "@angular/router-deprecated": {
    "main": "/bundles/router-deprecated.umd.min.js",
    "defaultExtension": "js"
  },
  "@angular/upgrade": {
    "main": "/bundles/upgrade.umd.min.js",
    "defaultExtension": "js"
  }
}

示例导入语句形式.ts文件:

import {Observable} from 'rxjs/Observable';
import {AsyncSubject} from 'rxjs/AsyncSubject';

我不明白为什么这仍然是加载所有单独的rxjs文件而不是识别包并加载它。它按预期加载所有@ angular / *包。

1 个答案:

答案 0 :(得分:0)

试试这个

 var packages = {
    'rxjs':{ defaultExtension: 'js' }
  };

tutorial

中没有提到主文件

Try this answer also