title: Angular6: No Provider for Injector when using local library
body: <p>I'm somewhat new to Angular versions post AngularJS and decided to give them a try. What I want to do is to build a library of UI components, and an application that will consume the said library. In my library, I decided to create the components as WebComponents, so following the tutorials I've found so far, I have something like</p>
  
  <pre><code>import { Injector, NgModule } from '@angular/core'
  import { createCustomElement } from '@angular/elements';
  import { MyButtonComponent} from './my-button.component'
  
  @NgModule({
      declarations: [MyButtonComponent],
      entryComponents: [MyButtonComponent]
  })
  export class MyButtonModule {
      constructor(injector: Injector) {
          const myButton = createCustomElement(MyButtonComponent, { injector });
          customElements.define('my-button', myButton);
      }
  }
  </code></pre>
  
  <p>For my custom component. If I add all the files (the module, the component, template and SCSS files) for my component directly to my application it works as expected, so I know my component declaration is right. However, if in my application I include the component from my library, when running my app with <code>ng serve</code>, I see the error:</p>
  
  <pre><code>Error: StaticInjectorError(AppModule)[MyButtonModule -&gt; Injector]: 
    StaticInjectorError(Platform: core)[MyButtonModule -&gt; Injector]: 
      NullInjectorError: No provider for Injector!
  </code></pre>
  
  <p>I'm using Angular 6 and I have both projects running locally and I'm using <code>ng-packagr</code> to bundle my library. I added <code>@angular/core</code> and <code>@angular/elements</code> as <code>peerDependencies</code> in my library, and in my main app I had to add</p>
  
  <pre><code>"resolutions": {
      "@angular/core": "6.1.4"
  }
  </code></pre>
  
  <p>To solve the error <code>cannot redeclare block-scoped variable 'ngDevMode'</code> (not sure if this is related or not). Initially I thought the injection error could be caused by <a href="https://github.com/dherges/ng-packagr/issues/299" rel="noreferrer" title="preserveSymlinks">this</a> but I've added the <code>preserveSymlinks</code> to my <code>angular.json</code> file and I still have the error. </p>
  
  <p>Any thoughts on what might be causing this?</p>
  
  <p>UPDATE: If I copy the files manually from my library folder and paste them inside the <code>node_modules</code> folder of my main app it works, which leads me to think it's something involve symbolic links.</p>