question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Probable issue with uglify, causing signalr-client to fail to build in production

See original GitHub issue

Refer to https://github.com/aspnet/SignalR/issues/729 https://github.com/aspnet/SignalR/issues/765

for the issue I raised with the signalr-client team.

I have created a sample repo at https://github.com/williamBurgeson/signalr-client_angular-cli

Quite simply, download the above repo and run ng build --prod, and you will get the error. Note the signalr-client is not hosted in the usual place in npm (I use yarn, but the principles are the same; it is hosted at https://dotnet.myget.org/f/aspnetcore-ci-dev/npm/).

Failing that, run the steps I described in the first comment from that thread: https://github.com/aspnet/SignalR/issues/729#issue-250646811

ERROR in vendor.a480795b35d0d09f117a.bundle.js from UglifyJs
Unexpected token: name (HubConnection) [vendor.a480795b35d0d09f117a.bundle.js:15675,6]

They have fixed the main problem, which was that when I included the current (at the time) version of signalr-client, it errored out when running ng build. Now that is fixed, but it still errors when running ng build --prod

If you see the last comments on that issue, they have implied the only way to fix this is to run ng eject (see https://github.com/aspnet/SignalR/issues/729#issuecomment-324569702) due to uglify not supporting ES6.

Is there anything which can be done from your end to mitigate this error, without having to ng eject? e.g. switch out dependencies or dependency versions etc. I’m not an expert on uglify by any means but would there be an option to use a newer version which does support ES6? (I assume the angular stack all still compiles down to ES5 to keep uglify happy if what they are saying is correct)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
Marcelh1983commented, Sep 13, 2017

For anyone that want to use the signalr-client npm package with angular-cli: I added the es5 jsfiles in .angular-cli.json under scripts.

  "scripts": [
    "../node_modules/@aspnet/signalr-client/dist/browser/signalr-clientES5.min.js",
    "../node_modules/@aspnet/signalr-client/dist/browser/signalr-msgpackprotocolES5.min.js"
  ],

In my signalR service I added two declarations:

this one for in development: import * as signalR from '@aspnet/signalr-client'; this one for the production build declare var signalR: any; Its not ideal but works. see: https://github.com/Marcelh1983/signalr-example

1reaction
sniffer327commented, Nov 2, 2017

Angular-cli has updated 1.5.0. It’s solved this problem.

Current version of @aspnet/signalr-client: ‘1.0.0-alpha2-final’ in my project. Now i’m using import { HubConnection } from ‘@aspnet/signalr-client’ without errors while production building.

Angular-cli releases link: https://github.com/angular/angular-cli/releases

Read more comments on GitHub >

github_iconTop Results From Across the Web

SignalR Troubleshooting | Microsoft Learn
This section describes possible causes for a method call between client and server to fail without a meaningful error message. In a SignalR...
Read more >
Can not find modules while building the project with signalr ...
import { HubConnection } from '@aspnet/signalr-client';. The build is going fine without uglify. But when I use uglify() it fails because of ...
Read more >
Error in non-existent folder #10853 - Asp.Net Zero Support
It hasn't been reviewed for security issues. Binding this server to an open connection can result in compromising your application or computer.
Read more >
How I Fixed: UglifyJs Unexpected token: name (DropIn)
I've been trying – in vain – to build the front end for CodeReviewVideos. The issue I have been hitting upon is as...
Read more >
Angular 2 | chsakell's Blog
The client side of the Scheduler app is build outside of Visual Studio (no .sln ... NET Core – Angular 2 – SignalR...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found