I'm having a hard time figuring out how exactly this import statement works (in an Angular application written in Typescript):
import 'rxjs/add/operator/toPromise';
I get that rxjs
is mapped to the respective node_modules
subfolder in the SystemJS config file, but then I'm stuck. I see that there is an index.js file but I don't see whether or how this helps to resolve the add/operator/...
part.
Similarly, I don't understand this one:
import {Observable} from 'rxjs/Observable';
Again, there is no file Observable.*
file in this place. I guess that it somehow works via the index.js file but I'd really like to get a more thorough understanding because I read that it is easy to import all of RxJS by accident which increases page load times.
I had a closer look at the Typescript module resolution documentation but I have the feeling that this is not sufficient to explain it.
Update: After reading the accepted answer below I figured out I had been looking at the node_modules/rx
directory instead of node_modules/rxjs
so the import statements match perfectly with the directory structure.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…