All files / builder/util load_esm.ts

83.33% Statements 5/6
50% Branches 1/2
100% Functions 1/1
83.33% Lines 5/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21  2x             2x     2x       1x   1x      
async function loadEsmModule<T>(modulePath: string): Promise<T> {
  const namespaceObject = await new Function(
    'modulePath',
    `return import(modulePath);`
  )(modulePath);
 
  // If it is not ESM then the values needed will be stored in the `default` property.
  // TODO_ESM: This can be removed once `@angular/*` packages are ESM only.
  Iif (namespaceObject.default) {
    return namespaceObject.default;
  } else {
    return namespaceObject;
  }
}
 
export const angularCompilerPromise =
  loadEsmModule<typeof import('@angular/compiler')>('@angular/compiler');
export const angularCompilerCliPromise = loadEsmModule<
  typeof import('@angular/compiler-cli')
>('@angular/compiler-cli');