From 984abc442ae9e7c4bc3a54c0f95eb72a48cc087d Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Fri, 1 Aug 2025 13:35:48 -0400 Subject: [PATCH] refactor(@angular/cli): remove unused load ESM helper The `loadEsmModule` helper utility function is no longer used within the `@angular/cli` package and can be removed. --- .../angular/cli/src/utilities/load-esm.ts | 33 ------------------- 1 file changed, 33 deletions(-) delete mode 100644 packages/angular/cli/src/utilities/load-esm.ts diff --git a/packages/angular/cli/src/utilities/load-esm.ts b/packages/angular/cli/src/utilities/load-esm.ts deleted file mode 100644 index 6a6220f66288..000000000000 --- a/packages/angular/cli/src/utilities/load-esm.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @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.dev/license - */ - -/** - * Lazily compiled dynamic import loader function. - */ -let load: ((modulePath: string | URL) => Promise) | undefined; - -/** - * 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 - * this, a Function constructor is used to prevent TypeScript from changing the dynamic import. - * Once TypeScript provides support for keeping the dynamic import this workaround can - * be dropped. - * - * @param modulePath The path of the module to load. - * @returns A Promise that resolves to the dynamically imported module. - */ -export function loadEsmModule(modulePath: string | URL): Promise { - load ??= new Function('modulePath', `return import(modulePath);`) as Exclude< - typeof load, - undefined - >; - - return load(modulePath); -}