hunk.code_window:     });
   }
   /**
    * 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.
    * require calls cannot load ESM code and will result in a runtime error. To workaround
  
hunk.labels: keep keep add keep 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/schematics_cli/bin/schematics.ts
hunk.type: add
file: /**
   * @license
   * Copyright Google LLC All Rights Reserved.
   *
   * Use of this source code is governed by an MIT-style license that can be
   * found in the LICENSE file at https://angular.io/license
   */
  
  import { appendToFile, prependToFile, replaceInFile, writeFile } from '../../utils/fs';
  import { ng } from '../../utils/process';
  import { updateJsonFile } from '../../utils/project';
  
  export default async function () {
    // Add lazy route.
    await ng('generate', 'component', 'lazy');
    await replaceInFile(
      'src/app/app.routes.ts',
      'routes: Routes = [];',
      `routes: Routes = [{path: 'lazy', loadComponent: () => import('./lazy/lazy.component').then(c => c.LazyComponent)}];`,
    );
  
    // Add lazy route e2e
    await writeFile(
      'e2e/src/app.e2e-spec.ts',
      `
       import { browser, logging, element, by } from 'protractor';
  
       describe('workspace-project App', () => {
         it('should display lazy route', async () => {
           await browser.get(browser.baseUrl + '/lazy');
           expect(await element(by.css('app-lazy p')).getText()).toEqual('lazy works!');
         });
  
         afterEach(async () => {
           // Assert that there are no errors emitted from the browser
           const logs = await browser.manage().logs().get(logging.Type.BROWSER);
           expect(logs).not.toContain(jasmine.objectContaining({
             level: logging.Level.SEVERE,
           }));
         });
       });
     `,
    );
  
    const testCases = [
      {
        aot: false,
        csp: `trusted-types angular angular#unsafe-bypass angular#unsafe-jit angular#bundler; require-trusted-types-for 'script';`,
      },
      {
        aot: true,
        csp: `trusted-types angular angular#unsafe-bypass angular#bundler; require-trusted-types-for 'script';`,
      },
    ];
  
    for (const { aot, csp } of testCases) {
      await updateJsonFile('angular.json', (json) => {
        const architect = json['projects']['test-project']['architect'];
        architect['build']['options']['aot'] = aot;
        if (!architect['serve']['options']) architect['serve']['options'] = {};
        architect['serve']['options']['headers'] = {
          'Content-Security-Policy': csp,
        };
      });
  
      try {
        await ng('e2e');
      } catch (error) {
        console.error(`Test case AOT ${aot} with CSP header ${csp} failed.`);
        throw error;
      }
    }
  }
  