question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dependency injection does not work with es2015 target

See original GitHub issue

Bug, feature request, or proposal:

Bug

What is the expected behavior?

mat-sidenav should Initialize without error

What is the current behavior?

Using target: es5 everything works normal (using --prod --aot --build-optimizer and in dev mode) When target is set to es2015 error is thrown:

Cannot read property 'create' of undefined
    at MatSidenav.ngAfterContentInit (sidenav.js:268)
    at callProviderLifecycles (core.js:10333)
    at callElementProvidersLifecycles (core.js:10310)
    at callLifecycleHooksChildrenFirst (core.js:10294)
    at checkAndUpdateView (core.js:11422)
    at callViewAction (core.js:11769)
    at execComponentViewsAction (core.js:11701)
    at checkAndUpdateView (core.js:11425)
    at callWithDebugContext (core.js:12592)
    at Object.debugCheckAndUpdateView [as checkAndUpdateView] (core.js:12182)

What are the steps to reproduce?

<mat-sidenav-container class="view"  fxLayout="column" >
        <mat-sidenav  #leftsidenav (opened)="onLeftOpened($event)" 
           (closed)="onLeftClosed($event)" class="left"  position="start"  mode="over">
             <ui-view name="left"></ui-view>
        </mat-sidenav>
</mat-sidenav-container>

What is the use-case or motivation for changing an existing behavior?

To work using target: es2015

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Angular CLI: 1.5.0
Node: 8.7.0
OS: linux x64
Angular: 5.0.0
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cdk: 5.0.0-rc0
@angular/cli: 1.5.0
@angular/flex-layout: 2.0.0-beta.10-4905443
@angular/material: 5.0.0-rc0
@angular-devkit/build-optimizer: 0.0.32
@angular-devkit/core: 0.0.20
@angular-devkit/schematics: 0.0.35
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.0
@schematics/angular: 0.1.1
typescript: 2.4.2
webpack-bundle-analyzer: 2.9.0
webpack: 3.8.1

Is there anything else we should know?

no

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
devversioncommented, Dec 28, 2017

I just looked into this issue again.

As I mentioned previously, the issue with the ES2015 mode when serving the application in combination with the build-optimizer in AOT mode has been fixed by the UglifyJS update.

For unit tests, the AOT mode is not supported, and the metadata files won’t be read. This means that Angular runs in JIT mode and needs to figure out the ctorParameters and the inheritance itself. Unfortunately this is not supported and therefore the tests won’t run in JIT ES2015 mode.

To summarize:

Closing this issue (again), because everything works as intended on our side.

1reaction
byrondovercommented, Jan 3, 2018

Thank you for the clarification and issue links, Paul! 🙇

I’m working around the testing issues in the meantime by configuring a second Angular CLI app, and setting "tsconfig": "tsconfig.spec.json" with tsconfig.spec.json explicitly targeting ES5 ("target": "es5"), per Felipe’s suggestion.

Not pretty, but good enough for now. Thanks again!

Read more comments on GitHub >

github_iconTop Results From Across the Web

When to Use ES2015 Modules Instead of ... - Angular First
This post discusses some of the nuances between ECMAScript 2015 module dependencies and Angular's dependency injection system. These are design ...
Read more >
Angular 2 dependency injection in ES5 and ES6
Here's a plunker with 'es6' TS target that follows the suggested syntax and it throws "Can't resolve all parameters for Service: (?) ....
Read more >
babel-loader - webpack
This package allows transpiling JavaScript files using Babel and webpack. Note: Issues with the output should be reported on the Babel Issues tracker....
Read more >
Browser support - Angular
Polyfillslink. Angular is built on the latest standards of the web platform. Targeting such a wide range of browsers is challenging because they...
Read more >
Universal Dependency Injection. DI in TypeScript for React ...
Dependency injection is a solution in which a system supplies a target 1..n ... A true dependency injection (DI) system easily solves these...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found