@mikro-orm/core 7.0.0-dev.28 → 7.0.0-dev.29

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/MikroORM.js CHANGED
@@ -35,7 +35,6 @@ export class MikroORM {
35
35
  }
36
36
  }
37
37
  options = Utils.mergeConfig(options, env);
38
- ConfigurationLoader.commonJSCompat(options);
39
38
  if ('DRIVER' in this && !options.driver) {
40
39
  options.driver = this.DRIVER;
41
40
  }
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.28",
4
+ "version": "7.0.0-dev.29",
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",
@@ -54,7 +54,7 @@
54
54
  "dataloader": "2.2.3",
55
55
  "dotenv": "17.2.3",
56
56
  "esprima": "4.0.1",
57
- "mikro-orm": "7.0.0-dev.28",
57
+ "mikro-orm": "7.0.0-dev.29",
58
58
  "reflect-metadata": "0.2.2",
59
59
  "tinyglobby": "0.2.13"
60
60
  }
@@ -146,7 +146,6 @@ export declare class Configuration<D extends IDatabaseDriver = IDatabaseDriver,
146
146
  fileName: (className: string) => string;
147
147
  };
148
148
  preferReadReplicas: true;
149
- dynamicImportProvider: (id: string) => Promise<any>;
150
149
  };
151
150
  private readonly options;
152
151
  private readonly logger;
@@ -414,6 +413,5 @@ export interface MikroORMOptions<D extends IDatabaseDriver = IDatabaseDriver, EM
414
413
  seeder: SeederOptions;
415
414
  preferReadReplicas: boolean;
416
415
  hashAlgorithm: 'md5' | 'sha256';
417
- dynamicImportProvider: (id: string) => Promise<unknown>;
418
416
  }
419
417
  export type Options<D extends IDatabaseDriver = IDatabaseDriver, EM extends D[typeof EntityManagerType] & EntityManager = D[typeof EntityManagerType] & EntityManager> = Pick<MikroORMOptions<D, EM>, Exclude<keyof MikroORMOptions<D, EM>, keyof typeof Configuration.DEFAULTS>> & Partial<MikroORMOptions<D, EM>>;
@@ -134,7 +134,6 @@ export class Configuration {
134
134
  fileName: (className) => className,
135
135
  },
136
136
  preferReadReplicas: true,
137
- dynamicImportProvider: /* v8 ignore next */ (id) => import(id),
138
137
  };
139
138
  options;
140
139
  logger;
