2016-06-23 12:47:54 -04:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
|
|
|
|
2016-06-10 13:21:53 -04:00
|
|
|
import {LocationStrategy} from '@angular/common';
|
|
|
|
import {APP_ID, NgZone, PLATFORM_COMMON_PROVIDERS, PLATFORM_INITIALIZER} from '@angular/core';
|
2016-06-08 19:38:52 -04:00
|
|
|
|
2016-06-10 13:21:53 -04:00
|
|
|
import {BROWSER_APP_PROVIDERS} from '../src/browser';
|
|
|
|
import {BrowserDomAdapter} from '../src/browser/browser_adapter';
|
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.
2016-06-30 16:07:17 -04:00
|
|
|
import {AnimationDriver} from '../src/dom/animation_driver';
|
2016-06-10 13:21:53 -04:00
|
|
|
import {ELEMENT_PROBE_PROVIDERS} from '../src/dom/debug/ng_probe';
|
2016-06-08 19:38:52 -04:00
|
|
|
|
2016-06-10 13:21:53 -04:00
|
|
|
import {BrowserDetection} from './browser_util';
|
2016-06-08 19:38:52 -04:00
|
|
|
|
2016-04-28 20:50:03 -04:00
|
|
|
|
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.
2016-06-30 16:07:17 -04:00
|
|
|
|
2016-04-28 20:50:03 -04:00
|
|
|
/**
|
2016-06-10 13:21:53 -04:00
|
|
|
* Default platform providers for testing without a compiler.
|
2016-04-28 20:50:03 -04:00
|
|
|
*/
|
2016-06-10 13:21:53 -04:00
|
|
|
const TEST_BROWSER_STATIC_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> = [
|
|
|
|
PLATFORM_COMMON_PROVIDERS,
|
|
|
|
{provide: PLATFORM_INITIALIZER, useValue: initBrowserTests, multi: true}
|
|
|
|
];
|
2016-05-13 16:22:29 -04:00
|
|
|
|
2016-06-10 13:21:53 -04:00
|
|
|
const ADDITIONAL_TEST_BROWSER_STATIC_PROVIDERS: Array<any /*Type | Provider | any[]*/> = [
|
2016-06-23 20:10:22 -04:00
|
|
|
{provide: APP_ID, useValue: 'a'}, ELEMENT_PROBE_PROVIDERS,
|
2016-06-10 13:21:53 -04:00
|
|
|
{provide: NgZone, useFactory: createNgZone},
|
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.
2016-06-30 16:07:17 -04:00
|
|
|
{provide: AnimationDriver, useValue: AnimationDriver.NOOP}
|
2016-05-13 16:22:29 -04:00
|
|
|
];
|
|
|
|
|
2016-06-10 13:21:53 -04:00
|
|
|
|
|
|
|
function initBrowserTests() {
|
|
|
|
BrowserDomAdapter.makeCurrent();
|
|
|
|
BrowserDetection.setup();
|
|
|
|
}
|
|
|
|
|
|
|
|
function createNgZone(): NgZone {
|
|
|
|
return new NgZone({enableLongStackTrace: true});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-28 20:50:03 -04:00
|
|
|
/**
|
2016-06-10 13:21:53 -04:00
|
|
|
* Default platform providers for testing.
|
2016-06-27 15:27:23 -04:00
|
|
|
*
|
|
|
|
* @stable
|
2016-04-28 20:50:03 -04:00
|
|
|
*/
|
2016-06-10 13:21:53 -04:00
|
|
|
export const TEST_BROWSER_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
|
|
|
TEST_BROWSER_STATIC_PLATFORM_PROVIDERS;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Default application providers for testing without a compiler.
|
2016-06-27 15:27:23 -04:00
|
|
|
*
|
|
|
|
* @stable
|
2016-06-10 13:21:53 -04:00
|
|
|
*/
|
|
|
|
export const TEST_BROWSER_APPLICATION_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
|
|
|
[BROWSER_APP_PROVIDERS, ADDITIONAL_TEST_BROWSER_STATIC_PROVIDERS];
|