Introduces the new `ANALYZE_FOR_PRECOMPILE` token. This token can be used to create a virtual provider that will populate the `precompile` fields of components and app modules based on its `useValue`. All components that are referenced in the `useValue` value (either directly or in a nested array or map) will be added to the `precompile` property. closes #9874 related to #9726
		
			
				
	
	
		
			34 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
/**
 | 
						|
 * @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
 | 
						|
 */
 | 
						|
 | 
						|
import './init';
 | 
						|
 | 
						|
import {BasicComp} from '../src/basic';
 | 
						|
import {CompWithAnalyzePrecompileProvider, CompWithPrecompile} from '../src/precompile';
 | 
						|
 | 
						|
import {createComponent} from './util';
 | 
						|
 | 
						|
describe('content projection', () => {
 | 
						|
  it('should support precompile in components', () => {
 | 
						|
    var compFixture = createComponent(CompWithPrecompile);
 | 
						|
    var cf = compFixture.componentInstance.cfr.resolveComponentFactory(BasicComp);
 | 
						|
    expect(cf.componentType).toBe(BasicComp);
 | 
						|
  });
 | 
						|
 | 
						|
  it('should support precompile via the ANALYZE_FOR_PRECOMPILE provider and function providers in components',
 | 
						|
     () => {
 | 
						|
       const compFixture = createComponent(CompWithAnalyzePrecompileProvider);
 | 
						|
       const cf = compFixture.componentInstance.cfr.resolveComponentFactory(BasicComp);
 | 
						|
       expect(cf.componentType).toBe(BasicComp);
 | 
						|
       // check that the function call that created the provider for ANALYZE_FOR_PRECOMPILE worked.
 | 
						|
       expect(compFixture.componentInstance.providedValue).toEqual([
 | 
						|
         {a: 'b', component: BasicComp}
 | 
						|
       ]);
 | 
						|
     });
 | 
						|
});
 |