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
This commit is contained in:

committed by
Victor Berchet

parent
d9d00bd9b5
commit
fcadbf4bf6
12
tools/public_api_guard/core/core.d.ts
vendored
12
tools/public_api_guard/core/core.d.ts
vendored
@ -209,7 +209,7 @@ export declare type CompilerOptions = {
|
||||
/** @deprecated */ useDebug?: boolean;
|
||||
useJit?: boolean;
|
||||
defaultEncapsulation?: ViewEncapsulation;
|
||||
providers?: any[];
|
||||
providers?: StaticProvider[];
|
||||
missingTranslation?: MissingTranslationStrategy;
|
||||
enableLegacyTemplate?: boolean;
|
||||
};
|
||||
@ -289,7 +289,7 @@ export interface ContentChildrenDecorator {
|
||||
export declare function createPlatform(injector: Injector): PlatformRef;
|
||||
|
||||
/** @experimental */
|
||||
export declare function createPlatformFactory(parentPlatformFactory: ((extraProviders?: Provider[]) => PlatformRef) | null, name: string, providers?: Provider[]): (extraProviders?: Provider[]) => PlatformRef;
|
||||
export declare function createPlatformFactory(parentPlatformFactory: ((extraProviders?: StaticProvider[]) => PlatformRef) | null, name: string, providers?: StaticProvider[]): (extraProviders?: StaticProvider[]) => PlatformRef;
|
||||
|
||||
/** @stable */
|
||||
export declare const CUSTOM_ELEMENTS_SCHEMA: SchemaMetadata;
|
||||
@ -537,7 +537,7 @@ export declare class IterableDiffers {
|
||||
constructor(factories: IterableDifferFactory[]);
|
||||
find(iterable: any): IterableDifferFactory;
|
||||
static create(factories: IterableDifferFactory[], parent?: IterableDiffers): IterableDiffers;
|
||||
static extend(factories: IterableDifferFactory[]): Provider;
|
||||
static extend(factories: IterableDifferFactory[]): StaticProvider;
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
@ -580,7 +580,7 @@ export declare class KeyValueDiffers {
|
||||
constructor(factories: KeyValueDifferFactory[]);
|
||||
find(kv: any): KeyValueDifferFactory;
|
||||
static create<S>(factories: KeyValueDifferFactory[], parent?: KeyValueDiffers): KeyValueDiffers;
|
||||
static extend<S>(factories: KeyValueDifferFactory[]): Provider;
|
||||
static extend<S>(factories: KeyValueDifferFactory[]): StaticProvider;
|
||||
}
|
||||
|
||||
/** @experimental */
|
||||
@ -715,7 +715,7 @@ export declare const PLATFORM_ID: InjectionToken<Object>;
|
||||
export declare const PLATFORM_INITIALIZER: InjectionToken<(() => void)[]>;
|
||||
|
||||
/** @experimental */
|
||||
export declare const platformCore: (extraProviders?: Provider[] | undefined) => PlatformRef;
|
||||
export declare const platformCore: (extraProviders?: StaticProvider[] | undefined) => PlatformRef;
|
||||
|
||||
/** @stable */
|
||||
export declare abstract class PlatformRef {
|
||||
@ -772,7 +772,7 @@ export declare abstract class ReflectiveInjector implements Injector {
|
||||
static resolveAndCreate(providers: Provider[], parent?: Injector): ReflectiveInjector;
|
||||
}
|
||||
|
||||
/** @experimental */
|
||||
/** @deprecated */
|
||||
export declare class ReflectiveKey {
|
||||
readonly displayName: string;
|
||||
id: number;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/** @stable */
|
||||
export declare const platformBrowserDynamic: (extraProviders?: Provider[] | undefined) => PlatformRef;
|
||||
export declare const platformBrowserDynamic: (extraProviders?: StaticProvider[] | undefined) => PlatformRef;
|
||||
|
||||
/** @experimental */
|
||||
export declare const RESOURCE_CACHE_PROVIDER: Provider[];
|
||||
|
@ -3,4 +3,4 @@ export declare class BrowserDynamicTestingModule {
|
||||
}
|
||||
|
||||
/** @stable */
|
||||
export declare const platformBrowserDynamicTesting: (extraProviders?: Provider[] | undefined) => PlatformRef;
|
||||
export declare const platformBrowserDynamicTesting: (extraProviders?: StaticProvider[] | undefined) => PlatformRef;
|
||||
|
@ -90,7 +90,7 @@ export declare class NgProbeToken {
|
||||
}
|
||||
|
||||
/** @stable */
|
||||
export declare const platformBrowser: (extraProviders?: Provider[]) => PlatformRef;
|
||||
export declare const platformBrowser: (extraProviders?: StaticProvider[]) => PlatformRef;
|
||||
|
||||
/** @stable */
|
||||
export interface SafeHtml extends SafeValue {
|
||||
|
@ -3,4 +3,4 @@ export declare class BrowserTestingModule {
|
||||
}
|
||||
|
||||
/** @stable */
|
||||
export declare const platformBrowserTesting: (extraProviders?: Provider[] | undefined) => PlatformRef;
|
||||
export declare const platformBrowserTesting: (extraProviders?: StaticProvider[] | undefined) => PlatformRef;
|
||||
|
@ -8,10 +8,10 @@ export interface PlatformConfig {
|
||||
}
|
||||
|
||||
/** @experimental */
|
||||
export declare const platformDynamicServer: (extraProviders?: Provider[] | undefined) => PlatformRef;
|
||||
export declare const platformDynamicServer: (extraProviders?: StaticProvider[] | undefined) => PlatformRef;
|
||||
|
||||
/** @experimental */
|
||||
export declare const platformServer: (extraProviders?: Provider[] | undefined) => PlatformRef;
|
||||
export declare const platformServer: (extraProviders?: StaticProvider[] | undefined) => PlatformRef;
|
||||
|
||||
/** @experimental */
|
||||
export declare class PlatformState {
|
||||
@ -24,14 +24,14 @@ export declare class PlatformState {
|
||||
export declare function renderModule<T>(module: Type<T>, options: {
|
||||
document?: string;
|
||||
url?: string;
|
||||
extraProviders?: Provider[];
|
||||
extraProviders?: StaticProvider[];
|
||||
}): Promise<string>;
|
||||
|
||||
/** @experimental */
|
||||
export declare function renderModuleFactory<T>(moduleFactory: NgModuleFactory<T>, options: {
|
||||
document?: string;
|
||||
url?: string;
|
||||
extraProviders?: Provider[];
|
||||
extraProviders?: StaticProvider[];
|
||||
}): Promise<string>;
|
||||
|
||||
/** @experimental */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/** @experimental */
|
||||
export declare const platformServerTesting: (extraProviders?: Provider[] | undefined) => PlatformRef;
|
||||
export declare const platformServerTesting: (extraProviders?: StaticProvider[] | undefined) => PlatformRef;
|
||||
|
||||
/** @experimental */
|
||||
export declare class ServerTestingModule {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/** @experimental */
|
||||
export declare const platformWorkerAppDynamic: (extraProviders?: Provider[] | undefined) => PlatformRef;
|
||||
export declare const platformWorkerAppDynamic: (extraProviders?: StaticProvider[] | undefined) => PlatformRef;
|
||||
|
||||
/** @stable */
|
||||
export declare const VERSION: Version;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/** @experimental */
|
||||
export declare function bootstrapWorkerUi(workerScriptUri: string, customProviders?: Provider[]): Promise<PlatformRef>;
|
||||
export declare function bootstrapWorkerUi(workerScriptUri: string, customProviders?: StaticProvider[]): Promise<PlatformRef>;
|
||||
|
||||
/** @experimental */
|
||||
export declare abstract class ClientMessageBroker {
|
||||
@ -41,10 +41,10 @@ export interface MessageBusSource {
|
||||
}
|
||||
|
||||
/** @experimental */
|
||||
export declare const platformWorkerApp: (extraProviders?: Provider[] | undefined) => PlatformRef;
|
||||
export declare const platformWorkerApp: (extraProviders?: StaticProvider[] | undefined) => PlatformRef;
|
||||
|
||||
/** @experimental */
|
||||
export declare const platformWorkerUi: (extraProviders?: Provider[] | undefined) => PlatformRef;
|
||||
export declare const platformWorkerUi: (extraProviders?: StaticProvider[] | undefined) => PlatformRef;
|
||||
|
||||
/** @experimental */
|
||||
export declare const PRIMITIVE: SerializerTypes;
|
||||
@ -100,7 +100,7 @@ export declare const WORKER_APP_LOCATION_PROVIDERS: ({
|
||||
})[];
|
||||
|
||||
/** @experimental */
|
||||
export declare const WORKER_UI_LOCATION_PROVIDERS: Provider[];
|
||||
export declare const WORKER_UI_LOCATION_PROVIDERS: StaticProvider[];
|
||||
|
||||
/** @experimental */
|
||||
export declare class WorkerAppModule {
|
||||
|
2
tools/public_api_guard/upgrade/static.d.ts
vendored
2
tools/public_api_guard/upgrade/static.d.ts
vendored
@ -11,7 +11,7 @@ export declare function downgradeComponent(info: {
|
||||
export declare function downgradeInjectable(token: any): Function;
|
||||
|
||||
/** @experimental */
|
||||
export declare function downgradeModule<T>(moduleFactoryOrBootstrapFn: NgModuleFactory<T> | ((extraProviders: Provider[]) => Promise<NgModuleRef<T>>)): string;
|
||||
export declare function downgradeModule<T>(moduleFactoryOrBootstrapFn: NgModuleFactory<T> | ((extraProviders: StaticProvider[]) => Promise<NgModuleRef<T>>)): string;
|
||||
|
||||
/** @stable */
|
||||
export declare function getAngularLib(): any;
|
||||
|
Reference in New Issue
Block a user