feat(router): add the ANALYZE_FOR_PRECOMPILE provider to make dev ergonomics better
This commit is contained in:
@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
import {Location, LocationStrategy, PathLocationStrategy} from '@angular/common';
|
||||
import {APP_INITIALIZER, AppModuleFactoryLoader, ApplicationRef, ComponentResolver, Injector, OpaqueToken, SystemJsAppModuleLoader} from '@angular/core';
|
||||
import {ANALYZE_FOR_PRECOMPILE, APP_INITIALIZER, AppModuleFactoryLoader, ApplicationRef, ComponentResolver, Injector, OpaqueToken, SystemJsAppModuleLoader} from '@angular/core';
|
||||
|
||||
import {Routes} from './config';
|
||||
import {Router} from './router';
|
||||
@ -84,6 +84,7 @@ export function setupRouterInitializer(injector: Injector) {
|
||||
*/
|
||||
export function provideRouter(routes: Routes, config: ExtraOptions): any[] {
|
||||
return [
|
||||
{provide: ANALYZE_FOR_PRECOMPILE, multi: true, useValue: routes},
|
||||
{provide: ROUTES, useExisting: ROUTER_CONFIG}, {provide: ROUTER_CONFIG, useValue: routes},
|
||||
|
||||
{provide: ROUTER_CONFIGURATION, useValue: config}, Location,
|
||||
@ -125,7 +126,10 @@ export function provideRouter(routes: Routes, config: ExtraOptions): any[] {
|
||||
* @experimental
|
||||
*/
|
||||
export function provideRoutes(routes: Routes): any {
|
||||
return {provide: ROUTES, useValue: routes};
|
||||
return [
|
||||
{provide: ANALYZE_FOR_PRECOMPILE, multi: true, useValue: routes},
|
||||
{provide: ROUTES, useValue: routes}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -74,15 +74,12 @@ export class RouterOutlet {
|
||||
}
|
||||
} catch (e) {
|
||||
if (!(e instanceof NoComponentFactoryError)) throw e;
|
||||
|
||||
// TODO: vsavkin uncomment this once ComponentResolver is deprecated
|
||||
// const componentName = component ? component.name : null;
|
||||
// console.warn(
|
||||
// `'${componentName}' not found in precompile array. To ensure all components referred
|
||||
// to by the Routes are compiled, you must add '${componentName}' to the
|
||||
// 'precompile' array of your application component. This will be required in a future
|
||||
// release of the router.`);
|
||||
|
||||
const componentName = component ? component.name : null;
|
||||
console.warn(
|
||||
`'${componentName}' not found in precompile array. To ensure all components referred
|
||||
to by the Routes are compiled, you must add '${componentName}' to the
|
||||
'precompile' array of your application component. This will be required in a future
|
||||
release of the router.`);
|
||||
factory = snapshot._resolvedComponentFactory;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user