Skip to content

Add information about breaking changes in Angular 8 and Angular CLI 8.1 #237

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 24, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down