From 011b515c6e588ceb83678afd6b236623929f3893 Mon Sep 17 00:00:00 2001 From: hpawe01 Date: Thu, 8 Aug 2019 12:16:43 +0200 Subject: [PATCH 1/2] Update README.md Add information about breaking changes in Angular 8 and Angular CLI 8.1 --- README.MD | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.MD b/README.MD index 860f61eb..e6eae67d 100644 --- a/README.MD +++ b/README.MD @@ -82,6 +82,26 @@ 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, + } +} +``` + +### Polyfills (for Angular 8+ AOT) + +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'; +``` + ## Usage ### Configuration From 65fb2dfb107ae1d7ebd03e410be10127714a306b Mon Sep 17 00:00:00 2001 From: hpawe01 Date: Thu, 8 Aug 2019 15:55:24 +0200 Subject: [PATCH 2/2] Add information about compile target --- README.MD | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.MD b/README.MD index e6eae67d..f3e2bb8d 100644 --- a/README.MD +++ b/README.MD @@ -94,14 +94,17 @@ Beginning from Angular CLI 8.1 the `tsconfig.json` does not sets the `emitDecora } ``` -### Polyfills (for Angular 8+ AOT) +### 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