construct plugins just before using them

The common plugins includes the tsetse plugin, which grabs
the Program's TypeChecker as part of its construction, which
causes TS to do a bunch of work.

By moving the plugin construction here, that work happens in
the code above (where we explicitly ask TS for diagnostics),
which makes perf trace accounting for type checking more
accurate.

PiperOrigin-RevId: 295773738
diff --git a/internal/tsc_wrapped/tsc_wrapped.ts b/internal/tsc_wrapped/tsc_wrapped.ts
index 659a91a..442ce6f 100644
--- a/internal/tsc_wrapped/tsc_wrapped.ts
+++ b/internal/tsc_wrapped/tsc_wrapped.ts
@@ -64,9 +64,6 @@
     options: ts.CompilerOptions, bazelOpts: BazelOptions, program: ts.Program,
     disabledTsetseRules: string[], angularPlugin?: TscPlugin,
     plugins: DiagnosticPlugin[] = []): ts.Diagnostic[] {
-  // Install extra diagnostic plugins
-  plugins.push(
-      ...getCommonPlugins(options, bazelOpts, program, disabledTsetseRules));
   if (angularPlugin) {
     program = angularPlugin.wrap(program);
   }
@@ -94,6 +91,10 @@
       });
       perfTrace.snapshotMemoryUsage();
     }
+
+    // Install extra diagnostic plugins
+    plugins.push(
+        ...getCommonPlugins(options, bazelOpts, program, disabledTsetseRules));
     for (const plugin of plugins) {
       perfTrace.wrap(`${plugin.name} diagnostics`, () => {
         for (const sf of sourceFilesToCheck) {