Skip to content

Commit

Permalink
perf: optimize package size
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmanuelRoux committed Sep 2, 2023
1 parent 609af37 commit 207a1fc
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
Empty file modified .husky/commit-msg 100644 → 100755
Empty file.
Empty file modified .husky/pre-commit 100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -47,7 +47,7 @@
"@angular/platform-browser-dynamic": "^15.0.1",
"@angular/router": "^15.0.1",
"rxjs": "~7.5.5",
"tslib": "^2.3.1",
"tslib": "^2.4.1",
"zone.js": "~0.11.5"
},
"devDependencies": {
Expand Down
7 changes: 3 additions & 4 deletions projects/ngx-matomo-client/package.json
Expand Up @@ -13,9 +13,7 @@
"@angular/common": "^15.0.0 || ^16.0.0",
"@angular/core": "^15.0.0 || ^16.0.0"
},
"dependencies": {
"tslib": "^2.0.0"
},
"dependencies": {},
"repository": {
"type": "git",
"url": "https://github.com/EmmanuelRoux/ngx-matomo.git",
Expand All @@ -33,5 +31,6 @@
"schematics": "./schematics/collection.json",
"ng-add": {
"save": true
}
},
"sideEffects": false
}
15 changes: 9 additions & 6 deletions projects/ngx-matomo-client/router/ngx-matomo-router.module.ts
Expand Up @@ -21,15 +21,18 @@ export class NgxMatomoRouterModule {
}
}

static forRoot({
interceptors,
...config
}: MatomoRouterConfigurationWithInterceptors = {}): ModuleWithProviders<NgxMatomoRouterModule> {
static forRoot(
configWithInterceptors: MatomoRouterConfigurationWithInterceptors = {}
): ModuleWithProviders<NgxMatomoRouterModule> {
// Note: not using "rest" syntax here, in order to avoid any dependency on tslib (and reduce package size)
// The only drawback of this is that MATOMO_ROUTER_CONFIGURATION will actually
// contain a reference to provided interceptors
return {
ngModule: NgxMatomoRouterModule,

providers: [
{ provide: MATOMO_ROUTER_CONFIGURATION, useValue: config },
provideInterceptors(interceptors),
{ provide: MATOMO_ROUTER_CONFIGURATION, useValue: configWithInterceptors },
provideInterceptors(configWithInterceptors.interceptors),
],
};
}
Expand Down
6 changes: 2 additions & 4 deletions projects/ngx-matomo-client/router/page-url-provider.ts
@@ -1,5 +1,5 @@
import { APP_BASE_HREF, PlatformLocation } from '@angular/common';
import { Inject, inject, InjectionToken, Optional } from '@angular/core';
import { inject, InjectionToken } from '@angular/core';
import { NavigationEnd } from '@angular/router';
import { Observable, of } from 'rxjs';
import { INTERNAL_ROUTER_CONFIGURATION, InternalRouterConfiguration } from './configuration';
Expand All @@ -26,10 +26,8 @@ function trimTrailingSlash(str: string): string {

export class DefaultPageUrlProvider implements PageUrlProvider {
constructor(
@Optional()
@Inject(INTERNAL_ROUTER_CONFIGURATION)
private readonly config: InternalRouterConfiguration,
@Optional() @Inject(APP_BASE_HREF) private readonly baseHref: string | null,
private readonly baseHref: string | null,
private readonly platformLocation: PlatformLocation
) {}

Expand Down

0 comments on commit 207a1fc

Please sign in to comment.