Skip to content

Commit

Permalink
Reduced bundle size of app by removing HttpClient-Plugin and loading …
Browse files Browse the repository at this point in the history
…it async
  • Loading branch information
gfoidl committed Jun 16, 2020
1 parent 1767f10 commit c4b0413
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 29 deletions.
2 changes: 1 addition & 1 deletion frontend/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<!--<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">-->
</head>
<body>
<app id="app"></app>
<app></app>

<noscript>JavaScript isn't supported or turned off by your browser. Please enable it, to use this app.</noscript>
</body>
Expand Down
8 changes: 3 additions & 5 deletions frontend/src/ts/app.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import Vue from "vue";
import App from "@/app.vue";
import HttpClientPlugin from "@svc/httpclient-plugin";
import Logger from "@svc/logger";
import Vue from "vue";
import App from "@/app.vue";
import Logger from "@svc/logger";
//-----------------------------------------------------------------------------
Vue.config.productionTip = false;
Vue.use(HttpClientPlugin);
Logger.init();
//-----------------------------------------------------------------------------
const app = new Vue({
Expand Down
8 changes: 0 additions & 8 deletions frontend/src/ts/services/httpclient-plugin.ts

This file was deleted.

7 changes: 4 additions & 3 deletions frontend/src/ts/services/logger.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Vue from "vue";
import { HttpClient } from "./httpclient";
import Vue from "vue";
//-----------------------------------------------------------------------------
interface ErrorData {
message: string;
Expand Down Expand Up @@ -57,9 +56,11 @@ export default class Logger {
}
}
//-------------------------------------------------------------------------
private static logUnhandledException(error: ErrorData): void {
private static async logUnhandledException(error: ErrorData): Promise<void> {
console.error("Unhandled error", error);

const HttpClient = (await import("./httpclient")).HttpClient;

HttpClient.Default.post<void>("error/client", error);
console.info("sent error info to server");
}
Expand Down
7 changes: 0 additions & 7 deletions frontend/src/ts/shims/vue-plugin-shims.d.ts

This file was deleted.

8 changes: 4 additions & 4 deletions frontend/src/ts/views/main/greeting-service.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { IHttpClient } from "@svc/httpclient";
import HelloResponse from "./hello-response";
import { IHttpClient, HttpClient } from "@svc/httpclient";
import HelloResponse from "./hello-response";
//-----------------------------------------------------------------------------
export default class GreetingService {
private readonly _httpClient: IHttpClient;
//-------------------------------------------------------------------------
constructor(httpClient: IHttpClient) {
this._httpClient = httpClient;
constructor(httpClient?: IHttpClient) {
this._httpClient = httpClient ?? HttpClient.Default;
}
//-------------------------------------------------------------------------
public async hello(name: string): Promise<string> {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/ts/views/main/main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
console.debug("mounted at", new Date());
// For Vue this won't work in the ctor, that's why it's here.
this.greetingService = new GreetingService(this.$http);
this.greetingService = new GreetingService();
}
//---------------------------------------------------------------------
public async hello(): Promise<void> {
Expand Down

0 comments on commit c4b0413

Please sign in to comment.