javascript - Importing RxJS through System.js in typescript -


i'm trying import rxjs 5 typescript app using system.js module type. it's there, when

import * rx "path/to/rxjs/rx"; 

the rx object doesn't contain module contents of rx directly, has property named 'default' contain module contents:

rx.observable.of(1,2,3) ... //does not work, rx.observable undefined rx.default.observable.of(1,2,3) ... //does work, , contains module contents expected 

my tsconfig looks this:

{     "compileroptions": {         "module": "system",         "allowsyntheticdefaultimports" : true,         "allowjs" : true,         "noimplicitany": true,         "removecomments": false,         "preserveconstenums": true,         "baseurl" : "./",         "sourcemap": true,         "target": "es6",         "lib" : ["dom","es6","dom.iterable","scripthost","es2015","es2016"],         "strict": true,         "forceconsistentcasinginfilenames": true,         "outfile" : "./js/out.js"     },     "files": [       "main.ts"     ] } 

and invocation of system.js looks this:

system.config({         "baseurl" : "/",         packages: {             '../node_modules/rxjs': {               defaultextension: 'js',             }           }       });       system.import("./js/out.js")         .then(() => {           console.log("js loaded");           system.import("main");         })         .catch((err)=> {           console.error("error: " + err);         }); 

i suspect configuration variable need pass system.js, documentation on cross-module system imports isn't helpful newbie. i've tried setting package type of ../node_modules/rxjs 'cjs' , has same result.

as aside: 5 different module systems (at least!) javascript sorta crazy. , thought java jigsaw brouhaha bad.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -