(request: JitCompilerUsageRequest)
| 21 | } |
| 22 | |
| 23 | export function getCompilerFacade(request: JitCompilerUsageRequest): CompilerFacade { |
| 24 | const globalNg: ExportedCompilerFacade = global['ng']; |
| 25 | if (globalNg && globalNg.ɵcompilerFacade) { |
| 26 | return globalNg.ɵcompilerFacade; |
| 27 | } |
| 28 | |
| 29 | if (typeof ngDevMode === 'undefined' || ngDevMode) { |
| 30 | // Log the type as an error so that a developer can easily navigate to the type from the |
| 31 | // console. |
| 32 | console.error(`JIT compilation failed for ${request.kind}`, request.type); |
| 33 | |
| 34 | let message = `The ${request.kind} '${request.type.name}' needs to be compiled using the JIT compiler, but '@angular/compiler' is not available.\n\n`; |
| 35 | if (request.usage === JitCompilerUsage.PartialDeclaration) { |
| 36 | message += `The ${request.kind} is part of a library that has been partially compiled.\n`; |
| 37 | message += `However, the Angular Linker has not processed the library such that JIT compilation is used as fallback.\n`; |
| 38 | message += '\n'; |
| 39 | message += `Ideally, the library is processed using the Angular Linker to become fully AOT compiled.\n`; |
| 40 | } else { |
| 41 | message += `JIT compilation is discouraged for production use-cases! Consider using AOT mode instead.\n`; |
| 42 | } |
| 43 | message += `Alternatively, the JIT compiler should be loaded by bootstrapping using '@angular/platform-browser-dynamic' or '@angular/platform-server',\n`; |
| 44 | message += `or manually provide the compiler with 'import "@angular/compiler";' before bootstrapping.`; |
| 45 | throw new Error(message); |
| 46 | } else { |
| 47 | throw new Error('JIT compiler unavailable'); |
| 48 | } |
| 49 | } |
no test coverage detected
searching dependent graphs…