Skip to content

Commit 771e0c0

Browse files
committed
fb
1 parent a6fc704 commit 771e0c0

File tree

4 files changed

+20
-15
lines changed

4 files changed

+20
-15
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
// This is an empty implementation of the NodeHttpClient that will be included in browser builds so the output file will be smaller
5+
6+
import { HttpClient, HttpResponse } from "./HttpClient";
7+
import { ILogger } from "./ILogger";
8+
9+
export class NodeHttpClient extends HttpClient {
10+
// @ts-ignore: Need ILogger to compile, but unused variables generate errors
11+
public constructor(logger: ILogger) {
12+
super();
13+
}
14+
15+
public send(): Promise<HttpResponse> {
16+
return Promise.reject(new Error("If using Node either provide an XmlHttpRequest polyfill or consume the cjs or esm script instead of the browser/signalr.js one."));
17+
}
18+
}

src/SignalR/clients/ts/signalr/src/NodeHttpClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export class NodeHttpClient extends HttpClient {
2525
public constructor(logger: ILogger) {
2626
super();
2727
if (typeof requestModule === "undefined") {
28-
throw new Error("error");
28+
throw new Error("The 'request' module could not be loaded.");
2929
}
3030

3131
this.logger = logger;

src/SignalR/clients/ts/signalr/src/empty.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/SignalR/clients/ts/webpack.config.base.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ module.exports = function (modulePath, browserBaseName, options) {
4141
resolve: {
4242
extensions: [".ts", ".js"],
4343
alias: {
44-
"./NodeHttpClient": path.resolve(__dirname, "signalr/src/empty.ts"),
44+
"./NodeHttpClient": path.resolve(__dirname, "signalr/src/EmptyNodeHttpClient.ts"),
4545
...options.alias,
4646
}
4747
},

0 commit comments

Comments
 (0)