Skip to content

SignalR NodeHttpClient module not found - Angular SSR #7823

Closed
@stephenlautier

Description

@stephenlautier

Describe the bug

This is the same exact as: aspnet/SignalR#3254

When using SignalR with Angular in SSR it throws an error (using Angular7, template with CLI - based on .NET Angular official Template to be exact)

NodeInvocationException: Prerendering failed because of error: Error: Cannot find module './NodeHttpClient'

Additional context

  • @aspnet/signalr: v1.1.2 (latest)

After diagnosing some, basically NodeHttpClient, which is imported only on Node, is being imported relatively e.g.

// bundled code
var nodeHttpClientModule;
if (typeof XMLHttpRequest === "undefined") {
    // In order to ignore the dynamic require in webpack builds we need to do this magic
    // @ts-ignore: TS doesn't know about these names
    var requireFunc =  true ? require : undefined;
    nodeHttpClientModule = requireFunc("./NodeHttpClient");
}

SSR App is bundled (dist/main.js), hence this file does not exists relative to ./dist/main.js file at runtime

So i guess it should be either:

  • Somehow webpack bundles it if its node only
  • Imported also for browser, but will eventually gets treeshaked

Metadata

Metadata

Assignees

Labels

area-signalrIncludes: SignalR clients and servers

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions