Barrel Import Appears To Break Load Order
<p>I've got a component that I'm trying to unit test but I keep getting these errors, depending on my import statements:</p>

<pre><code>Error: Cannot resolve all parameters for 'MyComponent'(undefined, FormBuilder).

TypeError: Cannot read property 'toString' of undefined
</code></pre>

<p>My component takes 2 parameters, one the FormBuilder and one a custom service, that must be injected:</p>

<pre><code>import {MyService} from '../';

@Component({
    ...,
    providers: [MyService]
})
class MyComponent {
    constructor(service: MyService, fb: FormBuilder) { ... }
    ...
}
</code></pre>

<p>And my unit test is setup as follows:</p>

<pre><code>import {MyComponent} from './';
import {MyService} from '../';

describe('Component: MyComponent', () =&gt; {

    let builder: TestComponentBuilder;

    beforeEachProviders(() =&gt; [
        MyService,
        MyComponent
    ]);

    beforeEach(inject([TestComponentBuilder], function (tcb: TestComponentBuilder) {
        builder = tcb;
    }));

    it('should inject the component', inject([MyComponent],      
        (component: MyComponent) =&gt; {
            expect(component).toBeTruthy();
        })
    );

}
</code></pre>

<p>The imports seem to be the problem, since I'm trying to use barrels:</p>

<pre><code>|
|- my-component
|  |- index.ts
|  |- my.component.ts
|  |- my.component.spec.ts
|
|- my-service
|  |- index.ts
|  |- my.service.ts
|
|- index.ts
</code></pre>

<p>Inside my index.ts files, I'm doing:</p>

<pre><code>export * from '&lt;filename&gt;';
export * from '&lt;directory&gt;';
</code></pre>

<p>as appropriate.</p>

<p>However, when I change the imports in the unit test AND component to reference the service file directly, the unit test works.  </p>

<pre><code>import {MyService} from '../my-service/my.service';
</code></pre>

<p>I'm using angular-cli in this project and SystemJS is being configured with the generated config file from that:</p>

<pre><code>...
const barrels: string[] = [
  ...,

  // App specific barrels.
  'app',
  'app/my-service',
  'app/my-component'
  /** @cli-barrel */
];

const cliSystemConfigPackages: any = {};
barrels.forEach((barrelName: string) =&gt; {
  cliSystemConfigPackages[barrelName] = { main: 'index' };
});

/** Type declaration for ambient System. */
declare var System: any;

// Apply the CLI SystemJS configuration.
System.config({
  map: {
    '@angular': 'vendor/@angular',
    'rxjs': 'vendor/rxjs',
    'main': 'main.js'
  },
  packages: cliSystemConfigPackages
});
...
</code></pre>

<p>It seems that when I import from the barrels, the component and service definitions aren't loaded ahead of the unit test code.  The application itself will transpile and run, either way.</p>

<p>Sorry if this is asking a broad question, but I'm still pretty new to barrels and SystemJS and I don't know how to narrow the scope further:  </p>

<p>Is this a bug with SystemJS/Jasmine/TypeScript/Angular2 or am I doing something wrong in my setup?</p>