-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Dependency injection does not work with es2015 target #8284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@kdomagoj - Did this work at one point or is this a regression? I'd generally advise against using ES2015 compiler target until full browser support has landed and those versions have been adopted widely. @mmalerba - Looks like the |
@amcdnl I was waiting for that feature to be available , and since 1.5 CLI it is. Everything works fine when built with target es5. This is first time I experience this issue. Thanks. |
It looks like everything that gets injected via DI is undefined, sidenav was just the first thing to throw an error because of it. Will update issue title to reflect the real issue |
My initial hunch would be that this is something in |
Same error with es2015 and es2016 |
I tried to reproduce that issue with the latest Angular CLI version, but unfortunately I wasn't able to serve the app with the There seem to be a lot of issues related to the I will try to manually work-around angular/angular-cli#8505 to be able to reproduce the issue. In meanwhile it would be helpful if someone runs the CLI with |
The issue of the Angular CLI has been resolved with |
I'm closing this issue because it looks like the issue has been resolved with the latest UglifyJS version. Please let us know if you still see that issue with the latest UglifyJS version. |
Can confirm issue is resolved! 15% smaller main.bundle with es2015 on Cordova Crosswalk 23 Android |
This does not appear to fully resolved yet. Using an empty material table:
with angular cli 1.6.1, target es2015, [email protected]. |
Still having this issue with MatSidenav Angular CLI 1.6.2, [email protected]
|
Same. Angular 5.1.2, Angular CLI 1.6.2, Angular Material 5.0.2, Karma 2.0.0, uglify-es 3.3.2. Works "target": "es5" // tsconfig.json Fails "target": "es2015" // tsconfig.json import { TestBed, async } from '@angular/core/testing';
import { MatSidenavModule } from '@angular/material';
import { AppComponent } from './app.component';
describe('AppComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
AppComponent
],
imports: [ MatSidenavModule ]
}).compileComponents();
}));
it('should render title in a h1 tag', async(() => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!');
}));
}); % ng test
[karma]: Karma v2.0.0 server started at http://0.0.0.0:9876/
Chrome 63.0.3239 (Mac OS X 10.12.6): Executed 1 of 1 (1 FAILED) (1.521 secs / 1.303 secs)
TOTAL: 1 FAILED
1) should render title in a link tag
AppComponent
Failed: Cannot read property 'create' of undefined
TypeError: Cannot read property 'create' of undefined
at MatSidenav.ngAfterContentInit Users/bdover/code/workshop/rethink-reading/node_modules/@angular/material/esm2015/sidenav.js:304:1)
at callProviderLifecycles Users/bdover/code/workshop/rethink-reading/node_modules/@angular/core/esm2015/core.js:10643:1)
at callElementProvidersLifecycles Users/bdover/code/workshop/rethink-reading/node_modules/@angular/core/esm2015/core.js:10617:1)
at callLifecycleHooksChildrenFirst Users/bdover/code/workshop/rethink-reading/node_modules/@angular/core/esm2015/core.js:10600:1)
at checkAndUpdateView Users/bdover/code/workshop/rethink-reading/node_modules/@angular/core/esm2015/core.js:11750:1)
at callViewAction Users/bdover/code/workshop/rethink-reading/node_modules/@angular/core/esm2015/core.js:12097:1)
at execComponentViewsAction Users/bdover/code/workshop/rethink-reading/node_modules/@angular/core/esm2015/core.js:12029:1)
at checkAndUpdateView Users/bdover/code/workshop/rethink-reading/node_modules/@angular/core/esm2015/core.js:11752:1)
at callWithDebugContext Users/bdover/code/workshop/rethink-reading/node_modules/@angular/core/esm2015/core.js:12941:28)
at Object.debugCheckAndUpdateView [as checkAndUpdateView] Users/bdover/code/workshop/rethink-reading/node_modules/@angular/core/esm2015/core.js:12531:1) |
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 To summarize:
Closing this issue (again), because everything works as intended on our side. |
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 Not pretty, but good enough for now. Thanks again! |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
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:
What are the steps to reproduce?
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?
Is there anything else we should know?
no
The text was updated successfully, but these errors were encountered: