I am trying to implement the import barrels structure that is described in this link (you may have to scroll down a bit) :
https://angular.io/docs/ts/latest/guide/style-guide.html#!#application-structure
The problem I am facing is that the index.ts files that I am creating and referencing like
import {...} from './shared/services';
are not found at runtime and are throwing 404s. If I reference the modules like
import {...} from './shared/services/index';
It works fine. The problem only appears at runtime, typescript does not complain and compiles successfully. I have duplicated the issue in a plunker:
https://plnkr.co/edit/ClE76zuihFTETLDGehnd?p=preview
You can see the error in the console.
Thanks in advance for your help!
I finally found something: https://www.reddit.com/r/Angular2/comments/4i2d9x/support_problem_with_barrels/
It seems, that this is not easily possible with SystemJS
, because it can not handle barrel-files.
To solve this, you can add every file as you did with [...]/index
or you can add them as a package in SystemJS
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With