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
Post a Comment