Repository: angular
Issue: Cannot read property 'bindingStartIndex' of null when using Library
Labels: type: bug/fix,area: core,area: compiler,P4

# 🐞 bug report

### Affected Package
Not sure. Maybe this is somewhere in @angular/cli or somewhere related to Webpack.


### Is this a regression?
Yes, the previous version in which this bug was not present was Angular 8


### Description
When creating a library as described in [the documentation](https://angular.io/guide/creating-libraries) and using it in an empty app, I get the following error at runtime:

    ERROR TypeError: Cannot read property 'bindingStartIndex' of null
    at Module.ɵɵelementStart (core.js:20997)
    at MyLibComponent_Template (my-lib.js:19)
    at executeTemplate (core.js:11930)
    at renderView (core.js:11716)
    at renderComponent (core.js:13232)
    at renderChildComponents (core.js:11519)
    at renderView (core.js:11742)
    at renderComponent (core.js:13232)
    at renderChildComponents (core.js:11519)
    at renderView (core.js:11742)

I do not see any errors while compiling.

## 🔬 Minimal Reproduction
I did the following:

- Create a `my-libs` project: `ng new my-libs --create-application=false`
- Create a library: `cd my-libs` and `ng generate library my-lib`
- Create an app next to this: `cd ..` and `ng new my-app`
- Add the library as a dependency of the app: Add `"my-lib": "file:../my-libs/dist/my-lib"` to the `dependencies` in the app's `package.json` and run `npm install`
- Import the `MyLibModule` in the `AppModule` (imported via `import { MyLibModule } from 'my-lib';`)
- Use the component in the `AppComponent`: `<lib-my-lib></lib-my-lib>`
- Build the library: `cd my-libs` and `ng build --prod`
- Run the app: `cd ..` and `ng serve`
- Point browser at `http://localhost:4200/`
- Open Developer Tools to look at the console

The resulting project is contained in this zip-file [repro.zip](https://github.com/angular/angular/files/4231679/repro.zip). I removed the `node_modules`, so please do

    $ cd my-libs
    $ npm install
    $ ng build --prod
    $ cd ..
    $ cd my-app
    $ npm install
    $ ng serve

## 🔥 Exception or Error
<pre><code>
    ERROR TypeError: Cannot read property 'bindingStartIndex' of null
    at Module.ɵɵelementStart (core.js:20997)
    at MyLibComponent_Template (my-lib.js:19)
    at executeTemplate (core.js:11930)
    at renderView (core.js:11716)
    at renderComponent (core.js:13232)
    at renderChildComponents (core.js:11519)
    at renderView (core.js:11742)
    at renderComponent (core.js:13232)
    at renderChildComponents (core.js:11519)
    at renderView (core.js:11742)
</code></pre>


## 🌍  Your Environment

**Angular Version:**
<pre><code>
     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 9.0.2
Node: 12.13.0
OS: darwin x64

Angular: 
... 
Ivy Workspace: 

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.900.2
@angular-devkit/core         9.0.2
@angular-devkit/schematics   9.0.2
@schematics/angular          9.0.2
@schematics/update           0.900.2
rxjs                         6.5.3
</code></pre>