@mikro-orm/cli 7.2.0-dev.17 → 7.2.0-dev.19

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.
Files changed (2) hide show
  1. package/CLIHelper.js +19 -1
  2. package/package.json +3 -3
package/CLIHelper.js CHANGED
@@ -288,6 +288,7 @@ export class CLIHelper {
288
288
  jiti: { cjs: 'jiti/register', cb: setEsmImportProvider },
289
289
  tsimp: { cjs: 'tsimp/import', cb: setEsmImportProvider },
290
290
  };
291
+ const errors = [];
291
292
  for (const loader of Utils.keys(loaders)) {
292
293
  if (explicitLoader !== 'auto' && loader !== explicitLoader) {
293
294
  continue;
@@ -295,13 +296,30 @@ export class CLIHelper {
295
296
  const { esm, cjs, cb } = loaders[loader];
296
297
  const isEsm = this.isESM();
297
298
  const module = isEsm && esm ? esm : cjs;
298
- const mod = await Utils.tryImport({ module });
299
+ let mod;
300
+ try {
301
+ mod = await Utils.tryImport({ module });
302
+ }
303
+ catch (e) {
304
+ const error = new Error(`Failed to load TypeScript loader \`${loader}\` (${module}): ${e.message}`, {
305
+ cause: e,
306
+ });
307
+ if (explicitLoader !== 'auto') {
308
+ throw error;
309
+ }
310
+ errors.push(error);
311
+ continue;
312
+ }
299
313
  if (mod) {
300
314
  cb?.(mod);
301
315
  process.env.MIKRO_ORM_CLI_TS_LOADER = loader;
302
316
  return true;
303
317
  }
304
318
  }
319
+ // a loader that is installed but broken is a real problem, not a missing dependency
320
+ if (errors.length > 0) {
321
+ throw new Error(errors.map(e => e.message).join('\n'), { cause: errors[0] });
322
+ }
305
323
  // eslint-disable-next-line no-console
306
324
  console.warn('Neither `oxc`, `swc`, `tsx`, `jiti` nor `tsimp` found in the project dependencies, support for working with TypeScript files might not work. To use `oxc`, install `@oxc-node/core`. To use `swc`, install both `@swc-node/register` and `@swc/core`.');
307
325
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/cli",
3
- "version": "7.2.0-dev.17",
3
+ "version": "7.2.0-dev.19",
4
4
  "description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
5
5
  "keywords": [
6
6
  "data-mapper",
@@ -50,8 +50,8 @@
50
50
  "copy": "node ../../scripts/copy.mjs"
51
51
  },
52
52
  "dependencies": {
53
- "@mikro-orm/core": "7.2.0-dev.17",
54
- "mikro-orm": "7.2.0-dev.17",
53
+ "@mikro-orm/core": "7.2.0-dev.19",
54
+ "mikro-orm": "7.2.0-dev.19",
55
55
  "yargs": "17.7.2"
56
56
  },
57
57
  "engines": {