function augmentAppModuleRule()

in modules/common/schematics/ng-add/index.ts [179:224]


function augmentAppModuleRule(
  project: ProjectDefinition,
  buildTarget: TargetDefinition,
  options: NgAddOptions,
): Rule {
  return (host: Tree) => {
    const bootstrapModuleRelativePath = findBootstrapModulePath(
      host,
      buildTarget.options.main as string,
    );
    const bootstrapModulePath = normalize(
      `/${project.sourceRoot}/${bootstrapModuleRelativePath}.ts`,
    );

    // Add BrowserModule.withServerTransition()
    const browserModuleImport = findBrowserModuleImport(host, bootstrapModulePath);
    const transitionCall = `.withServerTransition({ appId: '${options.appId}' })`;
    const position = browserModuleImport.pos + browserModuleImport.getFullText().length;
    const transitionCallChange = new InsertChange(bootstrapModulePath, position, transitionCall);

    const transitionCallRecorder = host.beginUpdate(bootstrapModulePath);
    transitionCallRecorder.insertLeft(transitionCallChange.pos, transitionCallChange.toAdd);
    host.commitUpdate(transitionCallRecorder);

    // Add @nguniversal/common/clover
    let changes = addImportToModule(
      getSourceFile(host, bootstrapModulePath),
      bootstrapModulePath,
      'RendererModule.forRoot()',
      '@nguniversal/common/clover',
    );
    let recorder = host.beginUpdate(bootstrapModulePath);
    applyToUpdateRecorder(recorder, changes);
    host.commitUpdate(recorder);

    changes = addImportToModule(
      getSourceFile(host, bootstrapModulePath),
      bootstrapModulePath,
      'TransferHttpCacheModule',
      '@nguniversal/common/clover',
    );
    recorder = host.beginUpdate(bootstrapModulePath);
    applyToUpdateRecorder(recorder, changes);
    host.commitUpdate(recorder);
  };
}