Skip to content

Commit d9135e5

Browse files
committed
correct readme
1 parent 4e96f91 commit d9135e5

File tree

1 file changed

+28
-14
lines changed

1 file changed

+28
-14
lines changed

projects/angular2-jsonapi/README.md

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Fork of the [angular2-jsonapi](https://github.com/ghidoz/angular2-jsonapi) repo.
77

88
A lightweight Angular 2 adapter for [JSON API](http://jsonapi.org/)
99

10+
11+
1012
## Table of Contents
1113
- [Introduction](#Introduction)
1214
- [Installation](#installation)
@@ -63,23 +65,35 @@ To install this library, run:
6365
$ npm install @michalkotas/angular2-jsonapi --save
6466
```
6567

66-
Add the `JsonApiModule` to your app module imports:
68+
### Migrate to version 18+
69+
70+
Version 18 does not expose the module because it has been removed. Therefore, you need to remove all imports of the `JsonApiModule`.
71+
72+
Additionally, ensure that `HttpClientModule` is provided in your application, as it was previously imported and re-exported by `JsonApiModule`.
73+
74+
### Angular CLI configuration (for CLI 8.1+)
75+
76+
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`:
77+
78+
```json
79+
{
80+
"compilerOptions": {
81+
"emitDecoratorMetadata": true,
82+
}
83+
}
84+
```
85+
86+
### Notice for `es2015` compilation
87+
88+
Beginning with Angular 8 the default compile target will be `es2015` (in `tsconfig.json`).
89+
Make sure to add this line in your `src/polyfills.ts` as we need it to read metadata from the models:
90+
6791
```typescript
68-
import { JsonApiModule } from '@michalkotas/angular2-jsonapi';
69-
70-
@NgModule({
71-
imports: [
72-
BrowserModule,
73-
JsonApiModule
74-
],
75-
declarations: [
76-
AppComponent
77-
],
78-
bootstrap: [AppComponent]
79-
})
80-
export class AppModule { }
92+
import 'core-js/proposals/reflect-metadata';
8193
```
8294

95+
**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).
96+
8397
## Usage
8498

8599
### Configuration

0 commit comments

Comments
 (0)