hunk.code_window:  * found in the LICENSE file at https://angular.io/license
    */
   /**
    * This uses a dynamic import to load a module which may be ESM.
    * CommonJS code can load ESM code via a dynamic import. Unfortunately, TypeScript
    * will currently, unconditionally downlevel dynamic import into a require call.
  
hunk.labels: keep keep add keep keep keep keep
hunk.after_edit: /**
    * Lazily compiled dynamic import loader function.
    */
   let load: (<T>(modulePath: string | URL) => Promise<T>) | undefined;
  
hunk.file_path: packages/angular_devkit/build_angular/src/utils/load-esm.ts
hunk.type: add
file: import { assertIsError } from '../../../utils/utils';
  import { expectFileToMatch, rimraf } from '../../../utils/fs';
  import { uninstallPackage } from '../../../utils/packages';
  import { ng } from '../../../utils/process';
  import { isPrereleaseCli } from '../../../utils/project';
  
  export default async function () {
    // forcibly remove in case another test doesn't clean itself up
    await rimraf('node_modules/@angular/material');
  
    const tag = (await isPrereleaseCli()) ? '@next' : '';
  
    try {
      await ng('add', `@angular/material${tag}`, '--unknown', '--skip-confirmation');
    } catch (error) {
      assertIsError(error);
      if (!(error as Error).message.includes(`Unknown option: '--unknown'`)) {
        throw error;
      }
    }
  
    await ng(
      'add',
      `@angular/material${tag}`,
      '--theme',
      'custom',
      '--verbose',
      '--skip-confirmation',
    );
    await expectFileToMatch('package.json', /@angular\/material/);
  
    // Clean up existing cdk package
    // Not doing so can cause adding material to fail if an incompatible cdk is present
    await uninstallPackage('@angular/cdk');
  }
  