How to use the @angular/tsc-wrapped.MetadataWriterHost function in @angular/tsc-wrapped

To help you get started, we’ve selected a few @angular/tsc-wrapped examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rangle / angular-ssr / source / application / compiler / ngc / compiler.ts View on Github external
join(this.project.workingPath.toString(), relativeOutput),
      workingPath
    ].map(pathFromString);

    if (this.project.workingPath != null) {
      ts.outDir = join(this.project.workingPath.toString(), relativeOutput);
      ng.outDir = ts.outDir;
    }

    const build = new Build(this.project.basePath, outputs, roots);

    const {host, compiler} = createNgCompiler(compilerHost, program, ng, roots);

    const generatedModules = await this.generateTemplateCode(compilerHost, host, compiler, program, build);

    const metadataWriter = new MetadataWriterHost(compilerHost, ng, true);

    const canonicalSources = program.getSourceFiles().map(sf => sf.fileName).concat(generatedModules);

    const templatedProgram = createProgram(canonicalSources, ts, metadataWriter, program);

    const originalWriteFile = compilerHost.writeFile.bind(compilerHost);

    const writeFile = (filename: string, data: string, writeByteOrderMark: boolean, onError: (message: string) => void, sourceFiles: Array) => {
      build.emit(filename, sourceFiles);

      return originalWriteFile(filename, data, writeByteOrderMark, onError, sourceFiles);
    };

    const emitResult = templatedProgram.emit(undefined, writeFile);
    if (emitResult) {
      assertDiagnostics(emitResult.diagnostics);
github rangle / angular-ssr / source / application / compiler / program.ts View on Github external
private async generateTemplates(): Promise<[CompilerHost, Array]> {
    const hostContext = new NodeCompilerHostContext();

    const compiler = this.compilerFactory(hostContext);

    const cli = new NgcCliOptions({
      i18nFormat: null,
      i18nFile: null,
      locale: null,
      basePath: this.ng.basePath
    });

    const generatedModules = await this.generateTemplateCode(compiler, cli);

    const metadataWriter = new MetadataWriterHost(this.compilerHost, this.ng, true);

    return [metadataWriter, generatedModules];
  }
github rangle / angular-ssr / source / application / compiler / template.ts View on Github external
const hostContext = new NodeCompilerHostContext();

  const ngCompiler = new TranslatingCompilerHost(program, options.angular, hostContext);

  const cli = new NgcCliOptions({
    i18nFormat: null,
    i18nFile: null,
    locale: null,
    basePath: options.angular.basePath
  });

  const generator = CodeGenerator.create(options.angular, cli, program, compilerHost, hostContext, ngCompiler);

  await generator.codegen();

  const metadataWriter = new MetadataWriterHost(compilerHost, options.angular);

  metadataWriter.writeFile = compilerHost.writeFile;

  return metadataWriter;
};
github rangle / angular-ssr / source / application / compiler / compiler-ng.ts View on Github external
export const compileTemplates = async (options: CompileOptions, program: Program, compilerHost: TsCompilerHost): Promise<[TsCompilerHost, Array]> => {
  const hostContext = new NodeCompilerHostContext();

  const ngCompiler = compilerFactory(program, options.angular, hostContext);

  const cli = new NgcCliOptions({
    i18nFormat: null,
    i18nFile: null,
    locale: null,
    basePath: options.angular.basePath
  });

  const generatedModules = await generateAngularCode(program, ngCompiler, compilerHost, cli);

  const metadataWriter = new MetadataWriterHost(compilerHost, options.angular);
  metadataWriter.writeFile = compilerHost.writeFile;

  return [metadataWriter, generatedModules];
};