Repository navigation
Closed
Labels
area: coreIssues related to the framework runtimeIssues related to the framework runtimefreq3: hightype: bug/fix
Milestone
Description
🐞 bug report
Description
When using ivy in compatibility mode, with platformBrowser, the final bundle is not optimal for tree-shaking. As in the final bundle the CommonModule references all module definitions and thus they are marked as used and cannot be dropped by webpack.
var CommonModule = /** @class */ /*@__PURE__*/ (function () {
function CommonModule() {
}
/*@__PURE__*/ _angular_core__WEBPACK_IMPORTED_MODULE_0__["ɵsetClassMetadata"](CommonModule, [{
type: _angular_core__WEBPACK_IMPORTED_MODULE_0__["NgModule"],
args: [{
declarations: [COMMON_DIRECTIVES, COMMON_PIPES],
exports: [COMMON_DIRECTIVES, COMMON_PIPES],
providers: [
{ provide: NgLocalization, useClass: NgLocaleLocalization },
]
}]
}], function () { return []; }, null);
CommonModule.ngModuleDef = _angular_core__WEBPACK_IMPORTED_MODULE_0__["ɵdefineNgModule"]({ type: CommonModule, bootstrap: [], declarations: [NgClass,
NgComponentOutlet,
NgForOf,
NgIf,
NgTemplateOutlet,
NgStyle,
NgSwitch,
NgSwitchCase,
NgSwitchDefault,
NgPlural,
NgPluralCase,
AsyncPipe,
UpperCasePipe,
LowerCasePipe,
JsonPipe,
SlicePipe,
DecimalPipe,
PercentPipe,
TitleCasePipe,
CurrencyPipe,
DatePipe,
I18nPluralPipe,
I18nSelectPipe,
KeyValuePipe], imports: [], exports: [NgClass,
NgComponentOutlet,
NgForOf,
NgIf,
NgTemplateOutlet,
NgStyle,
NgSwitch,
NgSwitchCase,
NgSwitchDefault,
NgPlural,
NgPluralCase,
AsyncPipe,
UpperCasePipe,
LowerCasePipe,
JsonPipe,
SlicePipe,
DecimalPipe,
PercentPipe,
TitleCasePipe,
CurrencyPipe,
DatePipe,
I18nPluralPipe,
I18nSelectPipe,
KeyValuePipe] });
CommonModule.ngInjectorDef = _angular_core__WEBPACK_IMPORTED_MODULE_0__["defineInjector"]({ factory: function CommonModule_Factory(t) { return new (t || CommonModule)(); }, providers: [
{ provide: NgLocalization, useClass: NgLocaleLocalization },
], imports: [[COMMON_DIRECTIVES, COMMON_PIPES]] });
return CommonModule;
}());🔬 Minimal Reproduction
Use ivy in compatibility mode.
In main.ts
import { enableProdMode } from '@angular/core';
import { platformBrowser } from '@angular/platform-browser';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
if (environment.production) {
enableProdMode();
}
platformBrowser().bootstrapModule(AppModule)
.catch(err => console.error(err));In app.module.ts, add BrowserModule
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 { }🌍 Your Environment
Angular Version: 7.2.0
Anything else relevant?
Been tried with #27848 and angular/angular-cli#13382
Reacted by Zama Khan Mohammed
Metadata
Metadata
Assignees
Labels
area: coreIssues related to the framework runtimeIssues related to the framework runtimefreq3: hightype: bug/fix
Activity
filipesilva commentedon Jan 22, 2019
Chatted with @alxhub about this, it's on the teams radar and part of the Ivy design.
Right now this option is always true:
angular/packages/compiler/src/render3/r3_module_compiler.ts
Lines 54 to 59 in 6324ad4
This option causes the imports to be inlined, and while inlined they are not tree-shakeable. Later on there will be a way for this option to be false and patch the selectors in later.
petebacondarwin commentedon Mar 27, 2019
Actually that option is not actually implemented at all yet :-)
feat(ivy): emit module scope metadata using pure function call (angul…
angular-automatic-lock-bot commentedon Sep 14, 2019
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.