Skip to content

Rxjs imports don't work correctly #459

Description

@chapati23

I'm migrating my app over from a JSPM setup and running into issues with Rxjs Imports.
Created a new app with ng new test-app so no crazy settings or something.

It might be that it's just a misunderstanding on my part on how importing 3rd-party-packages works in angular-cli vs. jspm (where i can just jspm install abc and then import 'abc')

Error Msg
When bootstrapping the app, I get:

angular2.dev.js:23941 TypeError: rxjs_1.BehaviorSubject is not a constructor
at new CategoryService (category.service.ts:12)
at angular2.dev.js:1418
at Injector._instantiate (angular2.dev.js:11770)
at Injector._instantiateProvider (angular2.dev.js:11709)
at Injector._new (angular2.dev.js:11699)
at InjectorDynamicStrategy.getObjByKeyId (angular2.dev.js:11577)
at Injector._getByKeyDefault (angular2.dev.js:11900)
at Injector._getByKey (angular2.dev.js:11854)
at Injector._getByDependency (angular2.dev.js:11842)
at Injector._instantiate (angular2.dev.js:11738)

Repro steps
In a service I do (shortened for clarity):

import{BehaviorSubject,Subject}from'rxjs'
export classMyService{publiccategories$: Subject<Array<Category>>constructor(privatehttp: Http){this.categories$=newBehaviorSubject([])}}

index.html

<body><app>Loading...</app><scriptsrc="vendor/es6-shim/es6-shim.js"></script><scriptsrc="vendor/systemjs/dist/system-polyfills.js"></script><scriptsrc="vendor/angular2/bundles/angular2-polyfills.js"></script><scriptsrc="vendor/systemjs/dist/system.src.js"></script><scriptsrc="vendor/angular2/bundles/angular2.dev.js"></script><scriptsrc="vendor/angular2/bundles/http.dev.js"></script><scriptsrc="vendor/angular2/bundles/router.dev.js"></script><scriptsrc="vendor/papaparse/papaparse.js"></script><scriptsrc="vendor/fuzzy/lib/fuzzy.js"></script><scriptsrc="vendor/dropzone/dist/dropzone.js"></script><script>System.config({map: {'@ngrx/store': 'vendor/@ngrx/store','rxjs': 'vendor/rxjs'},packages: {app: {format: 'register',defaultExtension: 'js'},'@ngrx/store': {main: './dist/index.js'},'rxjs': {main: './bundles/Rx.js',map: {'./BehaviorSubject': './subject/BehaviorSubject.js'}}}});System.import('app.js').then(null,console.error.bind(console));</script></body>
  • also tried explicitly including Rx.js in a <script>-tag like in the default project => same result
  • also tried without 'rxjs': { map: … } => same result

angular-cli-build.js

/* global require, module */varAngular2App=require('angular-cli/lib/broccoli/angular2-app');module.exports=function(defaults){varapp=newAngular2App(defaults,{vendorNpmFiles: ['@ngrx/store/dist/*.js','rxjs/**/*.js','papaparse/papaparse.js','fuzzy/lib/fuzzy.js','dropzone/dist/dropzone.js']});returnapp.toTree();};

Versions
OSX 10.11.4
angular-cli: 0.0.31
node: 5.10.1
os: darwin x64

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions