refactor(compiler): don’t rely on global reflector (#16832)
Using the global reflector made it impossible to compile multiple programs at the same time.
This commit is contained in:

committed by
Chuck Jazdzewski

parent
de8d7c65f2
commit
50abca4583
@ -28,7 +28,6 @@ import {ViewCompiler} from '../view_compiler/view_compiler';
|
||||
import {AotCompiler} from './compiler';
|
||||
import {AotCompilerHost} from './compiler_host';
|
||||
import {AotCompilerOptions} from './compiler_options';
|
||||
import {StaticAndDynamicReflectionCapabilities} from './static_reflection_capabilities';
|
||||
import {StaticReflector} from './static_reflector';
|
||||
import {StaticSymbol, StaticSymbolCache} from './static_symbol';
|
||||
import {StaticSymbolResolver} from './static_symbol_resolver';
|
||||
@ -47,7 +46,6 @@ export function createAotCompiler(compilerHost: AotCompilerHost, options: AotCom
|
||||
const summaryResolver = new AotSummaryResolver(compilerHost, symbolCache);
|
||||
const symbolResolver = new StaticSymbolResolver(compilerHost, symbolCache, summaryResolver);
|
||||
const staticReflector = new StaticReflector(summaryResolver, symbolResolver);
|
||||
StaticAndDynamicReflectionCapabilities.install(staticReflector);
|
||||
const console = new Console();
|
||||
const htmlParser = new I18NHtmlParser(
|
||||
new HtmlParser(), translations, options.i18nFormat, options.missingTranslation, console);
|
||||
@ -61,17 +59,17 @@ export function createAotCompiler(compilerHost: AotCompilerHost, options: AotCom
|
||||
{get: (url: string) => compilerHost.loadResource(url)}, urlResolver, htmlParser, config);
|
||||
const expressionParser = new Parser(new Lexer());
|
||||
const elementSchemaRegistry = new DomElementSchemaRegistry();
|
||||
const tmplParser =
|
||||
new TemplateParser(config, expressionParser, elementSchemaRegistry, htmlParser, console, []);
|
||||
const tmplParser = new TemplateParser(
|
||||
config, staticReflector, expressionParser, elementSchemaRegistry, htmlParser, console, []);
|
||||
const resolver = new CompileMetadataResolver(
|
||||
config, new NgModuleResolver(staticReflector), new DirectiveResolver(staticReflector),
|
||||
new PipeResolver(staticReflector), summaryResolver, elementSchemaRegistry, normalizer,
|
||||
console, symbolCache, staticReflector);
|
||||
// TODO(vicb): do not pass options.i18nFormat here
|
||||
const viewCompiler = new ViewCompiler(config, elementSchemaRegistry);
|
||||
const viewCompiler = new ViewCompiler(config, staticReflector, elementSchemaRegistry);
|
||||
const compiler = new AotCompiler(
|
||||
config, compilerHost, resolver, tmplParser, new StyleCompiler(urlResolver), viewCompiler,
|
||||
new NgModuleCompiler(), new TypeScriptEmitter(), summaryResolver, options.locale || null,
|
||||
options.i18nFormat || null, symbolResolver);
|
||||
config, compilerHost, staticReflector, resolver, tmplParser, new StyleCompiler(urlResolver),
|
||||
viewCompiler, new NgModuleCompiler(staticReflector), new TypeScriptEmitter(), summaryResolver,
|
||||
options.locale || null, options.i18nFormat || null, symbolResolver);
|
||||
return {compiler, reflector: staticReflector};
|
||||
}
|
||||
|
Reference in New Issue
Block a user