mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 12:29:55 +08:00
refactor: improve tree shaking abilities
Internal refactor completed in order to improve tree shaking and dead code removal. The public API, with an exception to ion-slides, has stayed the same. However, internally many changes were required so bundlers could better exclude modules which should not be bundled. Ultimately most changes resorted to removing references to `window` or `document`, or a module that referenced one of those. BREAKING CHANGES ion-slides was refactored to remove the external dependencies, and rewritten in TypeScript/ES6 modules to again improve tree shaking abilities.
This commit is contained in:
43
src/components/slides/slide.ts
Normal file
43
src/components/slides/slide.ts
Normal file
@ -0,0 +1,43 @@
|
||||
import { ChangeDetectionStrategy, Component, ElementRef, Renderer, ViewEncapsulation } from '@angular/core';
|
||||
|
||||
import { Slides } from './slides';
|
||||
|
||||
/**
|
||||
* @name Slide
|
||||
* @description
|
||||
* The Slide component is a child component of [Slides](../Slides). The template
|
||||
* should be written as `ion-slide`. Any slide content should be written
|
||||
* in this component and it should be used in conjunction with [Slides](../Slides).
|
||||
*
|
||||
* See the [Slides API Docs](../Slides) for more usage information.
|
||||
*
|
||||
* @demo /docs/v2/demos/src/slides/
|
||||
* @see {@link /docs/v2/api/components/slides/Slides/ Slides API Docs}
|
||||
*/
|
||||
@Component({
|
||||
selector: 'ion-slide',
|
||||
template:
|
||||
'<div class="slide-zoom">' +
|
||||
'<ng-content></ng-content>' +
|
||||
'</div>',
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
})
|
||||
export class Slide {
|
||||
|
||||
constructor(
|
||||
elementRef: ElementRef,
|
||||
renderer: Renderer,
|
||||
private _slides: Slides
|
||||
) {
|
||||
renderer.setElementClass(elementRef.nativeElement, 'swiper-slide', true);
|
||||
_slides.update(10);
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
ngOnDestroy() {
|
||||
this._slides.update(10);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user