@angular-devkit/schematics-cli 17.0.0-rc.1 → 17.0.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,3 +14,16 @@ export interface MainOptions {
14
14
  stderr?: ProcessOutput;
15
15
  }
16
16
  export declare function main({ args, stdout, stderr, }: MainOptions): Promise<0 | 1>;
17
+ /**
18
+ * This uses a dynamic import to load a module which may be ESM.
19
+ * CommonJS code can load ESM code via a dynamic import. Unfortunately, TypeScript
20
+ * will currently, unconditionally downlevel dynamic import into a require call.
21
+ * require calls cannot load ESM code and will result in a runtime error. To workaround
22
+ * this, a Function constructor is used to prevent TypeScript from changing the dynamic import.
23
+ * Once TypeScript provides support for keeping the dynamic import this workaround can
24
+ * be dropped.
25
+ *
26
+ * @param modulePath The path of the module to load.
27
+ * @returns A Promise that resolves to the dynamically imported module.
28
+ */
29
+ export declare function loadEsmModule<T>(modulePath: string | URL): Promise<T>;
package/bin/schematics.js CHANGED
@@ -31,7 +31,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
31
31
  return result;
32
32
  };
33
33
  Object.defineProperty(exports, "__esModule", { value: true });
34
- exports.main = void 0;
34
+ exports.loadEsmModule = exports.main = void 0;
35
35
  // symbol polyfill must go first
36
36
  require("symbol-observable");
37
37
  const core_1 = require("@angular-devkit/core");
@@ -40,7 +40,6 @@ const schematics_1 = require("@angular-devkit/schematics");
40
40
  const tools_1 = require("@angular-devkit/schematics/tools");
41
41
  const ansiColors = __importStar(require("ansi-colors"));
42
42
  const fs_1 = require("fs");
43
- const inquirer = __importStar(require("inquirer"));
44
43
  const path = __importStar(require("path"));
45
44
  const yargs_parser_1 = __importStar(require("yargs-parser"));
46
45
  /**
@@ -81,7 +80,7 @@ function _listSchematics(workflow, collectionName, logger) {
81
80
  return 0;
82
81
  }
83
82
  function _createPromptProvider() {
84
- return (definitions) => {
83
+ return async (definitions) => {
85
84
  const questions = definitions.map((definition) => {
86
85
  const question = {
87
86
  name: definition.id,
@@ -140,6 +139,7 @@ function _createPromptProvider() {
140
139
  return { ...question, type: definition.type };
141
140
  }
142
141
  });
142
+ const { default: inquirer } = await loadEsmModule('inquirer');
143
143
  return inquirer.prompt(questions);
144
144
  };
145
145
  }
@@ -429,3 +429,19 @@ if (require.main === module) {
429
429
  throw e;
430
430
  });
431
431
  }
432
+ /**
433
+ * This uses a dynamic import to load a module which may be ESM.
434
+ * CommonJS code can load ESM code via a dynamic import. Unfortunately, TypeScript
435
+ * will currently, unconditionally downlevel dynamic import into a require call.
436
+ * require calls cannot load ESM code and will result in a runtime error. To workaround
437
+ * this, a Function constructor is used to prevent TypeScript from changing the dynamic import.
438
+ * Once TypeScript provides support for keeping the dynamic import this workaround can
439
+ * be dropped.
440
+ *
441
+ * @param modulePath The path of the module to load.
442
+ * @returns A Promise that resolves to the dynamically imported module.
443
+ */
444
+ function loadEsmModule(modulePath) {
445
+ return new Function('modulePath', `return import(modulePath);`)(modulePath);
446
+ }
447
+ exports.loadEsmModule = loadEsmModule;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular-devkit/schematics-cli",
3
- "version": "17.0.0-rc.1",
3
+ "version": "17.0.0-rc.2",
4
4
  "description": "Angular Schematics - CLI",
5
5
  "homepage": "https://github.com/angular/angular-cli",
6
6
  "bin": {
@@ -21,10 +21,10 @@
21
21
  ],
22
22
  "schematics": "./collection.json",
23
23
  "dependencies": {
24
- "@angular-devkit/core": "17.0.0-rc.1",
25
- "@angular-devkit/schematics": "17.0.0-rc.1",
24
+ "@angular-devkit/core": "17.0.0-rc.2",
25
+ "@angular-devkit/schematics": "17.0.0-rc.2",
26
26
  "ansi-colors": "4.1.3",
27
- "inquirer": "8.2.6",
27
+ "inquirer": "9.2.11",
28
28
  "symbol-observable": "4.0.0",
29
29
  "yargs-parser": "21.1.1"
30
30
  },