UNPKG

1.23 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.loadEsmModule = exports.ngCompilerCli = void 0;
4function ngCompilerCli() {
5 return loadEsmModule('@angular/compiler-cli');
6}
7exports.ngCompilerCli = ngCompilerCli;
8/**
9 * Lazily compiled dynamic import loader function.
10 */
11let load;
12/**
13 * This uses a dynamic import to load a module which may be ESM.
14 * CommonJS code can load ESM code via a dynamic import. Unfortunately, TypeScript
15 * will currently, unconditionally downlevel dynamic import into a require call.
16 * require calls cannot load ESM code and will result in a runtime error. To workaround
17 * this, a Function constructor is used to prevent TypeScript from changing the dynamic import.
18 * Once TypeScript provides support for keeping the dynamic import this workaround can
19 * be dropped.
20 *
21 * @param modulePath The path of the module to load.
22 * @returns A Promise that resolves to the dynamically imported module.
23 */
24function loadEsmModule(modulePath) {
25 load !== null && load !== void 0 ? load : (load = new Function('modulePath', `return import(modulePath);`));
26 return load(modulePath);
27}
28exports.loadEsmModule = loadEsmModule;
29//# sourceMappingURL=load-esm.js.map
\No newline at end of file