angular - Angular2 RC4 build with tree shaking runtime error -


i tried build test app tree shaking according post. http://blog.mgechev.com/2016/06/26/tree-shaking-angular2-production-build-rollup-javascript/

the build scripts runs ok got runtime error when used bundle.js.

  zone.js@0.6.12?main=browser:461 unhandled promise rejection: observable$1.from not function ;    zone: angular ; task: promise.then ; value: typeerror: observable$1.from not function(…) 

observable$1.from came dist\bundle.es2015.js

  dist\bundle.es2015.js 48604                   return observable$1.from(this.checks)   dist\bundle.es2015.js 48624                   return observable$1.from(this.checks)   dist\bundle.es2015.js 48697                   return observable$1.from(canactivate)   dist\bundle.es2015.js 48714                   return observable$1.from(candeactivate) 

this function originated

  node_modules\@angular\router\esm\src\router.js    361         return observable.from(this.checks)   node_modules\@angular\router\esm\src\router.js    381         return observable.from(this.checks)   node_modules\@angular\router\esm\src\router.js    454         return observable.from(canactivate)   node_modules\@angular\router\esm\src\router.js    471         return observable.from(candeactivate) 

when use rollup generate dist\bundle.es2015.js

if build app without tree shaking via browserify-js function appears observable_1.from() , app works no error.

i thought may angular2 zone.js allergic observable$1 manually change observable$1 observable_1 in bundle.es2015.js , run

"es5": "tsc --target es5 --allowjs dist/bundle.es2015.js --out dist/bundle.js", 

then got this

  unhandled promise rejection: observable_1.from not function ;    zone: angular ; task: promise.then ; value: typeerror: observable_1.from not function(…) 

can tell me if due rollup bug or missed something?

here build scripts

"scripts": {   "clean": "rm -rf dist",   "typings": "typings install",   "serve": "http-server . -p 5557",   "postinstall": "npm run typings",   "build": "tsc -p tsconfig.json",   "rollup": "rollup -f iife -c -o dist/bundle.es2015.js",   "es5": "tsc --target es5 --allowjs dist/bundle.es2015.js --out dist/bundle.js",   "minify": "uglifyjs dist/bundle.js --screw-ie8 --compress --mangle --output dist/bundle.min.js",   "build_prod": "npm run clean && npm run build && npm run rollup && npm run es5 && npm run minify" } 

the rollup.config.js , tsconfig.json same in link above.


Comments