@mikro-orm/core 7.0.0-dev.15 → 7.0.0-dev.17

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
3
  "type": "module",
4
- "version": "7.0.0-dev.15",
4
+ "version": "7.0.0-dev.17",
5
5
  "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.",
6
6
  "exports": {
7
7
  "./package.json": "./package.json",
@@ -56,7 +56,7 @@
56
56
  "dotenv": "16.5.0",
57
57
  "esprima": "4.0.1",
58
58
  "globby": "11.1.0",
59
- "mikro-orm": "7.0.0-dev.15",
59
+ "mikro-orm": "7.0.0-dev.17",
60
60
  "reflect-metadata": "0.2.2"
61
61
  }
62
62
  }
package/utils/Utils.d.ts CHANGED
@@ -230,6 +230,12 @@ export declare class Utils {
230
230
  * @param [from] Location to start the node resolution
231
231
  */
232
232
  static requireFrom<T extends Dictionary>(id: string, from?: string): T;
233
+ /**
234
+ * Resolve path to a module.
235
+ * @param id The module to require
236
+ * @param [from] Location to start the node resolution
237
+ */
238
+ static resolveModulePath(id: string, from?: string): string;
233
239
  static dynamicImport<T = any>(id: string): Promise<T>;
234
240
  static setDynamicImportProvider(provider: (id: string) => Promise<unknown>): void;
235
241
  static ensureDir(path: string): void;
package/utils/Utils.js CHANGED
@@ -868,6 +868,21 @@ export class Utils {
868
868
  }
869
869
  return createRequire(resolve(from))(id);
870
870
  }
871
+ /**
872
+ * Resolve path to a module.
873
+ * @param id The module to require
874
+ * @param [from] Location to start the node resolution
875
+ */
876
+ static resolveModulePath(id, from = process.cwd()) {
877
+ if (!extname(from)) {
878
+ from = join(from, '__fake.js');
879
+ }
880
+ const path = Utils.normalizePath(createRequire(resolve(from)).resolve(id));
881
+ const parts = path.split('/');
882
+ const idx = parts.lastIndexOf(id) + 1;
883
+ parts.splice(idx, parts.length - idx);
884
+ return parts.join('/');
885
+ }
871
886
  static async dynamicImport(id) {
872
887
  /* v8 ignore next 7 */
873
888
  if (platform() === 'win32') {