xmaestro / angular2-recaptcha

Angular 2 : Typescript component for Google reCaptcha
ISC License
79 stars 30 forks source link

Error loading ../node_modules/rxjs.js as "rxjs" #31

Closed trevordaniels closed 8 years ago

trevordaniels commented 8 years ago

I'm getting the following error when using in the angular2-seed-advanced project.

Error loading http://localhost:5555/node_modules/rxjs.js as "rxjs" from http://localhost:5555/node_modules/angular2-recaptcha/lib/captcha.service.js

Changing this line in captcha.service var rxjs_1 = require("rxjs"); to var rxjs_1 = require("rxjs/Rx"); seems to fix it.

achimha commented 8 years ago

The Javascript file is generated from Typescript, the import is

import { Observable, BehaviorSubject } from "rxjs";

I don't know anything about angular2-seed-advanced and how correct it is with the current ng2 but I see that it uses SystemJS which is more or less replaced by webpack2 in the final angular release. This seems to be the config: https://github.com/NathanWalker/angular2-seed-advanced/blob/master/tools/config/seed.config.ts Here is how it maps rxjs:

...
 'rxjs/*': 'node_modules/rxjs/*',
...

This mapping only applies to submodules of rxjs, not to imports of rxjs itself which explains the error. Looking at how this projects does imports from rxjs itself, I see that it always references the submodule. So this can be fixed by changing our code to read

import { Observable, BehaviorSubject } from "rxjs/Rx";

I have created a PR to fix this issue: https://github.com/xmaestro/angular2-recaptcha/pull/32

xmaestro commented 8 years ago

Please re-open if the issue still pesists.

trevordaniels commented 8 years ago

thanks for resolving this so quickly