Skip to content

Commit

Permalink
feat(core): optimize bundle size (#611)
Browse files Browse the repository at this point in the history
Co-authored-by: Lukas Maurer <lukas.maurer@siemens.com>
  • Loading branch information
danielleroux and nuke-ellington committed Sep 20, 2023
1 parent 592a541 commit 43abb1b
Show file tree
Hide file tree
Showing 170 changed files with 914 additions and 1,013 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ yarn-error.log*
###
# Build output
##
packages/core/components/
packages/*/dist/
packages/*/www/
packages/*/loader/
Expand Down
2 changes: 1 addition & 1 deletion packages/angular-test-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@angular/platform-browser": "^14.2.0",
"@angular/platform-browser-dynamic": "^14.2.0",
"@angular/router": "^14.2.0",
"@siemens/ix-icons": "^1.2.0",
"@siemens/ix-icons": "2.0.0-beta.0",
"@siemens/ix": "~2.0.0-beta.1",
"@siemens/ix-aggrid": "~2.0.0-beta.1",
"@siemens/ix-angular": "~2.0.0-beta.1",
Expand Down
1 change: 0 additions & 1 deletion packages/angular-test-app/src/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

@import '@siemens/ix-aggrid/dist/ix-aggrid/ix-aggrid.css';
@import '@siemens/ix/dist/siemens-ix/siemens-ix.css';
@import '@siemens/ix-icons/dist/css/ix-icons.css';

@import './preview-examples/placeholder-logo.css';

Expand Down
2 changes: 1 addition & 1 deletion packages/angular/ng-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"lib": {
"entryFile": "src/index.ts"
},
"allowedNonPeerDependencies": ["tslib", "@siemens/ix", "@siemens/ix-icons"]
"allowedNonPeerDependencies": ["tslib", "@siemens/ix"]
}
6 changes: 3 additions & 3 deletions packages/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
},
"license": "MIT",
"dependencies": {
"@siemens/ix": "~2.0.0-beta.1",
"@siemens/ix-icons": "^1.2.0"
"@siemens/ix": "~2.0.0-beta.1"
},
"peerDependencies": {
"@angular/core": ">=13.3.12"
"@angular/core": ">=13.3.12",
"@siemens/ix-icons": "2.0.0-beta.0"
},
"devDependencies": {
"@angular/common": "v13-lts",
Expand Down
9 changes: 5 additions & 4 deletions packages/angular/src/app-initialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
* LICENSE file in the root directory of this source tree.
*/

import { defineCustomElements as iconsDefineCustomElements } from '@siemens/ix-icons/loader';
import { applyPolyfills, defineCustomElements } from '@siemens/ix/loader';

let didInitialize = false;

export const appInitialize = (doc: Document) => {
return () => {
return async () => {
const win: Window | undefined = doc.defaultView as any;
if (win && typeof (window as any) !== 'undefined') {
if (didInitialize) {
Expand All @@ -21,9 +22,9 @@ export const appInitialize = (doc: Document) => {

didInitialize = true;

applyPolyfills().then(() => {
return defineCustomElements();
});
await applyPolyfills();
await iconsDefineCustomElements();
await defineCustomElements();
}
};
};
22 changes: 0 additions & 22 deletions packages/angular/src/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -985,28 +985,6 @@ export declare interface IxGroupItem extends Components.IxGroupItem {
}


@ProxyCmp({
inputs: ['color', 'name', 'size']
})
@Component({
selector: 'ix-icon',
changeDetection: ChangeDetectionStrategy.OnPush,
template: '<ng-content></ng-content>',
// eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
inputs: ['color', 'name', 'size'],
})
export class IxIcon {
protected el: HTMLElement;
constructor(c: ChangeDetectorRef, r: ElementRef, protected z: NgZone) {
c.detach();
this.el = r.nativeElement;
}
}


export declare interface IxIcon extends Components.IxIcon {}


@ProxyCmp({
inputs: ['color', 'disabled', 'ghost', 'icon', 'loading', 'outline', 'oval', 'size', 'type', 'variant']
})
Expand Down
1 change: 0 additions & 1 deletion packages/angular/src/declare-components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export const DIRECTIVES = [
d.IxGroup,
d.IxGroupContextMenu,
d.IxGroupItem,
d.IxIcon,
d.IxIconButton,
d.IxIconToggleButton,
d.IxInputGroup,
Expand Down
1 change: 1 addition & 0 deletions packages/angular/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export * from '@siemens/ix';
export * from './boolean-value-accessor';
export * from './components';
export * from './dropdown/trigger.directive';
export { IxIcon } from './ix-icon';
export * from './modal';
export * from './module';
export * from './select-value-accessor';
Expand Down
38 changes: 38 additions & 0 deletions packages/angular/src/ix-icon.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* SPDX-FileCopyrightText: 2023 Siemens AG
*
* SPDX-License-Identifier: MIT
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
ElementRef,
NgZone,
} from '@angular/core';
import type { Components } from '@siemens/ix';
import { ProxyCmp } from './angular-component-lib/utils';

export declare interface IxIcon extends Components.IxIcon {}

@ProxyCmp({
defineCustomElementFn: undefined,
inputs: ['color', 'name'],
})
@Component({
selector: 'ix-icon',
changeDetection: ChangeDetectionStrategy.OnPush,
template: '<ng-content></ng-content>',
inputs: ['color', 'name'],
})
export class IxIcon {
protected el: HTMLElement;
constructor(c: ChangeDetectorRef, r: ElementRef, protected z: NgZone) {
c.detach();
this.el = r.nativeElement;
}
}
3 changes: 2 additions & 1 deletion packages/angular/src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,18 @@ import {
import { appInitialize } from './app-initialize';
import { DIRECTIVES } from './declare-components';
import { IxDropdownTriggerDirective } from './dropdown/trigger.directive';
import { IxIcon } from './ix-icon';
import { ModalService } from './modal';
import { SelectValueAccessor } from './select-value-accessor';
import { BooleanValueAccessor } from './boolean-value-accessor';
import { ThemeService } from './theme';
import { ToastService } from './toast';
import * as tree from './tree';

const DECLARATIONS = [
...DIRECTIVES,
tree.IxTree,
IxDropdownTriggerDirective,
IxIcon,
SelectValueAccessor,
BooleanValueAccessor
];
Expand Down
Loading

0 comments on commit 43abb1b

Please sign in to comment.