diff --git a/README.MD b/README.MD index 860f61eb..f3e2bb8d 100644 --- a/README.MD +++ b/README.MD @@ -82,6 +82,29 @@ import { JsonApiModule } from 'angular2-jsonapi'; export class AppModule { } ``` +### Angular CLI configuration (for CLI 8.1+) + +Beginning from Angular CLI 8.1 the `tsconfig.json` does not sets the `emitDecoratorMetadata` option (see https://blog.ninja-squad.com/2019/07/03/angular-cli-8.1/#typescript-configuration-changes). But we need it to read the metadata from the models. So make sure to update your `tsconfig.json`: + +```json +{ + "compilerOptions": { + "emitDecoratorMetadata": true, + } +} +``` + +### Notice for `es2015` compilation + +Beginning with Angular 8 the default compile target will be `es2015` (in `tsconfig.json`). +Make sure to add this line in your `src/polyfills.ts` as we need it to read metadata from the models: + +```typescript +import 'core-js/proposals/reflect-metadata'; +``` + +**Warning**: If you have circular dependencies in your model definitions (see https://github.com/ghidoz/angular2-jsonapi/issues/236#issuecomment-519473153 for example), you need to change the compile target to `es5` as this lead to runtime errors `ReferenceError: Cannot access 'x' before initialization` (see https://github.com/angular/angular/issues/30106#issuecomment-497699838). + ## Usage ### Configuration