Angular 4 / SignalR angular-cli production build fails
When trying to incoperate a SignalR hub in to a angular 4 project i encounter a issue when creating a production build with angular-cli.
Repo to reproduce issue: https://github.com/maartenmensink/signal-core-test-prod-build
Steps:
- npm install
- ng build --prod --sm --verbose
Should give error:
ERROR in vendor.b0045e4649a2b76539df.bundle.js from UglifyJs
Unexpected token: name (Subject) [C:/projects/test/signal-core-test-prod-build/node_modules/@aspnet/signalr-client/dist/src/Observable.js:3,0][vendor.b0045e4649a2b76539df.bundle.js:17107,6]
angular-cli uses UglifyJs and the latter doesn't support ES6 which this repository requires. There are already two issues for that in this repository.
I have not tried it yet but here is a possible workaround: https://github.com/aspnet/SignalR/issues/729#issuecomment-324569702 (as well as the entire thread about SignalR client and angular-cli).
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
@SergBozhko - thanks for the update!