For a module such as:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
Ivy will emit the following code:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import * as i0 from "@angular/core";
export class AppModule {
}
AppModule.ɵmod = i0.ɵɵdefineNgModule({ type: AppModule, bootstrap: [AppComponent] });
AppModule.ɵinj = i0.ɵɵdefineInjector({ factory: function AppModule_Factory(t) { return new (t || AppModule)(); }, providers: [], imports: [[
BrowserModule
]] });
/*@__PURE__*/ i0.ɵɵsetNgModuleScope(AppModule, { declarations: [AppComponent], imports: [BrowserModule] });
/*@__PURE__*/ i0.ɵsetClassMetadata(AppModule, [{
type: NgModule,
args: [{
declarations: [
AppComponent
],
imports: [
BrowserModule
],
providers: [],
bootstrap: [AppComponent]
}]
}], null, null);
//# sourceMappingURL=app.module.js.map
The import * as i0 from "@angular/core"; in particular is hard to optimize, as it imports the whole of @angular/core.
Instead it should only emit imports for the used imports:
import {ɵɵdefineNgModule, ɵɵdefineInjector, ɵɵsetNgModuleScope, ɵsetClassMetadata} from "@angular/core";
Alternatively, they could be added to the existing @angular/core import.
@clydin found that TypeScript has done the same for their helpers, for the same reason: microsoft/TypeScript#32742
For a module such as:
Ivy will emit the following code:
The
import * as i0 from "@angular/core";in particular is hard to optimize, as it imports the whole of@angular/core.Instead it should only emit imports for the used imports:
Alternatively, they could be added to the existing
@angular/coreimport.@clydin found that TypeScript has done the same for their helpers, for the same reason: microsoft/TypeScript#32742