Skip to content
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

Update so that Angular 9+ Ivy engine can better tree shake and remove warnings #277

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
14 changes: 14 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
image: $DOCKER_REGISTRY/angular:464c8f81b76c36a3d76334ffe3dc5a43881872a6

stages:
- test

test and lint:
stage: test
tags:
- elearnio
script:
- npm install
- cd projects/angular2-jsonapi && npm install && cd ../..
- npm test -- --no-watch --no-progress --code-coverage --browsers=ChromeHeadlessCI
- npm run lint
7,772 changes: 4,148 additions & 3,624 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
"start": "ng serve",
"test": "ng test"
},
"dependencies": {},
"dependencies": {
"lodash-es": "^4.17.15"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.803.4",
"@angular-devkit/build-ng-packagr": "~0.803.4",
Expand Down
3 changes: 2 additions & 1 deletion projects/angular2-jsonapi/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = function (config) {
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('karma-verbose-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
Expand All @@ -20,7 +21,7 @@ module.exports = function (config) {
reports: ['html', 'lcovonly', 'text-summary'],
fixWebpackSourcePaths: true
},
reporters: ['progress', 'kjhtml'],
reporters: ['verbose', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
Expand Down
5 changes: 1 addition & 4 deletions projects/angular2-jsonapi/ng-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@
"entryFile": "src/public-api.ts",
"umdModuleIds": {
"date-fns": "date-fns",
"lodash": "lodash",
"lodash-es": "lodash-es",
"qs": "qs"
"lodash-es": "lodash-es"
}
},
"whitelistedNonPeerDependencies": [
"date-fns",
"lodash-es",
"qs",
"tslib"
]
}
34 changes: 22 additions & 12 deletions projects/angular2-jsonapi/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions projects/angular2-jsonapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@
"dependencies": {
"date-fns": "^2.2.1",
"lodash-es": "^4.17.15",
"qs": "^6.8.0",
"tslib": "^1.10.0"
},
"peerDependencies": {
"@angular/common": "^8.2.5",
"@angular/core": "^8.2.5",
"@angular/common": "^10.1.1",
"@angular/core": "^10.1.1",
"reflect-metadata": "^0.1.13",
"rxjs": "^6.5.3"
"rxjs": "^6.6.3"
},
"devDependencies": {
"karma-verbose-reporter": "0.0.6"
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AttributeMetadata } from '../constants/symbols';
import { AttributeDecoratorOptions } from '../interfaces/attribute-decorator-options.interface';
import { DateConverter } from '../converters/date/date.converter';
import * as _ from 'lodash';
import * as _ from 'lodash-es';

export function Attribute(options: AttributeDecoratorOptions = {}): PropertyDecorator {
return (target: any, propertyName: string) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AttributeMetadata } from '../constants/symbols';
import { AttributeDecoratorOptions } from '../interfaces/attribute-decorator-options.interface';
import * as _ from 'lodash';
import * as _ from 'lodash-es';

export function NestedAttribute(options: AttributeDecoratorOptions = {}): PropertyDecorator {
return (target: any, propertyName: string) => {
Expand Down
2 changes: 1 addition & 1 deletion projects/angular2-jsonapi/src/models/json-api.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { find, includes } from 'lodash-es';
import { Observable } from 'rxjs';
import { JsonApiDatastore, ModelType } from '../services/json-api-datastore.service';
import { ModelConfig } from '../interfaces/model-config.interface';
import * as _ from 'lodash';
import * as _ from 'lodash-es';
import { AttributeMetadata } from '../constants/symbols';
import { HttpHeaders } from '@angular/common/http';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import { Observable, of, throwError } from 'rxjs';
import { JsonApiModel } from '../models/json-api.model';
import { ErrorResponse } from '../models/error-response.model';
import { JsonApiQueryData } from '../models/json-api-query-data';
import * as qs from 'qs';
import { DatastoreConfig } from '../interfaces/datastore-config.interface';
import { ModelConfig } from '../interfaces/model-config.interface';
import { AttributeMetadata } from '../constants/symbols';
import 'reflect-metadata';
import stringify from '../utilities/stringify';

export type ModelType<T extends JsonApiModel> = new(datastore: JsonApiDatastore, data: any) => T;

Expand Down Expand Up @@ -498,6 +498,6 @@ export class JsonApiDatastore {
}

private _toQueryString(params: any): string {
return qs.stringify(params, {arrayFormat: 'brackets'});
return stringify(params, {arrayFormat: 'brackets'});
}
}
24 changes: 24 additions & 0 deletions projects/angular2-jsonapi/src/utilities/formats.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const replace = String.prototype.replace;
const percentTwenties = /%20/g;

import util from './utils';

const Format = {
RFC1738: 'RFC1738',
RFC3986: 'RFC3986'
};

export default util.assign(
{
default: Format.RFC3986,
formatters: {
RFC1738(value) {
return replace.call(value, percentTwenties, '+');
},
RFC3986(value) {
return String(value);
}
}
},
Format
);
Loading