@@ -143,9 +142,6 @@ export class Configuration {
143
142
  cache = new Map();
144
143
  extensions = new Map();
145
144
  constructor(options, validate = true) {
146
- if (options.dynamicImportProvider) {
147
- Utils.setDynamicImportProvider(options.dynamicImportProvider);
148
- }
149
145
  this.options = Utils.mergeConfig({}, Configuration.DEFAULTS, options);
150
146
  this.options.baseDir = Utils.absolutePath(this.options.baseDir);
151
147
  this.options.preferTs ??= options.preferTs;
@@ -40,8 +40,6 @@ export declare class ConfigurationLoader {
40
40
  static loadEnvironmentVars<D extends IDatabaseDriver>(): Promise<Partial<Options<D>>>;
41
41
  static loadEnvironmentVarsSync<D extends IDatabaseDriver>(): Partial<Options<D>>;
42
42
  static getORMPackages(): Set<string>;
43
- /** @internal */
44
- static commonJSCompat(options: Partial<Options>): void;
45
43
  static getORMPackageVersion(name: string): string | undefined;
46
44
  static checkPackageVersion(): string;
47
45
  }
@@ -1,7 +1,5 @@
1
1
  import dotenv from 'dotenv';
2
2
  import { realpathSync } from 'node:fs';
3
- import { platform } from 'node:os';
4
- import { fileURLToPath } from 'node:url';
5
3
  import { colors } from '../logging/colors.js';
6
4
  import { Configuration } from './Configuration.js';
7
5
  import { Utils } from './Utils.js';
@@ -12,7 +10,6 @@ export class ConfigurationLoader {
12
10
  static async getConfiguration(contextName = 'default', paths = ConfigurationLoader.getConfigPaths(), options = {}) {
13
11
  // Backwards compatibility layer
14
12
  if (typeof contextName === 'boolean' || !Array.isArray(paths)) {
15
- this.commonJSCompat(options);
16
13
  this.registerDotenv(options);
17
14
  const configPathFromArg = ConfigurationLoader.configPathsFromArg();
18
15
  const configPaths = configPathFromArg ?? (Array.isArray(paths) ? paths : ConfigurationLoader.getConfigPaths());
@@ -300,25 +297,6 @@ export class ConfigurationLoader {
300
297
  ...Object.keys(pkg.devDependencies ?? {}),
301
298
  ]);
302
299
  }
303
- /** @internal */
304
- static commonJSCompat(options) {
305
- if (this.isESM()) {
306
- return;
307
- }
308
- /* v8 ignore next 11 */
309
- options.dynamicImportProvider ??= id => {
310
- if (platform() === 'win32') {
311
- try {
312
- id = fileURLToPath(id);
313
- }
314
- catch {
315
- // ignore
316
- }
317
- }
318
- return Utils.requireFrom(id);
319
- };
320
- Utils.setDynamicImportProvider(options.dynamicImportProvider);
321
- }
322
300
  static getORMPackageVersion(name) {
323
301
  try {
324
302
  const pkg = Utils.requireFrom(`${name}/package.json`);
package/utils/Utils.d.ts CHANGED
@@ -15,7 +15,6 @@ export declare function equals(a: any, b: any): boolean;
15
15
  export declare function parseJsonSafe<T = unknown>(value: unknown): T;
16
16
  export declare class Utils {
17
17
  static readonly PK_SEPARATOR = "~~~";
18
- static dynamicImportProvider: (id: string) => Promise<any>;
19
18
  /**
20
19
  * Checks if the argument is not undefined
21
20
  */
@@ -237,7 +236,6 @@ export declare class Utils {
237
236
  */
238
237
  static resolveModulePath(id: string, from?: string): string;
239
238
  static dynamicImport<T = any>(id: string): Promise<T>;
240
- static setDynamicImportProvider(provider: (id: string) => Promise<unknown>): void;
241
239
  static ensureDir(path: string): void;
242
240
  static pathExistsSync(path: string): boolean;
243
241
  static readJSONSync(path: string): Dictionary;
package/utils/Utils.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { createRequire } from 'node:module';
2
2
  import { glob, isDynamicPattern } from 'tinyglobby';
3
3
  import { extname, isAbsolute, join, normalize, relative, resolve } from 'node:path';
4
- import { platform } from 'node:os';
5
4
  import { fileURLToPath, pathToFileURL } from 'node:url';
6
5
  import { existsSync, mkdirSync, readFileSync } from 'node:fs';
7
6
  import { createHash } from 'node:crypto';
@@ -132,8 +131,6 @@ export function parseJsonSafe(value) {
132
131
  }
133
132
  export class Utils {
134
133
  static PK_SEPARATOR = '~~~';
135
- /* v8 ignore next */
136
- static dynamicImportProvider = (id) => import(id);
137
134
  /**
138
135
  * Checks if the argument is not undefined
139
136
  */
@@ -908,21 +905,9 @@ export class Utils {
908
905
  return parts.join('/');
909
906
  }
910
907
  static async dynamicImport(id) {
911
- /* v8 ignore next 7 */
912
- if (platform() === 'win32') {
913
- try {
914
- id = pathToFileURL(id).toString();
915
- }
916
- catch {
917
- // ignore
918
- }
919
- }
920
908
  /* v8 ignore next */
921
- return this.dynamicImportProvider(id);
922
- }
923
- /* v8 ignore next 3 */
924
- static setDynamicImportProvider(provider) {
925
- this.dynamicImportProvider = provider;
909
+ const specifier = id.startsWith('file://') ? id : pathToFileURL(id).href;
910
+ return import(specifier);
926
911
  }
927
912
  static ensureDir(path) {
928
913
  if (!existsSync(path)) {