UNPKG

1.58 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8/// <amd-module name="@angular/core/schematics/utils/load_esm" />
9/// <reference types="node" />
10import { URL } from 'url';
11/**
12 * This uses a dynamic import to load a module which may be ESM.
13 * CommonJS code can load ESM code via a dynamic import. Unfortunately, TypeScript
14 * will currently, unconditionally downlevel dynamic import into a require call.
15 * require calls cannot load ESM code and will result in a runtime error. To workaround
16 * this, a Function constructor is used to prevent TypeScript from changing the dynamic import.
17 * Once TypeScript provides support for keeping the dynamic import this workaround can
18 * be dropped.
19 * This is only intended to be used with Angular framework packages.
20 *
21 * @param modulePath The path of the module to load.
22 * @returns A Promise that resolves to the dynamically imported module.
23 */
24export declare function loadEsmModule<T>(modulePath: string | URL): Promise<T>;
25/**
26 * Attempt to load the new `@angular/compiler-cli/private/migrations` entry. If not yet present
27 * the previous deep imports are used to constructor an equivalent object.
28 *
29 * @returns A Promise that resolves to the dynamically imported compiler-cli private migrations
30 * entry or an equivalent object if not available.
31 */
32export declare function loadCompilerCliMigrationsModule(): Promise<typeof import('@angular/compiler-cli/private/migrations')>;