I'm using a service to make http get requests:
import { Headers, Http } from '@angular/http';
import { Observable } from 'rxjs';
import 'rxjs/add/operator/map';
.... classcode.....
getOffices(): Observable<Office[]> {
const url = `${this.apiurl}office`
console.log(url);
return this.http.get(url)
.map(response => response.json());
};
This all works when using SystemJS, which I'm using while I'm developing. However, when I use AoT compilation with rollup and uglify I keep getting the error:
bundle.min.js:7 EXCEPTION: Uncaught (in promise): TypeError: this.http.get(...).map is not a function
All I can find is people saying to add import 'rxjs/add/operator/map'
to the main.ts file or the app.module.ts file. I've added this to every related file as well as added import 'rxjs/Rx'
to all related file but nothing seems to work..
Has anybody been successful in using http request in combination with AoT compilation?
this is de tsconfig file I'm using for AoT:
{
"compilerOptions": {
"target": "es2015",
"module": "es2015",
"moduleResolution": "node",
"declaration": false,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"sourceMap": true,
"pretty": true,
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitUseStrict": false,
"noFallthroughCasesInSwitch": true,
"outDir": "./dist",
"rootDir": "./compiled"
},
"compileOnSave": false,
"files": [
"compiled/main-ngc.ts"
],
"filesGlob":[
"typings.d.ts",
"compiled/main-ngc.ts",
"compiled/main.ts"
],
"exclude": [
"node_modules"
]
}
and these are the build commands I'm using:
"build": "tsc -p tsconfig-compiled.json && gulp libs",
"rollup": "rollup -f iife -c -o dist/bundle.es2015.js",
"es5": "tsc --target es5 --allowJs dist/bundle.es2015.js --out dist/bundle.js",
"build_prod": "npm run ngc && npm run build && npm run rollup && npm run es5 && npm run minify && gulp clean:build && gulp build_prod",
"minify": "uglifyjs dist/bundle.js --screw-ie8 --compress --mangle --output dist/bundle.min.js",
any help would be welcome!