I tried updating today to the latest version of ng2-translate but my app fails when ng2-translate tries to load /rxjs/add/observable/of. This module was properly added only in rxjs 5.0.0-beta3.
You can compare the main Rx files:
The issue was introduced in https://github.com/ocombe/ng2-translate/commit/4b78732e. I'm using rxjs 5.0.0-beta.2 as angular2.0.0-beta13 uses this exact same version.
Thanks, someone reported a problem yesterday but he was using RxJS beta 4 and it worked after he downgraded to beta 2, that's weird that you have this problem on beta 2, I'll check asap.
I've had similar trouble, I think the package needs to reference ^5.0.0-beta.2 or ~5.0.0? Otherwise it has a hard dependency on the older beta version.
I have the same issue. Are there any temporary hotfixes?
Hi, we've encountered the same problem. In my case my app still boots and the translation are done, but I get an error on runtime: Uncaught ReferenceError: require is not defined.
As requested by others, I would also like to know if there is a planned fix until angular upgrade RxJS version? Even though it is functionnal, an error is a blocker for prod. Thank you! And thanks for this great library.
Alright, for now here is a temporary fix I made to make it work (since it never was called):
in index.html:
System.register('rxjs/add/observable/of', [], function(dummy) { return { setters: [], execute: function() {dummy('default', null); }}});
It should simply be removed from ng2-translate.js though, as it is not used (we use the static Observable.of)
If I got something wrong feel free to point it out. I'm a backend programmer and a bit new to angular.
edit for readability
Observable.of is added to Observable by calling import 'rxjs/add/observable/of';.
I just released a new version that removed most peer dependencies, included the dependency to RxJS. It's still a dependency but since I use the same as Angular 2, I don't need to specify it (I think).
Let me know if it fixes some of your problems ?
As said it the first comment, observable.of is not imported in 5.0.0-beta.2
I tried removing my ugly patch and fails again on the same error.
Note that I use Observable.of in my app and it works fine, even with me registering the dummy, so the import must not be the way it is used in beta2.
In beta2, in Observable.ts, there's
static of: typeof ArrayObservable.of;
Well I don't know what to tell you, but RxJS 5.0.0-beta.2 has rxjs/add/observable/of on npm, just check on npmcdn: https://npmcdn.com/[email protected]/add/observable/of.js
And I reinstalled it locally after doing npm cache clean just to be sure.
But they seem to have forgotten to include it in the root file: https://npmcdn.com/[email protected]
It has the functionnality, but is not used. The Observable 'class' already have a static method of. It was changed in beta3. The only thing it means is that you simply don't need to import it, or in your case, require it.
And a quick search in the minimed rxjs beta2 file shows that it is not there. Perhaps they fixed it, without fixing the minified file. I'll do some tests today.
Okay, then can you make a PR to fix it? if it passes the tests I'll merge it :)
By the way, I think that just adding this line should make it work for systemjs: https://github.com/ocombe/ng2-play/blob/ng2-translate/index.html#L27
I did, but I'm not using /node_modules/rxjs/bundles/Rx.js. I'm using /node_modules/rxjs/bundles/Rx.min.js
Ok, it makes sense then. That's why I like webpack much better, it bundles just what it needs :-)
I created a pull request but closed it. I did test it on my own, and did automated test on my project, but running npm test on the fork of ng2-translate resulted in error TS6053: File 'typings/main.d.ts' not found.
Not sure what I'm missing, and the checks do not pass...
I do not understand why it fails, but I'll keep the 'ugly patch' on my side for the moment. Will revisit this problem once I have some free time left, because we are short some people here and short on time for next delivery.
I have the same issue.
For the moment, the work around of @KevensPronovost works :
System.register('rxjs/add/observable/of', [], function(dummy) { return { setters: [], execute: function() {dummy('default', null); }}});
i added patch: System.register('rxjs/add/observable/of', [], function(dummy) { return { setters: [], execute: function() {dummy('default', null); }}}); in index.html
It work . But when i change language two time i get error : EXCEPTION: TypeError: Observable_1.Observable.of is not a function
Anyone help me to fix this issue, please ?
It seems my patch works only because we are not using the part of the code that makes uses of rxjs/add/observable/of. The problem is it is not in the rxjs minified version, so the require fails without the patch. Hopefully, angular will upgrade rxjs version soon enough, so that we can move on to the corrected version too.
Angular beta 17 now uses RxJS beta 6 ! Does this fixes your problems ?
It should, we'll upgrade today or next monday and tell you the verdict
The issues seems to be solved. Patch removed and everything works perfectly. Still need to port the rest of our app to angular, so not in prod yet, but I'd say the issue is fixed.
I confirm the issue is solved. I just tested. You can close this issue.
Cool thanks!
in my case I was importing JUST Observable
import { Observable } from 'rxjs/Observable';
so I needed to add "of"
import 'rxjs/add/observable/of';
Most helpful comment
I have the same issue. Are there any temporary hotfixes?