Skip to content

InjectorError trying to inject Injector into AOT-compiled library when using JIT for app #20102

@jeysal

Description

@jeysal

I'm submitting a...


[?] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

A library with a directive that requires injection of Injector is AOT-compiled and distributed with metadata.
An app imports the library's module and applies the directive to an element.
Running the app with ng serve --aot works fine, the Injector is injected into the library directive.
Running the app with ng serve (JIT) results in error on page load:

Error: StaticInjectorError[Injector]: 
  StaticInjectorError[Injector]: 
    NullInjectorError: No provider for Injector!

Note that this is not specific to Injector, trying to inject e.g. IterableDiffers causes the same problem.

Expected behavior

The app works with both JIT and AOT.

Minimal reproduction of the problem with instructions

https://github.com/jeysal/ng5-jit-inj-repro

Follow the instructions in the readme on master to reproduce.

Branch master contains the library (with very basic build setup).
Branch app contains the app (generated by angular-cli).

Environment


Angular version: 5.0.0


Browser:
- [x] Chrome (desktop) version 62.0.3202.75 (Official Build) (64-bit)
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: 8.8.1  
- Platform: Linux 

Others:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions