Skip to content

Commit 44fb45e

Browse files
authored
perf(angular): bundle size improvements for angular (#16966)
1 parent 45db44a commit 44fb45e

30 files changed

+280
-286
lines changed

angular/package.json

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@
2020
"url": "https://github.com/ionic-team/ionic.git"
2121
},
2222
"scripts": {
23-
"build": "npm run clean && npm run build.core && npm run build.ng && npm run clean-generated",
23+
"build": "npm run clean && npm run build.core && npm run build.ng && npm run build.fesm && npm run clean-generated",
2424
"build.dev": "npm run clean && npm run build.core.dev && npm run build.ng && npm run clean-generated",
2525
"build.core": "node scripts/build-core.js",
2626
"build.core.dev": "node scripts/build-core.js --dev",
27+
"build.fesm": "rollup --config ./scripts/rollup.config.js",
2728
"build.link": "npm run build && node scripts/link-copy.js",
2829
"build.ng": "./node_modules/.bin/ngc",
2930
"clean": "node scripts/clean.js",
@@ -36,9 +37,10 @@
3637
"tsc": "tsc -p .",
3738
"validate": "npm i && npm run lint && npm run test && npm run build"
3839
},
39-
"module": "dist/index.js",
40-
"main": "dist/index.js",
40+
"module": "dist/fesm5.js",
41+
"main": "dist/fesm5.js",
4142
"types": "dist/index.d.ts",
43+
"sideEffects": false,
4244
"files": [
4345
"dist/",
4446
"css/"
@@ -48,33 +50,35 @@
4850
"tslib": "^1.9.3"
4951
},
5052
"peerDependencies": {
51-
"@angular-devkit/core": "^7.1.2",
52-
"@angular-devkit/schematics": "^7.1.2",
53-
"@angular/core": "^7.1.3",
54-
"@angular/common": "^7.1.3",
55-
"@angular/forms": "^7.1.3",
56-
"@angular/router": "~7.1.3",
57-
"@angular/compiler": "^7.1.3",
58-
"@angular/compiler-cli": "^7.1.3",
59-
"@angular/platform-browser": "^7.1.3",
60-
"@angular/platform-browser-dynamic": "^7.1.3",
53+
"@angular-devkit/core": "^7.1.4",
54+
"@angular-devkit/schematics": "^7.1.4",
55+
"@angular/core": "^7.1.4",
56+
"@angular/common": "^7.1.4",
57+
"@angular/forms": "^7.1.4",
58+
"@angular/router": "~7.1.4",
59+
"@angular/compiler": "^7.1.4",
60+
"@angular/compiler-cli": "^7.1.4",
61+
"@angular/platform-browser": "^7.1.4",
62+
"@angular/platform-browser-dynamic": "^7.1.4",
6163
"rxjs": ">=6.2.0",
6264
"zone.js": "^0.8.26"
6365
},
6466
"devDependencies": {
65-
"@angular-devkit/core": "^7.1.2",
66-
"@angular-devkit/schematics": "^7.1.2",
67-
"@angular/core": "^7.1.3",
68-
"@angular/common": "^7.1.3",
69-
"@angular/forms": "^7.1.3",
70-
"@angular/router": "^7.1.3",
71-
"@angular/compiler": "^7.1.3",
72-
"@angular/compiler-cli": "^7.1.3",
73-
"@angular/platform-browser": "^7.1.3",
74-
"@angular/platform-browser-dynamic": "^7.1.3",
67+
"@angular-devkit/core": "^7.1.4",
68+
"@angular-devkit/schematics": "^7.1.4",
69+
"@angular/common": "^7.1.4",
70+
"@angular/compiler": "^7.1.4",
71+
"@angular/compiler-cli": "^7.1.4",
72+
"@angular/core": "^7.1.4",
73+
"@angular/forms": "^7.1.4",
74+
"@angular/platform-browser": "^7.1.4",
75+
"@angular/platform-browser-dynamic": "^7.1.4",
76+
"@angular/router": "^7.1.4",
7577
"@types/node": "~10.12.0",
7678
"fs-extra": "^7.0.0",
7779
"glob": "^7.1.3",
80+
"rollup": "^1.0.2",
81+
"rollup-plugin-node-resolve": "^4.0.0",
7882
"rxjs": "^6.2.0",
7983
"tslint": "^5.10.0",
8084
"tslint-ionic-rules": "0.0.21",

angular/scripts/rollup.config.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import resolve from 'rollup-plugin-node-resolve';
2+
3+
export default {
4+
input: 'dist/index.js',
5+
output: {
6+
file: 'dist/fesm5.js',
7+
format: 'es'
8+
},
9+
external: (id) => {
10+
// inline @ionic/core deps
11+
if (id === '@ionic/core') {
12+
return false;
13+
}
14+
// anything else is external
15+
return !(id.startsWith('.') || id.startsWith('/'));
16+
},
17+
plugins: [
18+
resolve({
19+
module: true,
20+
})
21+
]
22+
};

angular/src/app-initialize.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import { defineCustomElements } from '@ionic/core/loader';
2-
import { addIcons } from 'ionicons';
3-
import { ICON_PATHS } from 'ionicons/icons';
42

53
import { Config } from './providers/config';
64
import { IonicWindow } from './types/interfaces';
@@ -10,7 +8,6 @@ export function appInitialize(config: Config) {
108
const win: IonicWindow | undefined = window as any;
119
if (typeof win !== 'undefined') {
1210
const Ionic = win.Ionic = win.Ionic || {};
13-
addIcons(ICON_PATHS);
1411

1512
Ionic.config = config;
1613
Ionic.asyncQueue = false;

angular/src/components.d.ts

Lines changed: 0 additions & 28 deletions
This file was deleted.

angular/src/directives/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ export { IonVirtualScroll } from './virtual-scroll/virtual-scroll';
1616
export { VirtualItem } from './virtual-scroll/virtual-item';
1717
export { VirtualHeader } from './virtual-scroll/virtual-header';
1818
export { VirtualFooter } from './virtual-scroll/virtual-footer';
19+
export * from './proxies';

angular/src/directives/navigation/ion-back-button.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import { Directive, ElementRef, HostListener, Input, Optional } from '@angular/core';
1+
import { Directive, ElementRef, HostListener, Optional } from '@angular/core';
22

33
import { NavController } from '../../providers/nav-controller';
44

55
import { IonRouterOutlet } from './ion-router-outlet';
66

77
@Directive({
8-
selector: 'ion-back-button'
8+
selector: 'ion-back-button',
9+
inputs: ['defaultHref']
910
})
1011
export class IonBackButtonDelegate {
1112

12-
@Input()
1313
set defaultHref(value: string | undefined | null) {
1414
this.elementRef.nativeElement.defaultHref = value;
1515
}

angular/src/directives/navigation/ion-router-outlet.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
import { Attribute, ChangeDetectorRef, ComponentFactoryResolver, ComponentRef, Directive, ElementRef, EventEmitter, Injector, Input, NgZone, OnDestroy, OnInit, Optional, Output, ViewContainerRef } from '@angular/core';
1+
import { Attribute, ChangeDetectorRef, ComponentFactoryResolver, ComponentRef, Directive, ElementRef, EventEmitter, Injector, NgZone, OnDestroy, OnInit, Optional, Output, ViewContainerRef } from '@angular/core';
22
import { ActivatedRoute, ChildrenOutletContexts, OutletContext, PRIMARY_OUTLET, Router } from '@angular/router';
33

4-
import { Config } from '../../providers';
4+
import { Config } from '../../providers/config';
55
import { NavController } from '../../providers/nav-controller';
66

77
import { StackController } from './stack-controller';
88
import { RouteView, getUrl } from './stack-utils';
99

1010
@Directive({
1111
selector: 'ion-router-outlet',
12-
exportAs: 'outlet'
12+
exportAs: 'outlet',
13+
inputs: ['animated', 'swipeGesture']
1314
})
1415
export class IonRouterOutlet implements OnDestroy, OnInit {
1516

@@ -27,12 +28,10 @@ export class IonRouterOutlet implements OnDestroy, OnInit {
2728
@Output('activate') activateEvents = new EventEmitter<any>();
2829
@Output('deactivate') deactivateEvents = new EventEmitter<any>();
2930

30-
@Input()
3131
set animated(animated: boolean) {
3232
this.nativeEl.animated = animated;
3333
}
3434

35-
@Input()
3635
set swipeGesture(swipe: boolean) {
3736
this._swipeGesture = swipe;
3837

angular/src/directives/navigation/ion-tabs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Component, ContentChild, HostListener, ViewChild } from '@angular/core';
22

3-
import { NavController } from '../../providers';
3+
import { NavController } from '../../providers/nav-controller';
44
import { IonTabBar } from '../proxies';
55

66
import { IonRouterOutlet } from './ion-router-outlet';

angular/src/directives/navigation/router-link-delegate.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { LocationStrategy } from '@angular/common';
2-
import { Directive, ElementRef, HostListener, Input, Optional } from '@angular/core';
2+
import { Directive, ElementRef, HostListener, Optional } from '@angular/core';
33
import { Router, RouterLink } from '@angular/router';
44
import { RouterDirection } from '@ionic/core';
55
import { Subscription } from 'rxjs';
@@ -8,12 +8,13 @@ import { NavController } from '../../providers/nav-controller';
88

99
@Directive({
1010
selector: '[routerLink]',
11+
inputs: ['routerDirection']
1112
})
1213
export class RouterLinkDelegate {
1314

1415
private subscription?: Subscription;
1516

16-
@Input() routerDirection: RouterDirection = 'forward';
17+
routerDirection: RouterDirection = 'forward';
1718

1819
constructor(
1920
private locationStrategy: LocationStrategy,

angular/src/directives/proxies-list.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import * as d from './proxies';
33

44
export const DIRECTIVES = [
5-
d.IonApp,
5+
d.IonApp,
66
d.IonAvatar,
77
d.IonBackButton,
88
d.IonBackdrop,

0 commit comments

Comments
 (0)