* Create an `NgCompilerHost` from a delegate host, an array of input filenames, and the full set * of TypeScript and Angular compiler options.
(
delegate: ts.CompilerHost,
inputFiles: ReadonlyArray<string>,
options: NgCompilerOptions,
oldProgram: ts.Program | null,
)
| 197 | * of TypeScript and Angular compiler options. |
| 198 | */ |
| 199 | static wrap( |
| 200 | delegate: ts.CompilerHost, |
| 201 | inputFiles: ReadonlyArray<string>, |
| 202 | options: NgCompilerOptions, |
| 203 | oldProgram: ts.Program | null, |
| 204 | ): NgCompilerHost { |
| 205 | const topLevelShimGenerators: TopLevelShimGenerator[] = []; |
| 206 | const perFileShimGenerators: PerFileShimGenerator[] = []; |
| 207 | |
| 208 | const rootDirs = getRootDirs(delegate, options as ts.CompilerOptions); |
| 209 | |
| 210 | perFileShimGenerators.push(new TypeCheckShimGenerator()); |
| 211 | |
| 212 | let diagnostics: ts.Diagnostic[] = []; |
| 213 | |
| 214 | const normalizedTsInputFiles: AbsoluteFsPath[] = []; |
| 215 | for (const inputFile of inputFiles) { |
| 216 | if (!isNonDeclarationTsPath(inputFile)) { |
| 217 | continue; |
| 218 | } |
| 219 | normalizedTsInputFiles.push(resolve(inputFile)); |
| 220 | } |
| 221 | |
| 222 | let entryPoint: AbsoluteFsPath | null = null; |
| 223 | if (options.flatModuleOutFile != null && options.flatModuleOutFile !== '') { |
| 224 | entryPoint = findFlatIndexEntryPoint(normalizedTsInputFiles); |
| 225 | if (entryPoint === null) { |
| 226 | // This error message talks specifically about having a single .ts file in "files". However |
| 227 | // the actual logic is a bit more permissive. If a single file exists, that will be taken, |
| 228 | // otherwise the highest level (shortest path) "index.ts" file will be used as the flat |
| 229 | // module entry point instead. If neither of these conditions apply, the error below is |
| 230 | // given. |
| 231 | // |
| 232 | // The user is not informed about the "index.ts" option as this behavior is deprecated - |
| 233 | // an explicit entrypoint should always be specified. |
| 234 | diagnostics.push({ |
| 235 | category: ts.DiagnosticCategory.Error, |
| 236 | code: ngErrorCode(ErrorCode.CONFIG_FLAT_MODULE_NO_INDEX), |
| 237 | file: undefined, |
| 238 | start: undefined, |
| 239 | length: undefined, |
| 240 | messageText: |
| 241 | 'Angular compiler option "flatModuleOutFile" requires one and only one .ts file in the "files" field.', |
| 242 | }); |
| 243 | } else { |
| 244 | const flatModuleId = options.flatModuleId || null; |
| 245 | const flatModuleOutFile = normalizeSeparators(options.flatModuleOutFile); |
| 246 | const flatIndexGenerator = new FlatIndexGenerator( |
| 247 | entryPoint, |
| 248 | flatModuleOutFile, |
| 249 | flatModuleId, |
| 250 | ); |
| 251 | topLevelShimGenerators.push(flatIndexGenerator); |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | const shimAdapter = new ShimAdapter( |
| 256 | delegate, |
nothing calls this directly
no test coverage detected