I am using this kind of structure for folders that contain modules. This is a simplified core folder
-- core
|-- a.service.ts
|-- b.service.ts
|-- c.service.ts
|-- core.module.ts
|-- index.ts
The module imports all classes except for index. Index exports all classes.
I like this because from other files, say from components, I can import any service via import {ServiceName} from '../core/index'
and I get the nice intellisense list of all services when I start typing within the brackets in the import statement.
This was all nice and well, until I hit the 'unknown dependencies' error for some of the classes the files refer to.
Error: (SystemJS) Can't resolve all parameters for DummyComponent: (Http, ?).
The error goes away if I import the service referencing the file directly.
import {AService} from '../core/a.service'
I have two questions:
- Why does this happen? This looks like a circular reference problem. But AService doesn't have any dependencies, so it shouldn't be.
- How can I achieve this behaviour? What I am trying to emulate is the same as importing HttpModule or Http from @angular/core. I looked at the folder structure and it seems to me it is using the same logic as mine.