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-08-17 12:24:44 -04:00
|
|
|
import {ElementSchemaRegistry, ResourceLoader, UrlResolver} from '@angular/compiler';
|
2016-08-24 16:39:44 -04:00
|
|
|
import {Provider} from '@angular/core';
|
2016-08-30 21:07:40 -04:00
|
|
|
import {MockResourceLoader} from './resource_loader_mock';
|
|
|
|
import {MockSchemaRegistry} from './schema_registry_mock';
|
2016-08-24 16:39:44 -04:00
|
|
|
|
2016-08-30 21:07:40 -04:00
|
|
|
export function createUrlResolverWithoutPackagePrefix(): UrlResolver {
|
|
|
|
return new UrlResolver();
|
|
|
|
}
|
2015-09-14 18:59:09 -04:00
|
|
|
|
2016-08-17 19:37:31 -04:00
|
|
|
// This provider is put here just so that we can access it from multiple
|
|
|
|
// internal test packages.
|
|
|
|
// TODO: get rid of it or move to a separate @angular/internal_testing package
|
2016-12-27 17:55:58 -05:00
|
|
|
export const TEST_COMPILER_PROVIDERS: Provider[] = [
|
2016-09-27 20:10:02 -04:00
|
|
|
{provide: ElementSchemaRegistry, useValue: new MockSchemaRegistry({}, {}, {}, [], [])},
|
perf: switch angular to use StaticInjector instead of ReflectiveInjector
This change allows ReflectiveInjector to be tree shaken resulting
in not needed Reflect polyfil and smaller bundles.
Code savings for HelloWorld using Closure:
Reflective: bundle.js: 105,864(34,190 gzip)
Static: bundle.js: 154,889(33,555 gzip)
645( 2%)
BREAKING CHANGE:
`platformXXXX()` no longer accepts providers which depend on reflection.
Specifically the method signature when from `Provider[]` to
`StaticProvider[]`.
Example:
Before:
```
[
MyClass,
{provide: ClassA, useClass: SubClassA}
]
```
After:
```
[
{provide: MyClass, deps: [Dep1,...]},
{provide: ClassA, useClass: SubClassA, deps: [Dep1,...]}
]
```
NOTE: This only applies to platform creation and providers for the JIT
compiler. It does not apply to `@Compotent` or `@NgModule` provides
declarations.
Benchpress note: Previously Benchpress also supported reflective
provides, which now require static providers.
DEPRECATION:
- `ReflectiveInjector` is now deprecated as it will be remove. Use
`Injector.create` as a replacement.
closes #18496
2017-08-03 15:33:29 -04:00
|
|
|
{provide: ResourceLoader, useClass: MockResourceLoader, deps: []},
|
|
|
|
{provide: UrlResolver, useFactory: createUrlResolverWithoutPackagePrefix, deps: []}
|
2015-10-12 13:23:51 -04:00
|
|
|
];
|