| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ebdf495 commit 482f6d8
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -75,6 +75,7 @@ export function createCompilerPlugin( | |||
| 75 | 75 | // eslint-disable-next-line max-lines-per-function | |
| 76 | 76 | async setup(build: PluginBuild): Promise<void> { | |
| 77 | 77 | let setupWarnings: PartialMessage[] | undefined = []; | |
| 78 | + let diagnosticsPromise: ReturnType<AngularCompilation['diagnoseFiles']> | undefined; | ||
| 78 | 79 | const preserveSymlinks = build.initialOptions.preserveSymlinks; | |
| 79 | 80 | ||
| 80 | 81 | // Initialize a worker pool for JavaScript transformations. | |
@@ -157,6 +158,7 @@ export function createCompilerPlugin( | |||
| 157 | 158 | ||
| 158 | 159 | // eslint-disable-next-line max-lines-per-function | |
| 159 | 160 | build.onStart(async () => { | |
| 161 | + hasCompilationErrors = true; | ||
| 160 | 162 | await initializeHash(); | |
| 161 | 163 | ||
| 162 | 164 | const result: OnStartResult = { | |
@@ -400,16 +402,22 @@ export function createCompilerPlugin( | |||
| 400 | 402 | ], | |
| 401 | 403 | }); | |
| 402 | 404 | } | |
| 403 | - } | ||
| 404 | 405 | ||
| 405 | - const diagnostics = await compilation.diagnoseFiles( | ||
| 406 | - useTypeChecking ? DiagnosticModes.All : DiagnosticModes.All & ~DiagnosticModes.Semantic, | ||
| 407 | - ); | ||
| 408 | - if (diagnostics.errors?.length) { | ||
| 409 | - (result.errors ??= []).push(...diagnostics.errors); | ||
| 410 | - } | ||
| 411 | - if (diagnostics.warnings?.length) { | ||
| 412 | - (result.warnings ??= []).push(...diagnostics.warnings); | ||
| 406 | + const diagnosticModes = useTypeChecking | ||
| 407 | + ? DiagnosticModes.All | ||
| 408 | + : DiagnosticModes.All & ~DiagnosticModes.Semantic; | ||
| 409 | + diagnosticsPromise = compilation.diagnoseFiles(diagnosticModes).catch((error) => ({ | ||
| 410 | + errors: [ | ||
| 411 | + { | ||
| 412 | + text: 'Angular compilation diagnostics failed.', | ||
| 413 | + notes: [ | ||
| 414 | + { | ||
| 415 | + text: error instanceof Error ? (error.stack ?? error.message) : String(error), | ||
| 416 | + }, | ||
| 417 | + ], | ||
| 418 | + }, | ||
| 419 | + ], | ||
| 420 | + })); | ||
| 413 | 421 | } | |
| 414 | 422 | ||
| 415 | 423 | // Add errors from failed additional results. | |
@@ -617,7 +625,7 @@ export function createCompilerPlugin( | |||
| 617 | 625 | ); | |
| 618 | 626 | } | |
| 619 | 627 | ||
| 620 | - build.onEnd((result) => { | ||
| 628 | + build.onEnd(async (result) => { | ||
| 621 | 629 | // Ensure other compilations are unblocked if the main compilation throws during start | |
| 622 | 630 | if (angularCompilationContext.isPrimary()) { | |
| 623 | 631 | angularCompilationContext.markAsReady(hasCompilationErrors); | |
@@ -640,6 +648,20 @@ export function createCompilerPlugin( | |||
| 640 | 648 | } | |
| 641 | 649 | ||
| 642 | 650 | logCumulativeDurations(); | |
| 651 | + | ||
| 652 | + if (diagnosticsPromise) { | ||
| 653 | + try { | ||
| 654 | + const diagnostics = await diagnosticsPromise; | ||
| 655 | + const errors = diagnostics.errors?.length ? diagnostics.errors : undefined; | ||
| 656 | + const warnings = diagnostics.warnings?.length ? diagnostics.warnings : undefined; | ||
| 657 | + | ||
| 658 | + if (errors || warnings) { | ||
| 659 | + return { errors, warnings }; | ||
| 660 | + } | ||
| 661 | + } finally { | ||
| 662 | + diagnosticsPromise = undefined; | ||
| 663 | + } | ||
| 664 | + } | ||
| 643 | 665 | }); | |
| 644 | 666 | ||
| 645 | 667 | build.onDispose(() => { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments