HNeukermans / ng2-signalr

angular2 - asp.net signalr library
MIT License
173 stars 81 forks source link

Error with Angular Cli build using AOT option #49

Closed hakonamatata closed 7 years ago

hakonamatata commented 7 years ago

I haven't added much after generating a angular project using Angular Cli, except for a few components. One using SignalR.

This warning bellow makes it impossible to compile with --prod or --aot options in Angular Cli...

Warning: Can't resolve all parameters for SignalR in C:/front-end/beskr
.../node_modules/ng2-signalr/src/services/signalr.d.ts: ([object Object], [object Object], ?). This will become an error in Angular v5.x

package.json

{
  "name": "beskrivelse-frontend",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "^4.0.0",
    "@angular/compiler": "^4.0.0",
    "@angular/core": "^4.0.0",
    "@angular/forms": "^4.0.0",
    "@angular/http": "^4.0.0",
    "@angular/platform-browser": "^4.0.0",
    "@angular/platform-browser-dynamic": "^4.0.0",
    "@angular/router": "^4.0.0",
    "@biesbjerg/ngx-translate-po-http-loader": "^1.0.1",
    "@ngrx/core": "^1.2.0",
    "@ngrx/store": "^2.2.2",
    "@ngrx/store-devtools": "^3.2.4",
    "@ngx-translate/core": "^6.0.1",
    "angular2-jwt": "^0.2.3",
    "core-js": "^2.4.1",
    "devextreme": "^16.2.6",
    "devextreme-angular": "^16.2.6",
    "ng2-cookies": "^1.0.12",
    "ng2-signalr": "^2.0.3",
    "rxjs": "^5.1.0",
    "signalr": "^2.2.1",
    "ts-md5": "^1.2.0",
    "zone.js": "^0.8.4"
  },
  "devDependencies": {
    "@angular/cli": "1.0.0",
    "@angular/compiler-cli": "^4.0.0",
    "@types/jasmine": "2.5.38",
    "@types/node": "~6.0.60",
    "codelyzer": "~2.0.0",
    "jasmine-core": "~2.5.2",
    "jasmine-spec-reporter": "~3.2.0",
    "karma": "~1.4.1",
    "karma-chrome-launcher": "~2.0.0",
    "karma-cli": "~1.0.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "karma-coverage-istanbul-reporter": "^0.2.0",
    "protractor": "~5.1.0",
    "ts-node": "~2.0.0",
    "tslint": "~4.5.0",
    "typescript": "~2.2.0"
  }
}

app.module


// signalR setup
export function createConfig(): SignalRConfiguration {
  const signalRConfig = new SignalRConfiguration();

  signalRConfig.hubName = 'Ng2SignalRHub';
  signalRConfig.qs = {
    user: 'test user'
  };
  signalRConfig.url = 'http://ng2-signalr-backend.azurewebsites.net/';
  signalRConfig.logging = true;

  return signalRConfig;
}

(...)
  imports: [
    SignalRModule.forRoot(createConfig),
DaveMonag commented 7 years ago

https://angular.io/docs/ts/latest/api/core/index/OpaqueToken-class.html Looks like OpaqueToken is deprecated now, reckon that's the problem? From src/modules/signalr-module.ts

hakonamatata commented 7 years ago

https://angular.io/docs/ts/latest/api/core/index/OpaqueToken-class.html Looks like OpaqueToken is deprecated now, reckon that's the problem? From src/modules/signalr-module.ts

Thanks @DaveMonag, I tried to comment out SignalR. Still get the same error. :weary:

DaveMonag commented 7 years ago

If OpaqueToken is the problem (which is used in this SignalR module), then its up to @HNeukermans to make the change. Did you solve the problem another way?

HNeukermans commented 7 years ago

@DaveMonag, Yes, I took a peak... :-), but my question is... if I change OpaqueToken to InjectionToken, then how do I keep the angular 2.4.x users happy...

Going from ng2 to ng4, means I have to do breaking changes...

Any ideas... going from OpaqueToken to a string?

DaveMonag commented 7 years ago

If users are to stay on an old version, they should surely specify old versions of dependencies and not rely on open source projects staying outdated. Also, could you not increment the semver so that it indicates a breaking change and wont update past the current version without instruction? Also is this actually a breaking change? I was under the assumption 2 -> 4 was meant to be a non breaking update.

JakobSegerslatt commented 7 years ago

This doesn't seemed to have been addressed yet, right?

Using Angular 5, the compiler throws error that angular/core no longer exports OpaqueToken

WARNING in ./node_modules/ng2-signalr/src/modules/signalr-module.js 3:49-60 "export 'OpaqueToken' was not found in '@angular/core'

feitzi commented 6 years ago

Any updates to this topic? As @JakobSegerslatt mentioned, ng2-signalr and Angular5 produce a warning

JakobSegerslatt commented 6 years ago

@feitzi Have a look at #86 and #92 , @pbriones has created a PR that fixes it. :)