feat(browser): use AppModules for bootstrap in the browser
This introduces the `BrowserModule` to be used for long form bootstrap and offline compile bootstrap: ``` @AppModule({ modules: [BrowserModule], precompile: [MainComponent], providers: […], // additional providers directives: […], // additional platform directives pipes: […] // additional platform pipes }) class MyModule { constructor(appRef: ApplicationRef) { appRef.bootstrap(MainComponent); } } // offline compile import {bootstrapModuleFactory} from ‘@angular/platform-browser’; bootstrapModuleFactory(MyModuleNgFactory); // runtime compile long form import {bootstrapModule} from ‘@angular/platform-browser-dynamic’; bootstrapModule(MyModule); ``` The short form, `bootstrap(...)`, can now creates a module on the fly, given `directives`, `pipes, `providers`, `precompile` and `modules` properties. Related changes: - make `SanitizationService`, `SecurityContext` public in `@angular/core` so that the offline compiler can resolve the token - move `AnimationDriver` to `platform-browser` and make it public so that the offline compiler can resolve the token BREAKING CHANGES: - short form bootstrap does no longer allow to inject compiler internals (i.e. everything from `@angular/compiler). Inject `Compiler` instead. To provide custom providers for the compiler, create a custom compiler via `browserCompiler({providers: [...]})` and pass that into the `bootstrap` method.
This commit is contained in:
30
tools/public_api_guard/core/index.d.ts
vendored
30
tools/public_api_guard/core/index.d.ts
vendored
@ -129,7 +129,7 @@ export declare abstract class ApplicationRef {
|
||||
componentTypes: Type[];
|
||||
injector: Injector;
|
||||
zone: NgZone;
|
||||
abstract bootstrap<C>(componentFactory: ComponentFactory<C>): ComponentRef<C>;
|
||||
abstract bootstrap<C>(componentFactory: ComponentFactory<C> | ConcreteType<C>): ComponentRef<C>;
|
||||
abstract dispose(): void;
|
||||
abstract registerBootstrapListener(listener: (ref: ComponentRef<any>) => void): void;
|
||||
abstract registerDisposeListener(dispose: () => void): void;
|
||||
@ -289,14 +289,8 @@ export declare class Compiler {
|
||||
clearCacheFor(type: Type): void;
|
||||
compileAppModuleAsync<T>(moduleType: ConcreteType<T>, metadata?: AppModuleMetadata): Promise<AppModuleFactory<T>>;
|
||||
compileAppModuleSync<T>(moduleType: ConcreteType<T>, metadata?: AppModuleMetadata): AppModuleFactory<T>;
|
||||
compileComponentAsync<T>(component: ConcreteType<T>, {moduleDirectives, modulePipes}?: {
|
||||
moduleDirectives?: ConcreteType<any>[];
|
||||
modulePipes?: ConcreteType<any>[];
|
||||
}): Promise<ComponentFactory<T>>;
|
||||
compileComponentSync<T>(component: ConcreteType<T>, {moduleDirectives, modulePipes}?: {
|
||||
moduleDirectives?: ConcreteType<any>[];
|
||||
modulePipes?: ConcreteType<any>[];
|
||||
}): ComponentFactory<T>;
|
||||
compileComponentAsync<T>(component: ConcreteType<T>): Promise<ComponentFactory<T>>;
|
||||
compileComponentSync<T>(component: ConcreteType<T>): ComponentFactory<T>;
|
||||
}
|
||||
|
||||
/** @stable */
|
||||
@ -501,9 +495,6 @@ export declare function coreBootstrap<C>(componentFactory: ComponentFactory<C>,
|
||||
/** @experimental */
|
||||
export declare function coreLoadAndBootstrap(componentType: Type, injector: Injector): Promise<ComponentRef<any>>;
|
||||
|
||||
/** @experimental */
|
||||
export declare function createNgZone(): NgZone;
|
||||
|
||||
/** @experimental */
|
||||
export declare function createPlatform(injector: Injector): PlatformRef;
|
||||
|
||||
@ -1224,6 +1215,21 @@ export declare abstract class RootRenderer {
|
||||
abstract renderComponent(componentType: RenderComponentType): Renderer;
|
||||
}
|
||||
|
||||
/** @stable */
|
||||
export declare abstract class SanitizationService {
|
||||
abstract sanitize(context: SecurityContext, value: string): string;
|
||||
}
|
||||
|
||||
/** @stable */
|
||||
export declare enum SecurityContext {
|
||||
NONE = 0,
|
||||
HTML = 1,
|
||||
STYLE = 2,
|
||||
SCRIPT = 3,
|
||||
URL = 4,
|
||||
RESOURCE_URL = 5,
|
||||
}
|
||||
|
||||
/** @stable */
|
||||
export declare var Self: SelfMetadataFactory;
|
||||
|
||||
|
2
tools/public_api_guard/core/testing.d.ts
vendored
2
tools/public_api_guard/core/testing.d.ts
vendored
@ -16,7 +16,7 @@ export declare function beforeEachProviders(fn: () => Array<any>): void;
|
||||
/** @stable */
|
||||
export declare class ComponentFixture<T> {
|
||||
changeDetectorRef: ChangeDetectorRef;
|
||||
componentInstance: any;
|
||||
componentInstance: T;
|
||||
componentRef: ComponentRef<T>;
|
||||
debugElement: DebugElement;
|
||||
elementRef: ElementRef;
|
||||
|
Reference in New Issue
Block a user