@mikro-orm/core 6.4.15-dev.4 → 6.4.15-dev.6

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
- "version": "6.4.15-dev.4",
3
+ "version": "6.4.15-dev.6",
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
  "main": "index.js",
6
6
  "module": "index.mjs",
@@ -64,7 +64,7 @@
64
64
  "esprima": "4.0.1",
65
65
  "fs-extra": "11.3.0",
66
66
  "globby": "11.1.0",
67
- "mikro-orm": "6.4.15-dev.4",
67
+ "mikro-orm": "6.4.15-dev.6",
68
68
  "reflect-metadata": "0.2.2"
69
69
  }
70
70
  }
package/utils/Utils.d.ts CHANGED
@@ -228,6 +228,12 @@ export declare class Utils {
228
228
  * @param [from] Location to start the node resolution
229
229
  */
230
230
  static requireFrom<T extends Dictionary>(id: string, from?: string): T;
231
+ /**
232
+ * Resolve path to a module.
233
+ * @param id The module to require
234
+ * @param [from] Location to start the node resolution
235
+ */
236
+ static resolveModulePath(id: string, from?: string): string;
231
237
  static dynamicImport<T = any>(id: string): Promise<T>;
232
238
  static setDynamicImportProvider(provider: (id: string) => Promise<unknown>): void;
233
239
  static getORMVersion(): string;
package/utils/Utils.js CHANGED
@@ -884,6 +884,21 @@ class Utils {
884
884
  }
885
885
  return (0, node_module_1.createRequire)((0, node_path_1.resolve)(from))(id);
886
886
  }
887
+ /**
888
+ * Resolve path to a module.
889
+ * @param id The module to require
890
+ * @param [from] Location to start the node resolution
891
+ */
892
+ static resolveModulePath(id, from = process.cwd()) {
893
+ if (!(0, node_path_1.extname)(from)) {
894
+ from = (0, node_path_1.join)(from, '__fake.js');
895
+ }
896
+ const path = Utils.normalizePath((0, node_module_1.createRequire)((0, node_path_1.resolve)(from)).resolve(id));
897
+ const parts = path.split('/');
898
+ const idx = parts.lastIndexOf(id) + 1;
899
+ parts.splice(idx, parts.length - idx);
900
+ return parts.join('/');
901
+ }
887
902
  static async dynamicImport(id) {
888
903
  /* istanbul ignore next */
889
904
  if ((0, node_os_1.platform)() === 'win32') {