MOBILE-2163 aot: Support site plugins in AOT

main
Dani Palou 2018-06-12 14:11:52 +02:00
parent f3d103f311
commit 804e8c7b02
5 changed files with 1826 additions and 2264 deletions

4053
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -14,11 +14,12 @@
import { BrowserModule } from '@angular/platform-browser'; import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { NgModule } from '@angular/core'; import { NgModule, COMPILER_OPTIONS } from '@angular/core';
import { IonicApp, IonicModule, Platform, Content, ScrollEvent } from 'ionic-angular'; import { IonicApp, IonicModule, Platform, Content, ScrollEvent } from 'ionic-angular';
import { assert } from 'ionic-angular/util/util'; import { assert } from 'ionic-angular/util/util';
import { HttpModule } from '@angular/http'; import { HttpModule } from '@angular/http';
import { HttpClient, HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http'; import { HttpClient, HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
import { JitCompilerFactory } from '@angular/platform-browser-dynamic';
import { TranslateModule, TranslateLoader } from '@ngx-translate/core'; import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader'; import { TranslateHttpLoader } from '@ngx-translate/http-loader';
@ -248,7 +249,9 @@ export const CORE_PROVIDERS: any[] = [
provide: HTTP_INTERCEPTORS, provide: HTTP_INTERCEPTORS,
useClass: CoreInterceptor, useClass: CoreInterceptor,
multi: true, multi: true,
} },
{provide: COMPILER_OPTIONS, useValue: {}, multi: true},
{provide: JitCompilerFactory, useClass: JitCompilerFactory, deps: [COMPILER_OPTIONS]}
] ]
}) })
export class AppModule { export class AppModule {

View File

@ -15,13 +15,15 @@
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { CoreCompileHtmlComponent } from './compile-html'; import { CoreCompileHtmlComponent } from './compile-html';
import { CoreComponentsModule } from '@components/components.module';
@NgModule({ @NgModule({
declarations: [ declarations: [
CoreCompileHtmlComponent CoreCompileHtmlComponent
], ],
imports: [ imports: [
CommonModule CommonModule,
CoreComponentsModule
], ],
exports: [ exports: [
CoreCompileHtmlComponent CoreCompileHtmlComponent

View File

@ -37,7 +37,7 @@ import { CoreDomUtilsProvider } from '@providers/utils/dom';
*/ */
@Component({ @Component({
selector: 'core-compile-html', selector: 'core-compile-html',
template: '<ng-container #dynamicComponent></ng-container>' template: '<core-loading [hideUntil]="loaded"><ng-container #dynamicComponent></ng-container></core-loading>'
}) })
export class CoreCompileHtmlComponent implements OnChanges, OnDestroy, DoCheck { export class CoreCompileHtmlComponent implements OnChanges, OnDestroy, DoCheck {
@Input() text: string; // The HTML text to display. @Input() text: string; // The HTML text to display.
@ -50,6 +50,8 @@ export class CoreCompileHtmlComponent implements OnChanges, OnDestroy, DoCheck {
// Get the container where to put the content. // Get the container where to put the content.
@ViewChild('dynamicComponent', { read: ViewContainerRef }) container: ViewContainerRef; @ViewChild('dynamicComponent', { read: ViewContainerRef }) container: ViewContainerRef;
loaded: boolean;
protected componentRef: ComponentRef<any>; protected componentRef: ComponentRef<any>;
protected componentInstance: any; protected componentInstance: any;
protected element; protected element;
@ -93,6 +95,8 @@ export class CoreCompileHtmlComponent implements OnChanges, OnDestroy, DoCheck {
this.componentRef = this.container.createComponent(factory); this.componentRef = this.container.createComponent(factory);
this.created.emit(this.componentRef.instance); this.created.emit(this.componentRef.instance);
} }
this.loaded = true;
}); });
} }
} }

View File

@ -13,6 +13,7 @@
// limitations under the License. // limitations under the License.
import { Injectable, Injector, Component, NgModule, Compiler, ComponentFactory, ComponentRef, NgModuleRef } from '@angular/core'; import { Injectable, Injector, Component, NgModule, Compiler, ComponentFactory, ComponentRef, NgModuleRef } from '@angular/core';
import { JitCompilerFactory } from '@angular/platform-browser-dynamic';
import { import {
Platform, ActionSheetController, AlertController, LoadingController, ModalController, PopoverController, ToastController, Platform, ActionSheetController, AlertController, LoadingController, ModalController, PopoverController, ToastController,
IonicModule IonicModule
@ -125,6 +126,7 @@ import { AddonNotificationsComponentsModule } from '@addon/notifications/compone
export class CoreCompileProvider { export class CoreCompileProvider {
protected logger; protected logger;
protected compiler: Compiler;
// Other Ionic/Angular providers that don't depend on where they are injected. // Other Ionic/Angular providers that don't depend on where they are injected.
protected OTHER_PROVIDERS = [ protected OTHER_PROVIDERS = [
@ -141,8 +143,10 @@ export class CoreCompileProvider {
AddonNotificationsComponentsModule AddonNotificationsComponentsModule
]; ];
constructor(protected injector: Injector, logger: CoreLoggerProvider, protected compiler: Compiler) { constructor(protected injector: Injector, logger: CoreLoggerProvider, compilerFactory: JitCompilerFactory) {
this.logger = logger.getInstance('CoreCompileProvider'); this.logger = logger.getInstance('CoreCompileProvider');
this.compiler = compilerFactory.createCompiler();
} }
/** /**