i have a ngModule which uses ngx-socket-io, i removed the unnecessary imports and injections :) as you can see i have commented some code which works like charm only in development build of application, as soon as i build the app using --prod those variables wont work anymore, if logged to the console the value is the same as static declaration yet SocketIoModule.forRoot(socketConfig) wont see them if build using --prod flag
import { SocketIoModule, SocketIoConfig } from "ngx-socket-io";
const socketConfig = {
url: 'http://localhost:3000',
options: {
query: {
userId: "f9ae03de-f043-4704-882e-d269ee514805"
}
}
};
// const userId = (<any>window).MaxDuel.instance.userId;
// const socket = (<any>window).MaxDuel.instance.socket;
// const socketConfig = {url: socket, options: {query: {userId}}};
// const socketConfig2 = JSON.parse(JSON.stringify(socketConfig));
console.log(socketConfig);
@NgModule({
declarations: [],
imports: [
SocketIoModule.forRoot(socketConfig)
],
entryComponents: [],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule {}
but after commenting the variables and introducing the same copy but in static declaration, application starts working again! as you can see i even serialized and deserialized to simulate a static declaration but again nothing!
the main problem is i need the userId on connection and that variable can not be static